I would like to store the x y and z co-ords for some objects for a game but I can't find a built in class like Point. Is there a nice standard class I could add in and use that would handle distance between points/bearings from one object to another etc?
Class Point. A point representing a location in (x,y) coordinate space, specified in integer precision.
In the mathematical field of descriptive set theory, a pointclass is a collection of sets of points, where a point is ordinarily understood to be an element of some perfect Polish space.
Having recently done some vector mapping (including z / 3D), and seeing your Android tag, I recommend rolling your own.
The reasons are many:
In the end, most of these primitives are quite simple to write, test, etc. The main methods you'll need to write (beyond boilerplate constructor/get/set/...) - Distance - Dot product - Unitize (make length == 1 for various math ops) - And I've used DistanceSquared in the past for comparison functions... This removes the sqrt operator from most distance methods, while computing a relative distance useful enough for comparing point distances etc.
Maybe Point3D is what you need.
There is also a JavaFX class Point3D that meets your requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With