Permalink
Browse files

added x/y coordinate calculation for viewer

  • Loading branch information...
1 parent babcd45 commit 0ce897f0d0f47af5aa000647ed51774da8879d76 Michael Schleichardt committed Apr 10, 2012
@@ -3,6 +3,16 @@ package info.schleichardt.math
import info.schleichardt.math.angleToDouble
import scala.math._
+object DTMatrix {
+ def calculateXCoordinateViewer(distanceToViewer: Double, rotatedVector: MathVector) = {
+ (distanceToViewer * rotatedVector.content(0)) / (distanceToViewer - rotatedVector.content(2))
+ }
+
+ def calculateYCoordinateViewer(distanceToViewer: Double, rotatedVector: MathVector) = {
+ (distanceToViewer * rotatedVector.content(1)) / (distanceToViewer - rotatedVector.content(2))
+ }
+}
+
class DTMatrix() {
def toConcreteMatrix(phi: Angle, psi: Angle): ValueMatrix = {
val row1: Seq[Double] = Seq(cos(phi), 0, - sin(psi))
@@ -3,6 +3,9 @@ package info.schleichardt.math
object VectorsMain {
def main(args: Array[String]) {
val dT = new DTMatrix().toConcreteMatrix(Angle.fromDegree(10), Angle.fromDegree(20))
- println(dT * (new MathVector(Seq(-.5, -.2, -.3))))
+ val rotatedVector: MathVector = dT * (new MathVector(Seq(-.5, -.2, -.3)))
+ println(rotatedVector)
+ println(DTMatrix.calculateXCoordinateViewer(4.0, rotatedVector))
+ println(DTMatrix.calculateYCoordinateViewer(4.0, rotatedVector))
}
}

0 comments on commit 0ce897f

Please sign in to comment.