Package squidpony.squidmath
Class CoordDouble
java.lang.Object
squidpony.squidmath.CoordDouble
- All Implemented Interfaces:
Serializable
public class CoordDouble extends Object implements Serializable
Coord using double values for x and y instead of int. Not pooled.
When possible and you are using libGDX, use the
Created by Tommy Ettinger on 8/12/2015.
com.badlogic.gdx.math.Vector2
class in preference to this
one if you are OK with using floats instead of doubles.
Created by Tommy Ettinger on 8/12/2015.
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CoordDouble()
CoordDouble(double x, double y)
CoordDouble(Coord other)
CoordDouble(CoordDouble other)
-
Method Summary
Modifier and Type Method Description CoordDouble
add(double x, double y)
CoordDouble
add(CoordDouble other)
CoordDouble
copy()
Constructs an identical copy to this CoordDouble, making a new object that may be mutated independently.double
cross(CoordDouble other)
Gets the cross product of this CoordDouble andother
.double
distance(double x2, double y2)
double
distance(CoordDouble co)
double
distanceSq(double x2, double y2)
double
distanceSq(CoordDouble co)
CoordDouble
divide(double x, double y)
Divides the x component of this CoordDouble byx
and the y component byy
.CoordDouble
divide(CoordDouble other)
Divides the x component of this CoordDouble byother.x
and the y component byother.y
.double
dot(CoordDouble other)
Gets the dot product of this CoordDouble andother
.boolean
equals(Object o)
static CoordDouble
get(double x, double y)
double
getX()
double
getY()
int
hashCode()
double
length()
Distance from the origin to this CoordDouble.double
lengthSq()
Distance from the origin to this CoordDouble, squared.CoordDouble
multiply(double x, double y)
CoordDouble
multiply(CoordDouble other)
CoordDouble
set(double x, double y)
CoordDouble
set(CoordDouble co)
void
setX(double x)
void
setY(double y)
CoordDouble
subtract(double x, double y)
CoordDouble
subtract(CoordDouble other)
String
toString()
-
Field Details
-
Constructor Details
-
Method Details
-
get
-
copy
Constructs an identical copy to this CoordDouble, making a new object that may be mutated independently.- Returns:
- a copy of this CoordDouble
-
add
-
add
-
subtract
-
subtract
-
multiply
-
multiply
-
divide
Divides the x component of this CoordDouble byx
and the y component byy
. Be careful about when either of the parameters can be 0.0, since that can put NaN or infinite components in this.- Parameters:
x
- divisor for xy
- divisor for y
-
divide
Divides the x component of this CoordDouble byother.x
and the y component byother.y
. Be careful about when either of other's components can be 0.0, since that can put NaN or infinite components in this.- Parameters:
other
- a non-null CoordDouble to get divisors from
-
dot
Gets the dot product of this CoordDouble andother
.- Parameters:
other
- another CoordDouble; must not be null.- Returns:
- the dot product of this and
other
.
-
cross
Gets the cross product of this CoordDouble andother
.- Parameters:
other
- another CoordDouble; must not be null.- Returns:
- the cross product of this and
other
.
-
set
-
set
-
length
Distance from the origin to this CoordDouble.- Returns:
- the distance from the origin to this CoordDouble.
-
lengthSq
Distance from the origin to this CoordDouble, squared.- Returns:
- the distance from the origin to this CoordDouble, squared.
-
distance
-
distance
-
distanceSq
-
distanceSq
-
getX
-
setX
-
getY
-
setY
-
toString
-
hashCode
-
equals
-