diff options
author | iximeow <me@iximeow.net> | 2017-02-19 13:12:52 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2017-02-19 13:12:52 -0800 |
commit | 2770febcc400f5a16aea55ba7f11d942f8ccc22c (patch) | |
tree | 8851aa78b43283c4cb9bf70002a29877632054c9 /src/Math.scala |
initial commit
Diffstat (limited to 'src/Math.scala')
-rw-r--r-- | src/Math.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Math.scala b/src/Math.scala new file mode 100644 index 0000000..601e457 --- /dev/null +++ b/src/Math.scala @@ -0,0 +1,14 @@ +package net.iximeow.raytrace + +import Objects._ + +object Raymath { + def angleBetween(a: Point, b: Point, c: Point): Double = { + val lineA = a - b + val lineB = c - b + Math.acos(lineA.dot(lineB) / (lineA.magnitude * lineB.magnitude)) + } + + def toDegrees(rad: Double): Double = rad * 360 / 2 / Math.PI + def toRadians(deg: Double): Double = deg / 360 * 2 * Math.PI +} |