RobustGeometry.NET icon indicating copy to clipboard operation
RobustGeometry.NET copied to clipboard

Mesh_CreateTetrahedron

Open NMO13 opened this issue 11 years ago • 4 comments

Hi Govert,

let me first tell you how great and useful your library is. I'm currently developing a geometry project in C# and have encountered floating point issues in it. So I'm very thankful about your solution. I've downloaded it and have run the unit tests. One test is failing: the Mesh_CreateTetrahedron throws an assertion failure. I will try your library out and will give you a feedback in the next days.

NMO13 avatar Dec 05 '14 22:12 NMO13

I have a very basic question: Are the arithmetic operations like diff or sum not intended to be used by clients? Because the ExactArithmetic class has just internal scope. Can I only use the geometric predicates?

I think I just was just being conservative about what parts to make public.

You have to be quite careful in using the arithmetic operations in other contexts - I'd suggest you refer to the Shewchuck paper too. How do you intend to use the arithmetic operations otherwise?

govert avatar Dec 07 '14 09:12 govert

Let's say I have two vectors with the same origin. I know that both vectors are collinear. Now I want to know if they are pointing in the same direction or in the oppsite. I think I can't solve that just by means of the two Shewchuk predicates.

Example code (more pseudo than C#): Vector Origin = (0, 0); Vector a = (4, 0); Vector b = (-4, 0); Vector2D t = a - Origin; Vector2D t2 = c - Origin; if (Math.Sign(t.X) != Math.Sign(t2.X) || Math.Sign(t.Y) != Math.Sign(t2.Y)) result = OPPOSITE_DIRECTION; else return = SAME_DIRECTION;

So I just simply check the sign of the X and Y and if they are not equal than I know that these vectors are pointing in the opposite direction.

I wanted to use TwoDiff(double a, double b,double x,double y) in place of the minus operators to avoid rounding errors that could creep in. But I don't know how to use this method.

NMO13 avatar Dec 11 '14 11:12 NMO13

That's a good question. I don't know enough to say whether TwoDiff would give you a reliable check, or whether you need to dig in a bit more carefully. What about adding this check as a geometric primitive, thus keeping the implementation internal, maybe with a few tests?

Otherwise, you are of course free to take and use the code any way you want.

govert avatar Dec 14 '14 09:12 govert

Ok thanks!

NMO13 avatar Dec 24 '14 17:12 NMO13