Skip to content

Commit

Permalink
Changed length check to 0 to be approximate.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Jan 5, 2025
1 parent 539ba4f commit 300dee9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions FinModelUtility/Formats/Vrml/Vrml/src/util/Misc.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
using System.Numerics;

using fin.math.floats;
using fin.math.matrix.three;

namespace vrml.util;

class Misc {
public static int GetOrientation(Vector3m v0,
Vector3m v1,
Vector3m v2,
Vector3 normal) {
var res = (v0 - v1).Cross(v2 - v1);
if (res.LengthSquared().ToDouble() == 0)
var res = (Vector3) ((v0 - v1).Cross(v2 - v1));
if (res.Length().IsRoughly0()) {
return 0;
}

if (Math.Sign(res.X) != Math.Sign(normal.X) ||
Math.Sign(res.Y) != Math.Sign(normal.Y) ||
Math.Sign(res.Z) != Math.Sign(normal.Z))
Expand Down
6 changes: 6 additions & 0 deletions FinModelUtility/Formats/Vrml/Vrml/src/util/Vector3m.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
namespace vrml.util;

public class Vector3m {
public static implicit operator Vector3(Vector3m vec)
=> new(vec.X, vec.Y, vec.Z);

public static implicit operator Vector3m(Vector3 vec)
=> new(vec.X, vec.Y, vec.Z);

public Vector3m(float x, float y, float z) {
this.X = x;
this.Y = y;
Expand Down

0 comments on commit 300dee9

Please sign in to comment.