我有4个矢量的坐标定义了一个四边形,另一个定义了它是正常的。我试图获得四边形的旋转。我只是使用法线在X和Y上获得了很好的旋转效果,但由于我只使用了1个向量,因此无法获得Z.
以下是使用Processing和toxiclibs(Vec3D和heading methods)进行的基本测试:
import toxi.geom.*;
Vec3D[] face = {new Vec3D(1.1920928955078125e-07, 0.0, 1.4142135381698608),new Vec3D(-1.4142134189605713, 0.0, 5.3644180297851562e-07),new Vec3D(-2.384185791015625e-07, 0.0, -1.4142135381698608),new Vec3D(1.4142136573791504, 0.0, 0.0),};
Vec3D n = new Vec3D(0.0, 1.0, 0.0);
print("xy: " + degrees(n.headingXY())+"\t");
print("xz: " + degrees(n.headingXZ())+"\t");
print("yz: " + degrees(n.headingYZ())+"\n");
println("angleBetween x: " + degrees(n.angleBetween(Vec3D.X_AXIS)));
println("angleBetween y: " + degrees(n.angleBetween(Vec3D.X_AXIS)));
println("angleBetween z: " + degrees(n.angleBetween(Vec3D.X_AXIS)));
println("atan2 x: " + degrees(atan2(n.z,n.y)));
println("atan2 y: " + degrees(atan2(n.z,n.x)));
println("atan2 z: " + degrees(atan2(n.y,n.x)));
这是输出:
xy: 90.0 xz: 0.0 yz: 90.0
angleBetween x: 90.0
angleBetween y: 90.0
angleBetween z: 90.0
atan2 x: 0.0
atan2 y: 0.0
atan2 z: 90.0
如何获得我的四边形Z的旋转(围绕它的中心/法线)?
答案 0 :(得分:2)
答案 1 :(得分:0)
这是z轴的旋转矩阵
cos(theta)sin(theta)0
-sin(theta)cos(theta)0
0 0 1
结果是旋转的矢量