Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Torus(Double[] xiOrigin, Vector xiNormal, double xiMainRadius,
- double xiRingRadius, double xiReflectionCoeff,
- Double[] xiDiffCoeff, Double[] xiSpecCoeff,
- double xiShinyness) {
- mOrigin = xiOrigin;
- mMainRadius = xiMainRadius;
- mRingRadius = xiRingRadius;
- mReflCoeff = xiReflectionCoeff;
- mDiffCoeff = xiDiffCoeff;
- mSpecCoeff = xiSpecCoeff;
- mShinyness = xiShinyness;
- xiNormal = xiNormal.Normalise();
- Double[] lNormalComponents = xiNormal.getDifferences();
- if ((lNormalComponents[0] == 0) && (lNormalComponents[1] == 0)) {
- mRotation = new Matrix3D();
- }
- else {
- double div = Math.sqrt(Math.pow(lNormalComponents[0], 2) +
- Math.pow(lNormalComponents[1], 2));
- double cos = lNormalComponents[1] / div;
- double sin = lNormalComponents[0] / div;
- Matrix3D z_rot = Matrix3D.rot_z(cos, sin);
- System.out.println("Z rotation : Cos = " + cos + ", Sin = " + sin);
- double ydash = (sin * lNormalComponents[0]) +
- (cos * lNormalComponents[1]);
- double div2 = Math.sqrt(Math.pow(lNormalComponents[2], 2) + (ydash * ydash));
- double cos2 = lNormalComponents[1] / div2;
- double sin2 = ydash / div2;
- Matrix3D x_rot = Matrix3D.rot_x(cos2, sin2);
- System.out.println("div2 = " + div2);
- System.out.println("X rotation : Cos = " + cos2 + ", Sin = " + sin2);
- mRotation = x_rot.timesMatrix(z_rot);
- double[][] TODO = {{1.0, 0.0, 0.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}};
- mRotation = new Matrix3D(TODO);
- }
- System.out.println(mRotation.mMatrix[0][0] + "," + mRotation.mMatrix[0][1] + ":" + mRotation.mMatrix[0][2]);
- System.out.println(mRotation.mMatrix[1][0] + "," + mRotation.mMatrix[1][1] + ":" + mRotation.mMatrix[1][2]);
- System.out.println(mRotation.mMatrix[2][0] + "," + mRotation.mMatrix[2][1] + ":" + mRotation.mMatrix[2][2]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement