Java // Rotation matrices // 3D [ x,y,z ] // Point about the origin;

1.5k views Asked by At

Intro I have been researching this topic for a while, however do not entirely grasp it. I have looked on stackoverflow as well as other on-line resources for an example, but couldn't find a fairly similar problem to refer to. Any help would be very much appreciated.

To reduce the amount of duplicates, please notify me if there is such question already answered so I can remove this question;

Objective: Rotate a point [ x,y,z ] in 3D space around an origin using rotation matrices;

Problem specification: Insufficient level of understanding in the above topic. Uncertainty in the implementation;

Reference: http://en.wikipedia.org/wiki/Rotation_matrix

Code structure:

class RotationMatrix{
        private double theta; // Rotiation angle;
        private double rotateX[][] = {{1,0,0},{0,Math.cos(theta),-Math.sin(theta)},{0,Math.sin(theta),Math.cos(theta)}};   // Rotation matrice for x axis;
        private double rotateY[][] = {{Math.cos(theta),0,Math.sin(theta)},{0,1,0},{-Math.sin(theta),0,Math.cos(theta)}};   // Rotation matrice for y axis;
        private double rotateZ[][] = {{Math.cos(theta),-Math.sin(theta),0},{Math.sin(theta),Math.cos(theta),0},{0,0,1}};   // Rotation matrice for z axis;

    // Method to rotate point in interest in 3D [ x,y,z ];
    public void Rotate3D(Node n,double[] point){             // Method to be called (Node n to provide direction N/E/U) and array[] point to provide the coordinates of the point in interest;


            if(n.getN() == 1){                                 
                while(theta != 6.28318531){                           // Rotate by 90 degrees till theta != 360;
                    theta += 1.57079633;
                // do rotation around 'y' axis;
                }
            }
            else if(n.getE() == 1){                         
                while(theta != 6.28318531){                        // Rotate by 90 degrees till theta != 360;
                    theta += 1.57079633;
                // do rotation around 'x' axis;
                }
            }
            else if(n.getU() == 1){
                while(theta != 6.28318531){                        // Rotate by 90 degrees till theta != 360;
                    theta += 1.57079633;
                // do rotation around 'z' axis;
                }
            } else {
                System.out.println("The rotation has failed \n"
                        + "The direction data is missing...");
            }
        }
    }
0

There are 0 answers