次の物理シミュレーションで浮動小数点エラーを修正するにはどうすればよいですか。
- 原点(x、y、z)、
- 力が適用された後の目的の点 (x'、y'、z')。
- 辺 BC を共有する 2 つの三角形 (A, B, C) と (B, C, D)
衝突検出にこの方法を使用しています:
For each Triangle
If the original point is in front of the current triangle, and the desired point is behind the desired triangle:
Calculate the intersection point of the ray (original-desired) and the plane (triangle's normal).
If the intersection point is inside the triangle edges (!)
Respond to the collision.
End If
End If
Next Triangle
私が抱えている問題は、技術的には常にどちらか一方と衝突する必要があるにもかかわらず、点が線 BC に非常に近い浮動小数点演算の灰色の領域に入ることがあるということです。彼らはエッジを共有しています。これが発生すると、ポイントは 2 つのエッジ共有三角形の間を通過します。コードの 1 行を(!)でマークしました。これは、変更を加える必要があると思われるためです。
非常に限られた状況で機能する 1 つのアイデアは、エッジ テストをスキップすることです。三角形を効果的に平面に変えます。これは、メッシュが凸包である場合にのみ機能しますが、凸形状を作成する予定です。
私は特に、前後のすべてのテストで内積と三角形の法線を使用しています。