I have a triangle strip in 3D (see illustration). The triangles do not lie in one plane.
I would like to flatten the triangle strip so that all triangles lie in the plane of the first triangle.
The plan is to rotate the second triangle around its connecting edge with the first triangle so that it becomes in plane with the first triangle. Then I continue this method for the other triangles until all of them are in plane.
If you just rotate every triangle, you have to rotate all the next triangles to keep geometry unchanged - this slow way with quadratic complexity.
Instead of this you can store mutual positions of triangle vertices and restore them in plane.
Possible way (I suppose that vertex numbering is sequential):
For N-th point C=P[N]
calculate and store Len
- length of it's projection to the line AB (A=P[N-2], B=P[N-1]
)
Len = VectorLength(VectorProduct(UnitAB, AC))
and position of this projection at that line (as parameter t).
t = DotProduct(AC, AB) / DotProduct(AB, AB)
To build C'=P'[N]
in the plane, calculate
C' = A' + t * A'B' + Len * VectorProduct(UnitPlaneNormal, UnitA'B')