1
0

Added sample image output for transformations

This commit is contained in:
neviyn 2020-11-08 22:08:38 +00:00
parent a076b82bfc
commit f2729c59c3
2 changed files with 19 additions and 4 deletions

2
.gitignore vendored
View File

@ -154,4 +154,4 @@ modules.xml
# End of https://www.toptal.com/developers/gitignore/api/intellij+all
raytracer_nim
output.ppm
*.ppm

View File

@ -1,4 +1,4 @@
import "./tuple", "./canvas"
import "./tuple", "./canvas", "./matrix", "./transformations", math
type
Projectile = object
@ -10,7 +10,7 @@ type
proc tick(proj: Projectile, env: Environment): Projectile = Projectile(position: proj.position + proj.velocity, velocity: proj.velocity + env.gravity + env.wind)
when isMainModule:
proc arc() =
var world = canvas(800, 600)
let start = point(0, 1, 0)
let velocity = normalize(vector(0.5, 1.2, 0)) * 11.25
@ -28,6 +28,21 @@ when isMainModule:
if(600 - projectile.position.y + 1 < 600):
world.writePixel(projectile.position.x, 600 - projectile.position.y + 1, colour)
projectile = projectile.tick(environment)
writeFile("output.ppm", world.toPPM())
writeFile("arc.ppm", world.toPPM())
proc clock() =
var world = canvas(200, 200)
var p = point(0.0, 0.0, 1.0)
let colour = colour(1, 1, 1)
let oneHourRotation = rotationY(PI / 6)
for i in 0..11:
let target = p.scale(60.0, 0.0, 60.0).translate(100.0, 0.0, 100.0)
world.writePixel(target.x, target.z, colour)
p = oneHourRotation * p
writeFile("clock.ppm", world.toPPM())
when isMainModule:
arc()
clock()