Java //旋转矩阵// 3D [x,y,z] //关于原点的点;

时间:2013-12-11 14:49:49

标签: java matrix rotational-matrices

简介 我一直在研究这个话题,但是并没有完全掌握它。我已经查看了stackoverflow以及其他在线资源的示例,但是找不到一个相当类似的问题来引用。任何帮助将非常感谢。

要减少重复数量,如果已经回答了这样的问题,请通知我,以便我可以删除此问题;

目标:使用旋转矩阵在原点周围的3D空间中旋转点[x,y,z];

问题说明:上述主题的理解水平不足。实施中的不确定性;

参考: http://en.wikipedia.org/wiki/Rotation_matrix

代码结构:

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 个答案:

没有答案