- java.lang.Object
-
- be.yildizgames.common.geometry.Point3D
-
public final class Point3D extends Object
Simple class to hold 3d coordinates, immutable.- Author:
- Gregory Van den Borre
-
-
Field Summary
Fields Modifier and Type Field Description static Point3DBASE_DIRECTIONInitial direction for all built object, axis is -Z.floatxValue for the x axis.static Point3DX_NEGATIVEstatic Point3DX_POSITIVEfloatyValue for the y axis.static Point3DY_NEGATIVEConstant with Y = -1.static Point3DY_POSITIVEConstant with Y = 1.floatzValue for the z axis.static Point3DZ_NEGATIVEConstant with Z = -1.static Point3DZ_POSITIVEConstant with Z = -1.static Point3DZEROConstant with all values as 0.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Point3Dadd(float x, float y, float z)Add values to the values of this point.Point3Dadd(Point3D point)Add a point to this one.static Point3DaddPoints(Point3D... points)Create a new point from the addition of other points.Point3DaddX(float value)Add a value to the X value of this point.Point3DaddY(float value)Add a value to the Y value of this point.Point3DaddZ(float value)Add a value to the Z value of this point.booleanequals(Object obj)floatgetAngle(Axis axis)Get this point angle.Point3DgetInverse()inthashCode()Point3Dmultiply(float scalar)Multiply this point values by a given value.static Point3Dnormalize(Point3D p)Normalize a point.static Point3DnormalizeAndMultiply(Point3D p, float scalar)Normalize a point and multiply the values.Point3Drounded()static floatsquaredDistance(Point3D p1, Point3D p2)Compute squared distance between 2 points.Point3Dsubtract(Point3D point)Subtract this point values by the other point values.StringtoString()Point3DtoXY()Point3DtoXZ()Point3DtoYZ()static Point3DvalueOf(float xyz)static Point3DvalueOf(float x, float y, float z)static Point3DvalueOfX(float x)static Point3DvalueOfXY(float xy)static Point3DvalueOfXY(float x, float y)static Point3DvalueOfXZ(float xz)static Point3DvalueOfXZ(float x, float z)static Point3DvalueOfY(float y)static Point3DvalueOfYZ(float yz)static Point3DvalueOfYZ(float y, float z)static Point3DvalueOfZ(float z)
-
-
-
Field Detail
-
X_NEGATIVE
public static final Point3D X_NEGATIVE
-
Y_NEGATIVE
public static final Point3D Y_NEGATIVE
Constant with Y = -1.
-
Z_NEGATIVE
public static final Point3D Z_NEGATIVE
Constant with Z = -1.
-
X_POSITIVE
public static final Point3D X_POSITIVE
-
Y_POSITIVE
public static final Point3D Y_POSITIVE
Constant with Y = 1.
-
Z_POSITIVE
public static final Point3D Z_POSITIVE
Constant with Z = -1.
-
ZERO
public static final Point3D ZERO
Constant with all values as 0.
-
BASE_DIRECTION
public static final Point3D BASE_DIRECTION
Initial direction for all built object, axis is -Z.
-
x
public final float x
Value for the x axis.
-
y
public final float y
Value for the y axis.
-
z
public final float z
Value for the z axis.
-
-
Method Detail
-
valueOf
public static Point3D valueOf(float x, float y, float z)
-
valueOf
public static Point3D valueOf(float xyz)
-
valueOfX
public static Point3D valueOfX(float x)
-
valueOfY
public static Point3D valueOfY(float y)
-
valueOfZ
public static Point3D valueOfZ(float z)
-
valueOfXY
public static Point3D valueOfXY(float x, float y)
-
valueOfXY
public static Point3D valueOfXY(float xy)
-
valueOfXZ
public static Point3D valueOfXZ(float x, float z)
-
valueOfXZ
public static Point3D valueOfXZ(float xz)
-
valueOfYZ
public static Point3D valueOfYZ(float y, float z)
-
valueOfYZ
public static Point3D valueOfYZ(float yz)
-
addPoints
public static Point3D addPoints(Point3D... points)
Create a new point from the addition of other points.- Parameters:
points- Point3D to add to compute the result.- Returns:
- A Point3D resulting from the addition of the given points.
-
normalize
public static Point3D normalize(Point3D p)
Normalize a point.- Parameters:
p- Point to normalize.- Returns:
- A new normalized point.
-
normalizeAndMultiply
public static Point3D normalizeAndMultiply(Point3D p, float scalar)
Normalize a point and multiply the values.- Parameters:
p- Point to normalize.scalar- Value to multiply.- Returns:
- A new point normalized and multiplied.
-
squaredDistance
public static float squaredDistance(Point3D p1, Point3D p2)
Compute squared distance between 2 points.- Parameters:
p1- First point.p2- Second point.- Returns:
- The squared distance between the 2 points.
-
add
public Point3D add(float x, float y, float z)
Add values to the values of this point.- Parameters:
x- Value to add to this point X value.y- Value to add to this point Y value.z- Value to add to this point Z value.- Returns:
- A new point with added values.
-
add
public Point3D add(Point3D point)
Add a point to this one.- Parameters:
point- Point to add.- Returns:
- A new point with added values.
-
addX
public Point3D addX(float value)
Add a value to the X value of this point.- Parameters:
value- Value to add to this point X value.- Returns:
- A new point with added value.
-
addY
public Point3D addY(float value)
Add a value to the Y value of this point.- Parameters:
value- value to add to this point Y value.- Returns:
- A new point with added value.
-
addZ
public Point3D addZ(float value)
Add a value to the Z value of this point.- Parameters:
value- value to add to this point Z value.- Returns:
- A new point with added value.
-
getAngle
public float getAngle(Axis axis)
Get this point angle.- Parameters:
axis- Axis to use.- Returns:
- The point angle.
-
getInverse
public Point3D getInverse()
- Returns:
- This point with all values inverted(5,10,-8 will be -5,-10,8).
-
multiply
public Point3D multiply(float scalar)
Multiply this point values by a given value.- Parameters:
scalar- Value to multiply.- Returns:
- A new point with the multiplied values.
-
rounded
public Point3D rounded()
- Returns:
- This point with rounded values.
-
subtract
public Point3D subtract(Point3D point)
Subtract this point values by the other point values.- Parameters:
point- Other point to use.- Returns:
- A new Point3D with the computed values.
-
toXZ
public Point3D toXZ()
- Returns:
- A copy of this point with 0 as Y coordinate.
-
toXY
public Point3D toXY()
-
toYZ
public Point3D toYZ()
-
-