Here is a direct port of immutable.Ray:
{{{
import simplex3d.math.doublem._
import simplex3d.math.doublem.DoubleMath._
class Ray protected(val origin: Vec3d, val direction: Vec3d) {
def pointAtDistance(d: Double) = Vec3d(
origin.x + (direction.x * d),
origin.y + (direction.y * d),
origin.z + (direction.z * d)
)
def transform(m: inMat3x4d) = new Ray(
m.transformPoint(origin),
normalize(m.transformVector(direction))
)
// Not sure what this does
def translate() :Vec3d = {
val t = -origin.z / direction.z
Vec3d(
origin.x + direction.x * t,
origin.y + direction.y * t,
origin.z + direction.z * t
)
}
override def toString() =
"Ray(origin=" + origin + ", direction=" + direction + ")"
}
object Ray {
def apply(origin: Vec3d, direction: Vec3d) = new Ray(origin,
direction)
}
}}}
I will think more about a smoother way to integrate the two API,
meanwhile I hope it helps you a little.
On Jun 28, 7:04 pm, "Hicks, Matt" <
mhi...@captiveimagination.com>
wrote: