From b1376dff1a375c1371e175817c392f9cbce79377 Mon Sep 17 00:00:00 2001 From: iximeow Date: Wed, 22 Mar 2017 00:59:44 -0700 Subject: partial refactoring to Surface instead of Segment + parabolic lenses --- src/main.scala | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/main.scala') diff --git a/src/main.scala b/src/main.scala index 8883cc7..a0ea4cd 100644 --- a/src/main.scala +++ b/src/main.scala @@ -4,10 +4,12 @@ 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(Scene.generateParabola(-0.9, -0.0075, 16, 0, 142, Point(0, 14), 0) :+ Segment.fromPoints( +// Point(-0.5, 0.5) + offset, +// Point(0.5, -0.5) + offset +// ) :+ ParabolicLens(Point(4, -9), -Math.PI / 2, 1, 0.2) :+ ParabolicLens(Point(5, -1), 0, 1, 0.4)) +// + val mirror = Scene(Seq(ParabolicLens(Point(0, 1), 0.00, 2, 0.2))) // 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) @@ -21,20 +23,15 @@ object main extends App { } } */ - 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)) +/* + rays(63, 0.165, Point(-0, -10), Point(0.0, 4)) + .flatMap(x => mirror.cast(x, 63)) .map(_.renderTo(mirror.buffer, 20, 400, 300)) //println(ray) +*/ + Scene.rays(4, 0.165, Point(0, -10), Point(0.0, 40)) + .flatMap(x => mirror.cast(x, 2)) + .map(_.renderTo(mirror.buffer, 20, 400, 300)) mirror.save() } -- cgit v1.1