How to rotate points without moving them?

I need to rotate the triangle so that it lies on a plane defined by the normal n and constant d. enter image description here

I have a normal n1 plane in which there are two triangles. Now I need to rotate the right red triangle so that it turns orange. The points of triangles and normals are stored as 3-dimensional vectors. So far I have done the following:

  • Get the normalized rotation quaternion (rotQuat) between n1 and n2.
  • Multiply each point of the triangle by a quaternion. Therefore, I convert the point to a quaternion (point.x, point.y, point.z, 0) and do the following: resultQuat = rotQuat * point * conjugate (rotQuat). Then I apply x, y and z to the point.

This is how I get the rotation between two vectors:

public static Quaternion getRotationBetweenTwoVector3f(Vector3f vec1, Vector3f vec2)
{
    Vector3f cross = Vector3f.cross(vec1, vec2);
    float w = (float) (java.lang.Math.sqrt(java.lang.Math.pow(vec1.getLength(), 2) * java.lang.Math.pow(vec2.getLength(), 2)) + Vector3f.dot(vec1, vec2));
    Quaternion returnQuat = new Quaternion(cross.x, cross.y, cross.z, w);
    returnQuat.normalize();
    return returnQuat;
}

, , . , , (, ). ?

+4
1

, / , . , , ( ), .

, :

  • translPoints [i] = triPoints [i] - rotationPoint;
  • translPoints
  • , .
+1

All Articles