Open bubblobill opened 1 month ago
org.locationtech.jts.math.Vector2D is already available in one of the libraries in use by MapTool.
org.locationtech.jts.math.Vector2D is already available in one of the libraries in use by MapTool.
I checked it out and it mostly has what I want but still has some irritating foibles. Unsurprisingly it is well plumbed into the jts ecosystem which comes with things both useful and superfluous. I'm inclined to use it as a delegate and tack on the other bits I want. Still requires me creating a new class though, not sure if it will be more or less work.
org.locationtech.jts.math.Vector2D is already available in one of the libraries in use by MapTool.
I checked it out and it mostly has what I want but still has some irritating foibles. Unsurprisingly it is well plumbed into the jts ecosystem which comes with things both useful and superfluous. I'm inclined to use it as a delegate and tack on the other bits I want. Still requires me creating a new class though, not sure if it will be more or less work.
Looking at the class it seems pretty complete, what is it missing that you wanted?
It's designed for doing GIS stuff, so it overdoes some things and misses some graphical operations that are inappropriate for its target purpose. Examples:
Getting things into and out of it is painful. It doesn't deal directly with Point, Point2D, or Point3D. Seems to require a different transform class, generator, or builder in order to talk to half the types we use. jts uses it's own point class "coordinate" which is a geo-something point 3D with an extra dimension which again is overkill for most simple operations and I had to dig deep to find IdentityPointTransformation.transfom(Coordinate, Point2d) which only goes one way.
Personal beefs with this and other vector classes:
That's why I'm thinking delegate. That way I can write the annoying stuff once to make it transparent, and I can staple on any other neat bits as and when they become useful.
It's designed for doing GIS stuff, so it overdoes some things and misses some graphical operations that are inappropriate for its target purpose. Examples:
- "interpolate" is for points along a path which is a bit heavy handed when you want distance along a line.
- Has no homography (that I could find). The one truly complex operation I want is nowhere to be found.
- Don't see any gains in the precision of a custom DoubleDouble number type either.
Getting things into and out of it is painful. It doesn't deal directly with Point, Point2D, or Point3D. Seems to require a different transform class, generator, or builder in order to talk to half the types we use. jts uses it's own point class "coordinate" which is a geo-something point 3D with an extra dimension which again is overkill for most simple operations and I had to dig deep to find IdentityPointTransformation.transfom(Coordinate, Point2d) which only goes one way.
Personal beefs with this and other vector classes:
- it has no setX/Y()
- Coordinate is comparable (strangely, only in 2 dimensions) but its vectors are not.
- Vector2D and 3D are either; not interchangeable, or provide no conversion methods. Before you point out they shouldn't be: A 2D vector is the same as a 3D vector with z=0
Ok, what should I do before I point out that is not strictly correct :)
Also, what is the cross product of two 2D vectors? An incovenient vector perpendicular to both axes, i.e 3D.
There is a certain Nathan Fillion GIF I want to insert :) By definition, you can't do a cross-product of 2D vectors
But I digress... What did you need the vector class for / to do? Then we can see if we can find anything useful or, if not, write one.
There is a certain Nathan Fillion GIF I want to insert :) By definition, you can't do a cross-product of 2D vectors
I know, I know, but often working with 2D vectors is actually working in a 3D space and ignoring one axis until reality rudely intrudes and you have to go back to 3D.
But I digress... What did you need the vector class for / to do? Then we can see if we can find anything useful or, if not, write one.
I just wrote a nice long set of cogent examples until the GitHub app swallowed it all and did nothing. Hopefully I remember the salient points.
Two distinct use cases.
Describe the problem
Disambiguation: Vectors = Magnitude And Direction
The improvement you'd like to see
Make AbstractPoint an extension of a new class AbstractVector. AbstractVector can be defined using generic types (I believe) to make it easier to deal with extracting the numeric type you want without having to convert stuff between Int/Float/Double/BigDecimal.
Expected Benefits
One point to rule them all. No longer have to accommodate fiddly bits to shoehorn existing classes or create repetitious classes to do with complex operations. Can be exposed to macro functions to perform vector maths. More accurate conversions to output integer points
Additional Context
I've written (stolen) one, and am looking at getting it to work. Hoping other people will chime in and tell me if I am wasting my time or make comment on what it should and shouldn't be.