Package org.jzy3d.maths
Class Coord2d
java.lang.Object
org.jzy3d.maths.Coord2d
- All Implemented Interfaces:
Serializable
A
Coord2d
stores a 2 dimensional coordinate for cartesian (x,y) or polar (a,r) mode, and
provide operators allowing to add, substract, multiply and divises coordinate values, as well as
computing the distance between two points, and converting polar and cartesian coordinates.- Author:
- Martin Pernollet
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(float value) Add a value to all components of the current Coord and return the result in a new Coord2d.add
(float x, float y) Add a Coord2d to the current one and return the result in a new Coord2d.void
addSelf
(float x, float y) void
void
addSelfX
(float x) void
addSelfY
(float y) static Coord2d
addWeighted
(Coord2d a, Coord2d b, float weigthA, float weightB) Converts the current Coord3d into cartesian coordinates and return the result in a new Coord3d.clone()
Return a duplicate of this 3d coordinate.double
Compute the distance between two coordinates.double
div
(float value) Divise all components of the current Coord by the same value and return the result in a new Coord3d.div
(float x, float y) Divise a Coord2d to the current one and return the result in a new Coord2d.void
divSelf
(float value) boolean
Return a real polar value, with an angle in the range [0;2*PI] https://en.wikipedia.org/wiki/Polar_coordinate_systemfloat
getX()
float
getY()
int
hashCode()
static Coord2d
interpolate
(Coord2d a, Coord2d b, float weigthA) interpolation
(Coord2d c, float ratio) Returns an interpolated point between the current and given point, according to an input ratio in [0;1] that indicates how near to the current point the new point will stand.mul
(float value) Multiply all components of the current Coord and return the result in a new Coord3d.mul
(float x, float y) Multiply a Coord2d to the current one and return the result in a new Coord2d.mulSelf
(float x, float y) polar()
void
set
(float x, float y) void
sub
(float value) Substract a value to all components of the current Coord and return the result in a new Coord2d.sub
(float x, float y) Substract a Coord2d to the current one and return the result in a new Coord2d.to3d()
float[]
toArray()
Return an array representation of this coordinate.toString()
Return a string representation of this coordinate.
-
Field Details
-
ORIGIN
The origin is a Coord2d having value 0 for each dimension. -
IDENTITY
-
INVALID
An invalid Coord2d has value NaN for each dimension. -
x
public float x -
y
public float y
-
-
Constructor Details
-
Coord2d
public Coord2d()Creates a 2d coordinate with the value 0 for each dimension. -
Coord2d
public Coord2d(float xi, float yi) Creates a 2d coordinate. When using polar mode, x represents angle, and y represents distance. -
Coord2d
public Coord2d(double xi, double yi) Creates a 2d coordinate. When using polar mode, x represents angle, and y represents distance. -
Coord2d
public Coord2d(double xi)
-
-
Method Details
-
clone
Return a duplicate of this 3d coordinate. -
set
-
set
public void set(float x, float y) -
add
Add a Coord2d to the current one and return the result in a new Coord2d.- Parameters:
c2
-- Returns:
- the result Coord2d
-
addSelf
-
addSelf
public void addSelf(float x, float y) -
addSelfX
public void addSelfX(float x) -
addSelfY
public void addSelfY(float y) -
add
Add a value to all components of the current Coord and return the result in a new Coord2d.- Parameters:
value
-- Returns:
- the result Coord2d
-
add
-
sub
Substract a Coord2d to the current one and return the result in a new Coord2d.- Parameters:
c2
-- Returns:
- the result Coord2d
-
sub
Substract a value to all components of the current Coord and return the result in a new Coord2d.- Parameters:
value
-- Returns:
- the result Coord2d
-
sub
-
mul
Multiply a Coord2d to the current one and return the result in a new Coord2d.- Parameters:
c2
-- Returns:
- the result Coord2d
-
mul
-
mul
Multiply all components of the current Coord and return the result in a new Coord3d.- Parameters:
value
-- Returns:
- the result Coord3d
-
mulSelf
-
mulSelf
-
div
Divise a Coord2d to the current one and return the result in a new Coord2d.- Parameters:
c2
-- Returns:
- the result Coord2d
-
div
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
-
div
-
divSelf
public void divSelf(float value) -
cartesian
Converts the current Coord3d into cartesian coordinates and return the result in a new Coord3d.- Returns:
- the result Coord3d
-
polar
-
fullPolar
Return a real polar value, with an angle in the range [0;2*PI] https://en.wikipedia.org/wiki/Polar_coordinate_system -
distance
Compute the distance between two coordinates. -
distanceSq
-
interpolation
Returns an interpolated point between the current and given point, according to an input ratio in [0;1] that indicates how near to the current point the new point will stand. A value of 1 will return a copy of the current point. -
mean
-
addWeighted
-
interpolate
-
toString
Return a string representation of this coordinate. -
toArray
public float[] toArray()Return an array representation of this coordinate. -
getX
public float getX() -
getY
public float getY() -
hashCode
public int hashCode() -
equals
-
to3d
-