summaryrefslogtreecommitdiff
path: root/src/main.scala
blob: a0ea4cd43fbd1155da234b41d721d22ae272898d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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, 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)
  //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)
    }
  }
*/

/*
  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()
}