I want to rotate a point (Vector3f) around another point (Vector3f). The problem is that i don’t want to rotate around the x,y or z-axis but the axis shown in the picture. The axis is defined by the Position of the points. P1, P2 and the angle are known. I want to calculate P1’.
Are there methods i can use to do this?
rotate_dragon (ang) = {
var radius1 = 3
var ang_rad = 3.14/180*ang
var p1_x = p2_x+cos(ang_rad)*radius1
var p1_y = p2_y+sin(ang_rad)*radius1
var p1_z = p2_z
p1.move to (p1_x,p1_y,p1_z) in 0.1 seconds
run rotate_dragon(ang+3) async
}
and then you can adjust specific angle rotation like:
rotation[0] += moveDirection.x;
rotation[1] += moveDirection.y; // use only one of them
rotation[2] += moveDirection.z;
#Node(parent)#quaternion = new Quaternion().fromAngles(rotation);
Vector3f axis =new Vector3f(2,3,4);
Obj.rotate(new Quaternion().fromAngleAxis(axis.normalize(),Math.PI));
/*Your point that is rotated */
Vector3f point = Obj.getLocalTranslation();
Actually I havenot yet tried it , I have used predefined values as in wiki UNIT_X , UNIT_Y, UNIT_Z which are actually normalized vectors that are coincident on their corresponding axes , so I think it would be the same
Thanks for the fast answer. But this will not solve my problem because you dont’t change p1_z. So you turn round the z-Axis. The axis i need to turn around depends on the relation of the to points (look at my jpg). So x,y and z of the point have to be changed.
Sorry, i don’t know how this solves my Problem. When i rotate a node i can only rotate it around x, y, or z-axis. But the rotation i need goes around another axis (see jpg).
There is some way to build a node hierarchy to do what you want. It may require one more node than you think but it can definitely be done (I think it’s mathematically provable).
Make a node that’s positioned where you want it. Rotate it so that one of it’s axes aligns with the one you want to rotate around. Add another child and rotate that one around that axis.