summaryrefslogtreecommitdiff
path: root/src/Math.scala
blob: 601e4571f238f6dfc265929cd508578cc5cf4247 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
}