简介 我一直在研究这个主题一段时间,但并没有完全掌握它。我查看了 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...");
}
}
}