im trying to make a hole into a triangle in 3D space using XNA.
I want to convert this problem to 2D space.
But i dont know how to rotate the triangle that all the points have Z = 0.
Point1 has the coordinats X=0,Y=0,Z=0.
Anyone know a solution?
LG
Jens
im trying to make a hole into a triangle in 3D space using XNA.
Share
Given
P1,P2,P3the points of the triangle.Let’s note:
a = P2 - P1b = P3 - P1n = Vector3.CrossProduct(a, b).Normalized()->nis the normal of the triangleThe triangle is in the
Z = 0plane if and only of,n.z = 0Then, just use:
d = Vector3.CrossProduct(n, z).Normalized()-> it is the axis of your rotationangle = (float)System.Math.Acos(Vector3.DotProduct(n, z))-> it is the angle of your rotationThe code is: