/** * Multiply this Matrix for a General Rotation: alpha is the rotation angle in radians and (x,y,z) * is the direction of the rotation ax */ public void rotateGeneral(float alpha, float x, float y, float z) { // Direction3f dir=new Direction3f(x,y,z); Vertex3f dir = new Vertex3f(x, y, z); dir.normalize(); // Direction3f A=dir.getNormalCandidate(); Vertex3f A = dir.getNormalCandidate(); A.normalize(); Vertex3f B = dir.getVectorProduct(A); // Direction3f B=dir.getVectorProduct(A); // Construct a Third Vector B normal to Both V and A Transform3f t = new Transform3f(); float cos = (float) (Math.cos(alpha)); float sin = (float) (Math.sin(alpha)); t.mM.A = dir.getX(); t.mM.B = A.getX(); t.mM.C = B.getX(); t.mM.E = dir.getY(); t.mM.F = A.getY(); t.mM.G = B.getY(); t.mM.I = dir.getZ(); t.mM.L = A.getZ(); t.mM.M = B.getZ(); mult(t); t.mM.A = dir.getX(); t.mM.B = dir.getY(); t.mM.C = dir.getZ(); t.mM.E = A.getX() * cos - B.getX() * sin; t.mM.F = A.getY() * cos - B.getY() * sin; t.mM.G = A.getZ() * cos - B.getZ() * sin; t.mM.I = A.getX() * sin + B.getX() * cos; t.mM.L = A.getY() * sin + B.getY() * cos; t.mM.M = A.getZ() * sin + B.getZ() * cos; mult(t); }