jscad / csg.js

DEPRECATED: CSG Library for JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/master/packages/modeling
MIT License
218 stars 56 forks source link

math/line3 is broken #153

Closed pentacular closed 5 years ago

pentacular commented 5 years ago

math/line3 seems to be confused between lines and vectors on lines and line segments.

In particular line3 equals is wrong -- two mathematically equal lines will generally compare false.

I think we need to decide what line3 is trying to describe before fixing it.

z3dev commented 5 years ago

Actually, I don’t understand the existence of these two objects, line2 and line3. These seem to be unbounded lines with slope. It seems that line2 is supposed to be a line defined in Hesse normal form. I thought line3 is suppose to be to the complement in 3D.

line2 is used. line3 is not used.

kaosat-dev commented 5 years ago

agreed, we should find a way to remove it if not absolutely needed: Here is the listing of where it was/is used:

pentacular commented 5 years ago

Actually, it's been very useful in the watertightness detection code I've put together before trying to replace fixTJunctions.

I think that I understand what line3 is now, and I think it mostly needs documentation and some changes to the equals operator.

They are a combination of (point, and unit vector) to describe a line, which is valid.

The problem is in the semantics of equals -- what is line3.equals measuring?

Currently it measures the equality of the implementation as (point, and unit vector), but doesn't measure line equality.

Elsewhere I've run into some other problems with equals, where it isn't practically possible to compute total equality, but is practical to compute 'definite inequality'.

For example, in the geometries, there are many possible isomorphisms.

I'll think about it some more --- it might just be that equals needs to be a little more nuanced.

z3dev commented 5 years ago

Maybe we shouldn’t have equal which implies exact equality. Maybe a better check is equivalence between lines... meaning the two lines represent the same line. The check would include...

equivalent(a, b)

pentacular commented 5 years ago

I saw some suggestion that line3 be called a 'ray' somewhere, which sounds about right, as it's direction from a point.

So, how about line3 -> ray3 and worry about the rest later?

z3dev commented 5 years ago

It’s not a Ray in the true sense, so kept Line. The functionality also works like an line, as you can see in the test cases.

https://en.m.wikipedia.org/wiki/Line_(geometry)

Also, shouldn’t this just be an issue? There isn’t any code change.

pentacular commented 5 years ago

It’s not a Ray in the true sense, so kept Line. The functionality also works like an line, as you can see in the test cases.

Except that they can't be compared as lines (as far as I can see).

https://en.m.wikipedia.org/wiki/Line_(geometry)

Also, shouldn’t this just be an issue? There isn’t any code change.

Probably. :)