From 7436c251afa07d157b541084d40237a4def3d7f5 Mon Sep 17 00:00:00 2001 From: Marius Kern <mariusskern@gmail.com> Date: Sat, 3 Aug 2024 13:12:24 +0200 Subject: [PATCH] Triangle fixed --- .../FactHandling/Facts/TriangleFact2.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs index 5487bf40..24b29c2d 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs @@ -66,6 +66,8 @@ protected void calculate_vectors(){ // Rotation = Quaternion.LookRotation(Vector3.Cross((B - A), (C - A)), Vector3.up); // Rotation = Quaternion.LookRotation(forward, new Vector3(1.0F, 0.0F, 0.0F)); + + /* Vector3 forward = Vector3.Cross((B - A), (C - A)); Vector3 up = Vector3.up; @@ -80,6 +82,26 @@ protected void calculate_vectors(){ up = -up; } + Rotation = Quaternion.LookRotation(forward, up); + */ + + + Vector3 forward = Vector3.Cross((B - A), (C - A)); + Vector3 up = C - c; + + /* + Vector3 crossForwardUp = Vector3.Cross(forward, up); + if (Mathf.Abs(crossForwardUp.magnitude) <= Mathf.Epsilon) + { + up = up + (C - c); + } + */ + + if ((C - c).y < 0) + { + up = -up; + } + Rotation = Quaternion.LookRotation(forward, up); } -- GitLab