Advertisement
Guest User

Untitled

a guest
Sep 21st, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1.   public Torus(Double[] xiOrigin, Vector xiNormal, double xiMainRadius,
  2.                double xiRingRadius, double xiReflectionCoeff,
  3.                Double[] xiDiffCoeff, Double[] xiSpecCoeff,
  4.                double xiShinyness) {
  5.     mOrigin = xiOrigin;
  6.     mMainRadius = xiMainRadius;
  7.     mRingRadius = xiRingRadius;
  8.     mReflCoeff = xiReflectionCoeff;
  9.     mDiffCoeff = xiDiffCoeff;
  10.     mSpecCoeff = xiSpecCoeff;
  11.     mShinyness = xiShinyness;
  12.    
  13.     xiNormal = xiNormal.Normalise();
  14.     Double[] lNormalComponents = xiNormal.getDifferences();
  15.    
  16.     if ((lNormalComponents[0] == 0) && (lNormalComponents[1] == 0)) {
  17.       mRotation = new Matrix3D();
  18.     }
  19.     else {
  20.       double div = Math.sqrt(Math.pow(lNormalComponents[0], 2) +
  21.                              Math.pow(lNormalComponents[1], 2));
  22.       double cos = lNormalComponents[1] / div;
  23.       double sin = lNormalComponents[0] / div;
  24.       Matrix3D z_rot = Matrix3D.rot_z(cos, sin);
  25.       System.out.println("Z rotation : Cos = " + cos + ", Sin = " + sin);
  26.  
  27.       double ydash = (sin * lNormalComponents[0]) +
  28.                      (cos * lNormalComponents[1]);
  29.      
  30.       double div2 = Math.sqrt(Math.pow(lNormalComponents[2], 2) + (ydash * ydash));
  31.       double cos2 = lNormalComponents[1] / div2;
  32.       double sin2 = ydash / div2;
  33.       Matrix3D x_rot = Matrix3D.rot_x(cos2, sin2);
  34.       System.out.println("div2 = " + div2);
  35.       System.out.println("X rotation : Cos = " + cos2 + ", Sin = " + sin2);
  36.  
  37.       mRotation = x_rot.timesMatrix(z_rot);
  38.      
  39.       double[][] TODO = {{1.0, 0.0, 0.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}};
  40.       mRotation = new Matrix3D(TODO);
  41.     }
  42.    
  43.     System.out.println(mRotation.mMatrix[0][0] + "," + mRotation.mMatrix[0][1] + ":" + mRotation.mMatrix[0][2]);
  44.     System.out.println(mRotation.mMatrix[1][0] + "," + mRotation.mMatrix[1][1] + ":" + mRotation.mMatrix[1][2]);
  45.     System.out.println(mRotation.mMatrix[2][0] + "," + mRotation.mMatrix[2][1] + ":" + mRotation.mMatrix[2][2]);
  46.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement