diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs index 8676234babc1712eabb8655536855a32edd175f7..86696d9de11c0fdd32f3a9d12b7857b4865f50be 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/TriangleFact2.cs @@ -63,9 +63,19 @@ protected void calculate_vectors(){ Position = A; - Rotation = Quaternion.LookRotation(Vector3.Cross((B - A), (C - A)), Vector3.up); - //Rotation = Quaternion.LookRotation(forward, new Vector3(1.0F, 0.0F, 0.0F)); - + // 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; + + Vector3 crossForwardUp = Vector3.Cross(forward, up); + if (Mathf.Abs(crossForwardUp.magnitude) <= Mathf.Epsilon) + { + up = up + (C - c); + } + + Rotation = Quaternion.LookRotation(forward, up); } public TriangleFact2() : base(){