简体   繁体   中英

Algorithm to flatten a 3D triangle strip

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.

  1. I am looking for a fast algorithm to do that.
  2. Are there other methods to flatten the triangle strip?

Keep in mind you are only going to be moving one point at a time. Since each triangle shares two points with the previous one, only the far point needs to move, and will move around the axis created by the other two points, until it lies on the desired plane. Repeat this process until done.

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')

最快的方法是1)计算第一个三角形定义的平面的方程式2)将所有休息点投影到该平面上

I found this question having just implemented a 3D triangle-strip flattening algorithm myself in C++ for purposes unrelated to the original poster's goal of finding a shorted path. I basically took the route of rotating the second triangle around the common edge with the first, and repeating along the strip. However, due to the cumulative nature of the process, I have found that even with 20 or so triangles, errors in vertex positions pile up very quickly, giving noticeably different overall results when the vertex order is reversed.

I believe this is due to the mathematical complexities of working in 3D, so to answer the original question 2, I think a much better approach will just be to take the triangle side lengths and then rebuild the strip from scratch in 2D, where the maths is much simpler. It should then be easy enough to transform the whole thing back to restore the position and orientation of the first triangle if necessary, but I don't think the original poster needed this, and neither do I.

I am going to try this and will report back here.

EDIT : It didn't help. See my comment below.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM