summaryrefslogtreecommitdiff
path: root/src/main.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.scala')
-rw-r--r--src/main.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main.scala b/src/main.scala
new file mode 100644
index 0000000..8883cc7
--- /dev/null
+++ b/src/main.scala
@@ -0,0 +1,40 @@
+import net.iximeow.raytrace._
+import Objects._
+
+object main extends App {
+// val mirror = Scene(Scene.generateMirror(10, 60, Raymath.toRadians(180), Point(0, 0), 0))
+ val offset = Point(0.0, -9)
+ val mirror = Scene(Scene.generateParabola(-0.9, -0.0075, 16, 0, 42, Point(0, 14), 0) :+ Segment.fromPoints(
+ Point(-0.5, 0.5) + offset,
+ Point(0.5, -0.5) + offset
+ ))
+// val mirror = Scene(Seq(Segment(4, -4, Point(-2, 2))))
+ //val ray = mirror.cast(Ray(0, 2, Point(0.8, -1)), 4)
+ mirror.render(scale = 20, color = 0xc0c0c0, normals = true)
+ //for (segment <- ray) {
+ // segment.renderTo(mirror.buffer, 20, 400, 300)
+ //}
+/*
+ for (i <- -4 to 4 by 1) {
+ for (segment <- mirror.cast(Ray(i / 2.0, 2, Point(0.8, -1)), 4)) {
+ segment.renderTo(mirror.buffer, 20, 400, 300)
+ }
+ }
+*/
+ def rays(number: Int, spacing: Double, centerpoint: Point, direction: Point): Seq[Ray] = {
+ (0 until number).map { i =>
+ val x = (i.toDouble - number.toDouble / 2) * spacing
+ val y = 0
+ val dx = direction.x
+// * Math.cos((i.toDouble - number.toDouble) / (number.toDouble / 4))
+ val dy = direction.y
+ Ray(dx, dy, Point(x, y) + centerpoint)
+ }
+ }
+
+ rays(63, 0.165, Point(-0, -10), Point(0.0, 2))
+ .flatMap(x => mirror.cast(x, 30))
+ .map(_.renderTo(mirror.buffer, 20, 400, 300))
+ //println(ray)
+ mirror.save()
+}