Package org.jzy3d.maths
Class Coord3d
- java.lang.Object
-
- org.jzy3d.maths.Coord3d
-
- All Implemented Interfaces:
Serializable
public class Coord3d extends Object implements Serializable
ACoord3dstores a 3 dimensional coordinate for cartesian or polar mode, and provide few operators. Operators allow adding, substracting, multiplying and divising coordinate values, as well as computing the distance between two points, and converting polar and cartesian coordinates.- Author:
- Martin Pernollet
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Coord3dIDENTITYThe origin is a Coord3d having value 1 for each dimension.static Coord3dINVALIDAn invalid Coord2d has value NaN for each dimension.static Coord3dORIGINThe origin is a Coord3d having value 0 for each dimension.floatxfloatyfloatz
-
Constructor Summary
Constructors Constructor Description Coord3d()Create a 3d coordinate with value 0 for each dimension.Coord3d(double[] c)Coord3d(double xi, double yi, double zi)Create a 3d coordinate.Coord3d(float[] c)Coord3d(float xi, float yi, float zi)Create a 3d coordinate.Coord3d(Coord2d c)Coord3d(Coord2d c, double zi)Coord3d(Coord2d c, float zi)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Coord3dadd(float value)Add a value to all components of the current Coord and return the result in a new Coord3d.Coord3dadd(float x, float y, float z)static voidadd(List<Coord3d> coords, float x, float y, float z)static voidadd(List<Coord3d> coords, Coord3d add)Coord3dadd(Coord3d c2)Add a Coord3d to the current one and return the result in a new Coord3d.Coord3daddSelf(float value)Coord3daddSelf(float x, float y, float z)Coord3daddSelf(Coord3d c2)static Coord3d[]array(Set<Coord3d> coords)Coord3dcartesian()Converts the current Coord3d into cartesian coordinates and return the result in a new Coord3d.Coord3dcartesianSelf()Coord3dclone()Return a duplicate of this 3d coordinate.static List<Coord3d>clone(List<Coord3d> coords)Coord3dcross(Coord3d v)doubledistance(Coord3d c)Compute the distance between two coordinates.doubledistanceSq(Coord3d c)Compute the square distance between two coordinates.Coord3ddiv(float value)Divise all components of the current Coord by the same value and return the result in a new Coord3d.static voiddiv(List<Coord3d> coords, float x, float y, float z)static voiddiv(List<Coord3d> coords, Coord3d div)Coord3ddiv(Coord3d c2)Divise a Coord3d to the current one and return the result in a new Coord3d.voiddivSelf(double value)voiddivSelf(float value)voiddivSelf(Coord3d c2)floatdot(Coord3d v)booleanequals(Object obj)static Coord3dgetCoordAt(double[] array, int i)static Coord3dgetCoordAt(float[] array, int i)static List<Coord3d>getCoords(double[] array)static List<Coord3d>getCoords(float[] array)Coord3dgetNormalizedTo(float len)Coord2dgetXY()Return the x and y component as a 2d coordinate.static RangegetZRange(List<Coord3d> coords)inthashCode()Coord3dinterpolateTo(Coord3d v, float f)static List<Coord3d>list(int size)static List<Coord3d>list(Coord3d... coords)floatmagSquared()static Coord3dmax(List<Coord3d> coords)Compute the component-wise minimum values of a set of coordinates.static Coord3dmin(List<Coord3d> coords)Compute the component-wise minimum values of a set of coordinates.static Pair<Coord3d,Coord3d>minMax(List<Coord3d> coords)Compute the component-wise minimum and maximum values of a set of coordinates.Coord3dmul(float value)Multiply all components of the current Coord and return the result in a new Coord3d.Coord3dmul(float x, float y, float z)static voidmul(List<Coord3d> coords, float x, float y, float z)static voidmul(List<Coord3d> coords, Coord3d multiplier)Coord3dmul(Coord3d c2)Multiply a Coord3d to the current one and return the result in a new Coord3d.voidmulSelf(float value)voidmulSelf(float x, float y, float z)voidmulSelf(Coord3d c2)Coord3dnegative()Coord3dnormalizeTo(float len)Coord3dpolar()Converts the current Coord3d into polar coordinates and return the result in a new Coord3d.Coord3dpolarSelf()Coord3drotate(float angleDeg, Coord3d axis)Applies a rotation represented by the AxisAngle notation using the Rodrigues' rotation formula.Coord3dset(float x, float y, float z)Coord3dset(Coord3d c2)Coord3dsub(float value)Substract a value to all components of the current Coord and return the result in a new Coord3d.Coord3dsub(float x2, float y2, float z2)static voidsub(List<Coord3d> coords, float x, float y, float z)static voidsub(List<Coord3d> coords, Coord3d add)Coord3dsub(Coord3d c2)Substract a Coord3d to the current one and return the result in a new Coord3d.Coord3dsubSelf(float value)Coord3dsubSelf(Coord3d c2)float[]toArray()Return an array representation of this coordinate.voidtoArray(float[] array, int offset)StringtoString()Return a string representation of this coordinate.
-
-
-
Field Detail
-
x
public float x
-
y
public float y
-
z
public float z
-
ORIGIN
public static final Coord3d ORIGIN
The origin is a Coord3d having value 0 for each dimension.
-
IDENTITY
public static final Coord3d IDENTITY
The origin is a Coord3d having value 1 for each dimension.
-
INVALID
public static final Coord3d INVALID
An invalid Coord2d has value NaN for each dimension.
-
-
Constructor Detail
-
Coord3d
public Coord3d()
Create a 3d coordinate with value 0 for each dimension.
-
Coord3d
public Coord3d(float xi, float yi, float zi)Create a 3d coordinate. When using polar mode, x represents azimuth, y represents elevation, and z represents range.
-
Coord3d
public Coord3d(Coord2d c, float zi)
-
Coord3d
public Coord3d(Coord2d c, double zi)
-
Coord3d
public Coord3d(Coord2d c)
-
Coord3d
public Coord3d(float[] c)
-
Coord3d
public Coord3d(double[] c)
-
Coord3d
public Coord3d(double xi, double yi, double zi)Create a 3d coordinate. When using polar mode, x is azimuth, y is elevation, and z is range.
-
-
Method Detail
-
set
public Coord3d set(float x, float y, float z)
-
clone
public Coord3d clone()
Return a duplicate of this 3d coordinate.
-
getXY
public Coord2d getXY()
Return the x and y component as a 2d coordinate.
-
add
public Coord3d add(Coord3d c2)
Add a Coord3d to the current one and return the result in a new Coord3d.- Parameters:
c2-- Returns:
- the result Coord3d
-
add
public Coord3d add(float x, float y, float z)
-
addSelf
public Coord3d addSelf(float x, float y, float z)
-
add
public Coord3d add(float value)
Add a value to all components of the current Coord and return the result in a new Coord3d.- Parameters:
value-- Returns:
- the result Coord3d
-
addSelf
public Coord3d addSelf(float value)
-
sub
public Coord3d sub(Coord3d c2)
Substract a Coord3d to the current one and return the result in a new Coord3d.- Parameters:
c2-- Returns:
- the result Coord3d
-
sub
public Coord3d sub(float x2, float y2, float z2)
-
sub
public Coord3d sub(float value)
Substract a value to all components of the current Coord and return the result in a new Coord3d.- Parameters:
value-- Returns:
- the result Coord3d
-
subSelf
public Coord3d subSelf(float value)
-
mul
public Coord3d mul(Coord3d c2)
Multiply a Coord3d to the current one and return the result in a new Coord3d.- Parameters:
c2-- Returns:
- the result Coord3d
-
mul
public Coord3d mul(float x, float y, float z)
-
mul
public Coord3d mul(float value)
Multiply all components of the current Coord and return the result in a new Coord3d.- Parameters:
value-- Returns:
- the result Coord3d
-
mulSelf
public void mulSelf(Coord3d c2)
-
mulSelf
public void mulSelf(float x, float y, float z)
-
mulSelf
public void mulSelf(float value)
-
div
public Coord3d div(Coord3d c2)
Divise a Coord3d to the current one and return the result in a new Coord3d.- Parameters:
c2-- Returns:
- the result Coord3d
-
divSelf
public void divSelf(Coord3d c2)
-
divSelf
public void divSelf(float value)
-
divSelf
public void divSelf(double value)
-
div
public Coord3d div(float value)
Divise all components of the current Coord by the same value and return the result in a new Coord3d.- Parameters:
value-- Returns:
- the result Coord3d
-
negative
public Coord3d negative()
-
cartesian
public Coord3d cartesian()
Converts the current Coord3d into cartesian coordinates and return the result in a new Coord3d. Assume that- X represent azimuth
- Y represent elevation
- Z represent distance
- Returns:
- the result Coord3d
-
cartesianSelf
public Coord3d cartesianSelf()
-
polar
public Coord3d polar()
Converts the current Coord3d into polar coordinates and return the result in a new Coord3d.- Returns:
- the result Coord3d
-
polarSelf
public Coord3d polarSelf()
-
distance
public double distance(Coord3d c)
Compute the distance between two coordinates.
-
distanceSq
public double distanceSq(Coord3d c)
Compute the square distance between two coordinates.
-
magSquared
public float magSquared()
-
getNormalizedTo
public Coord3d getNormalizedTo(float len)
-
normalizeTo
public Coord3d normalizeTo(float len)
-
dot
public final float dot(Coord3d v)
-
rotate
public final Coord3d rotate(float angleDeg, Coord3d axis)
Applies a rotation represented by the AxisAngle notation using the Rodrigues' rotation formula. math implemented using http://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula- Parameters:
angleDeg- angle of rotation about the given axis [deg]axis- unit vector describing an axis of rotation- Returns:
- rotated copy of the original vector
-
toString
public String toString()
Return a string representation of this coordinate.
-
toArray
public float[] toArray()
Return an array representation of this coordinate.
-
toArray
public void toArray(float[] array, int offset)
-
min
public static Coord3d min(List<Coord3d> coords)
Compute the component-wise minimum values of a set of coordinates.- Parameters:
coords-- Returns:
- minimum value on each dimension
-
max
public static Coord3d max(List<Coord3d> coords)
Compute the component-wise minimum values of a set of coordinates.- Parameters:
coords-- Returns:
- maximum value on each dimension
-
minMax
public static Pair<Coord3d,Coord3d> minMax(List<Coord3d> coords)
Compute the component-wise minimum and maximum values of a set of coordinates.- Parameters:
coords-- Returns:
- maximum value on each dimension
-
getCoordAt
public static Coord3d getCoordAt(double[] array, int i)
-
getCoordAt
public static Coord3d getCoordAt(float[] array, int i)
-
-