summaryrefslogtreecommitdiff
path: root/src/Math.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/Math.scala')
-rw-r--r--src/Math.scala14
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
+}