- Home /
Rotate plane by normal, how to calculate new position?
I hava a plane, which I know the normal(normal0), and 2 points(pointA, pointB).
Now I have another normal:normal1.
I need to rotate plane from normal0 to normal1 around pointA, How can I know the new position pointB after rotation?
The func would be like:
Vector3 changeNormal(Vector3 normal0, Vector3 normal2, Vector3 pointA, Vector3 pointB) { .....
return newPointB
}
Answer by rocket350 · Jul 27, 2016 at 10:49 AM
This function should just do the trick:
Vector3 changeNormal(Vector3 normal0, Vector3 normal2, Vector3 pointA, Vector3 pointB) {
Quaternion rotation = Quaternion.FromToRotation(normal0, normal2); //Get rotation between both normals
Vector3 rotationDir = pointB - pointA; // Get point direction relative to pivot
rotationDir = rotation * rotationDir; // Rotate it
pointB = rotationDir + pointA; // Calculate rotated point
return pointB;
}
Thanks a lot !!! It's kind of basic but I was blocked on this
Your answer
Follow this Question
Related Questions
Rotate a vector3 to a surface normal? 1 Answer
Problem with normal snapping and rotations. 1 Answer
make enemy only follow along the X and Z axis 1 Answer
add force in a particular direction 0 Answers
Instant Transform.Rotate? 1 Answer