Package com.j3d.engine.math
Class CartesianPoint
CartesianPoint, not to be confused with
ScreenPoint, represents
a point in 2D space.
(On the Cartesian AxisPlane, where (0, 0) is the centre of the window.)
All 2d points should be calculated in CartesianPoint, but when you
want to show it on the screen, converted to a ScreenPoint
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleused for comparing double values without running into floating point errors. -
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor.CartesianPoint(double X, double Y) Constructor with X and Y -
Method Summary
Modifier and TypeMethodDescriptiondoubledistanceSquaredTo(CartesianPoint other) Calculates the distance between this point and another point without the square root.doubledistanceTo(CartesianPoint other) Calculates the distance between this point and another point.booleanstatic CartesianPointConverts a 2-dimensional array into a cartesian point.inthashCode()booleanIf this Cartesian Point is emptytoArray()Reverse offromList(ArrayList)toScreen()Converts the Cartesian Point to aScreenPointusing the global properties defined byConversion.global()toScreen(Conversion conversion) Converts the Cartesian Point to aScreenPointusing provided propertiestoScreen(ConversionWithOffset conversion) Converts the Cartesian Point to aScreenPointusing the provided properties.toString()Methods inherited from class com.j3d.engine.math.BasePoint
areCollinear
-
Field Details
-
EPSILON
private static final double EPSILONused for comparing double values without running into floating point errors.- See Also:
-
-
Constructor Details
-
CartesianPoint
public CartesianPoint()Default Constructor. Constructs a null CartesianPoint. This is probably a bad idea. -
CartesianPoint
public CartesianPoint(double X, double Y) Constructor with X and Y- Parameters:
X- X-coordianteY- Y-coordinate
-
-
Method Details
-
isNotEmpty
public boolean isNotEmpty()If this Cartesian Point is empty- Returns:
- boolean
-
toScreen
Converts the Cartesian Point to aScreenPointusing the global properties defined byConversion.global()- Returns:
- A ScreenPoint
-
toScreen
Converts the Cartesian Point to aScreenPointusing provided properties- Parameters:
conversion- The conversion properties- Returns:
- A ScreenPoint representing the converted coordinates.
-
toScreen
Converts the Cartesian Point to aScreenPointusing the provided properties.- Parameters:
conversion- The conversion properties- Returns:
- A sScreenPoint representing the converted coordinates
-
fromList
Converts a 2-dimensional array into a cartesian point.Generally used by Jaiva Implementation where points can be represented by [X, Y]
- Parameters:
arr- The array.- Returns:
- The new cartesian point
-
toArray
Reverse offromList(ArrayList)- Returns:
- A 2 Dimensional ArrayList of doubles.
-
toString
-
equals
-
hashCode
public int hashCode() -
distanceTo
Calculates the distance between this point and another point.- Parameters:
other- The other point.- Returns:
- The distance.
-
distanceSquaredTo
Calculates the distance between this point and another point without the square root.- Parameters:
other- The other point.- Returns:
- The distance.
-
friendlyString
-