mathnet / mathnet-spatial

Math.NET Spatial
http://spatial.mathdotnet.com
MIT License
376 stars 132 forks source link

Plane created from three points returns different result for Equals depending on the order of the points #172

Closed vazrupe closed 1 year ago

vazrupe commented 5 years ago

Version: 0.5

Point3D pt1 = new Point3D(3, 3, 0);
Point3D pt2 = new Point3D(3, 0, 3);
Point3D pt3 = new Point3D(0, 3, 3);

Plane plane1 = Plane.FromPoints(pt1, pt2, pt3);
Plane plane2 = Plane.FromPoints(pt1, pt3, pt2);

bool equals = plane1.Equals(plane2); // false

A plane made from the same three points, but returns false when compared.

JohanLarsson commented 5 years ago

Is there an overload with tolerance? Should probably be two tolerances, one for max distance between base points and one for max angle between normals.

vazrupe commented 5 years ago

Instead of comparing angles, you can substitute one more comparison with Negative Normal.

RootPoint.Equals(plane.RootPoint[, tolerance]) && (Normal.Equals(plane.Normal[, tolerance]) || Normal.Equals(-plane.Normal[, tolerance]))

vazrupe commented 4 years ago

@JohanLarsson

I've tested and found that I don't understand this very well.

I understood Normal as a vector that simply determines the plane. But in practice it's being used as a direction.

It would be nice to add a function like this:

What do you think about this?

JohanLarsson commented 4 years ago

A function that returns the plane in which Normal is inverted

Doesn't Plane have a Flip() method? I don't remember.

Function to compare planes irrespective of Normal

Not sure what semantics you have in mind here.

DaveInCaz commented 3 years ago

I think when the plane's A,B,C,D are all negated, you get it 'flipped'. I've read that the directionality can be used to describe a "half plane" meaning, the half of all space to the side of the plane the normal points into. So it can be a useful concept in some cases.

A function which checks if two plane objects are the negated / flipped versions of each other could be handy.