Package sim.util
Class MutableDouble2D
java.lang.Object
sim.util.NumberND
sim.util.MutableNumberND
sim.util.MutableDouble2D
- All Implemented Interfaces:
Serializable,Cloneable
MutableDouble2D is more or less the same class as java.awt.geom.Point2D.Double, except that it is hash-equivalent to Double2D.
Just as with MutableInt2D: you use MutableDouble2D as a STORED hash key at your peril: it has the same misfeature as java.awt.geom.Point2D.Double, and you should read the warning in Double2D. However, you can look up Double2D-keyed objects in a hash table by passing in a MutableDouble2D instead.
- See Also:
-
Field Summary
FieldsFields inherited from class sim.util.NumberND
TYPE_DOUBLE_2D, TYPE_DOUBLE_3D, TYPE_INT_2D, TYPE_INT_3D, TYPE_MUTABLE_DOUBLE_2D, TYPE_MUTABLE_DOUBLE_3D, TYPE_MUTABLE_INT_2D, TYPE_MUTABLE_INT_3D -
Constructor Summary
ConstructorsConstructorDescriptionMutableDouble2D(double[] vals) MutableDouble2D(double x, double y) Only included for completeness' sakes, in case a new Point2D subclass is created in the future. -
Method Summary
Modifier and TypeMethodDescriptionfinal MutableDouble2Dadd(Double2D other1, MutableDouble2D other2) Sets me to the sum of other1 and other2, returning me.final MutableDouble2Dadd(MutableDouble2D other1, Double2D other2) Sets me to the sum of other1 and other2, returning me.final MutableDouble2Dadd(MutableDouble2D other1, MutableDouble2D other2) Sets me to the sum of other1 and other2, returning me.final MutableDouble2DaddIn(double x, double y) Adds the x and y values into my x and y values, returning me.final MutableDouble2DAdds other into me, returning me.final MutableDouble2DaddIn(MutableDouble2D other) Adds other into me, returning me.final doubleangle()Returns the length of the vector between -Pi and Pi.clone()doubledistance(double x, double y) Returns the distance FROM this MutableDouble2D TO the specified pointdoubleReturns the distance FROM this MutableDouble2D TO the specified point.doubleReturns the distance FROM this MutableDouble2D TO the specified point.doubleReturns the distance FROM this MutableDouble2D TO the specified point.doubleReturns the distance FROM this MutableDouble2D TO the specified point.doubleReturns the distance FROM this MutableDouble2D TO the specified point.doubledistanceSq(double x, double y) Returns the distance FROM this MutableDouble2D TO the specified pointdoubleReturns the distance FROM this Point2D TO the specified pointdoubleReturns the distance FROM this MutableDouble2D TO the specified point.doubledistanceSq(Int2D p) Returns the distance FROM this MutableDouble2D TO the specified point.doubleReturns the distance FROM this MutableDouble2D TO the specified point.doubleReturns the distance FROM this MutableDouble2D TO the specified point.final doubledot(MutableDouble2D other) Returns the dot product of myself against other, that is me DOT other.final MutableDouble2Ddup()Equivalent to (new MutableDouble2D(d)), but (d.dup()) shorter of course, but perhaps not quite as fast.final booleanReturns whether this NumberND is equivalent to some other NumberND.doublegetVal(int val) Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)final doublegetX()final doublegetY()final inthashCode()Provides a hashcode for this NumberND.final doublelength()Returns the length of the vector.final doublelengthSq()Returns the square of the length of the MutableDouble2D.doublemanhattanDistance(double x, double y) Returns the manhtattan distance FROM this MuableDouble2D TO the specified pointdoubleReturns the manhtattan distance FROM this MuableDouble2D TO the specified pointdoubleReturns the manhtattan distance FROM this MuableDouble2D TO the specified pointdoubleReturns the manhtattan distance FROM this MuableDouble2D TO the specified pointdoubleReturns the manhtattan distance FROM this MuableDouble2D TO the specified pointdoubleReturns the manhtattan distance FROM this MuableDouble2D TO the specified pointfinal MutableDouble2DMultiplies other by val, setting me to the result and returning me.final MutableDouble2Dmultiply(MutableDouble2D other, double val) Multiplies other by val, setting me to the result and returning me.final MutableDouble2DmultiplyIn(double val) Extends my length so that it is multiplied by val, and returns me.booleanmutable()Returns whether this NumberND is mutable.final MutableDouble2Dnegate()Negates the MutableDouble2D's values and returns it.final MutableDouble2DintReturns the number of dimensions of this NumberND (normally 2 or 3)doubleperpDot(MutableDouble2D other) 2D version of the cross product: returns the dot product of me rotated 90 degrees dotted against the other vector.final MutableDouble2Dresize(double val) Sets my length, which should be >= 0.final MutableDouble2Drotate(double theta) Rotates me by theta radians, returning me.final MutableDouble2DsetLength(double val) Deprecated.use resize instead [renaming]final voidsetTo(double bx, double by) final voidfinal voidfinal voidfinal voidfinal MutableDouble2DSets the values to the negation of the values in the provided MutableDouble2DvoidsetVal(int val, double to) final voidsetX(double val) final voidsetY(double val) final MutableDouble2Dsubtract(Double2D other1, MutableDouble2D other2) Subtracts other2 from other1, setting me to the result and returning me.final MutableDouble2Dsubtract(MutableDouble2D other1, Double2D other2) Subtracts other2 from other1, setting me to the result and returning me.final MutableDouble2Dsubtract(MutableDouble2D other1, MutableDouble2D other2) Subtracts other2 from other1, setting me to the result and returning me.final MutableDouble2DsubtractIn(Double2D other) Sets me to me minus other, returning me.final MutableDouble2DsubtractIn(MutableDouble2D other) Sets me to me minus other, returning me.double[]byte[]toBytes()Flattens out the NumberND to an array of bytes, including the NumberND subtype.Returns this NumberND in mathematical coordinates as a formatted String.toString()Returns this NumberND as a nicely formatted String.final MutableDouble2Dzero()Sets the values to 0 and returns it.Methods inherited from class sim.util.MutableNumberND
isMutableMethods inherited from class sim.util.NumberND
doubleFromBytes, doubleToBytes, fromBytes, getDistanceSq, getOffsets, intFromBytes, intToBytes, main
-
Field Details
-
x
public double x -
y
public double y
-
-
Constructor Details
-
MutableDouble2D
public MutableDouble2D() -
MutableDouble2D
-
MutableDouble2D
-
MutableDouble2D
-
MutableDouble2D
-
MutableDouble2D
-
MutableDouble2D
-
MutableDouble2D
-
MutableDouble2D
Only included for completeness' sakes, in case a new Point2D subclass is created in the future. -
MutableDouble2D
public MutableDouble2D(double x, double y) -
MutableDouble2D
public MutableDouble2D(double[] vals)
-
-
Method Details
-
mutable
public boolean mutable()Description copied from class:NumberNDReturns whether this NumberND is mutable. This is equivalent to asking (instanceof val MutableNumberND) -
numDimensions
public int numDimensions()Description copied from class:NumberNDReturns the number of dimensions of this NumberND (normally 2 or 3)- Specified by:
numDimensionsin classNumberND
-
getVal
public double getVal(int val) Description copied from class:NumberNDReturns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2) -
setVal
public void setVal(int val, double to) - Specified by:
setValin classMutableNumberND
-
toBytes
public byte[] toBytes()Description copied from class:NumberNDFlattens out the NumberND to an array of bytes, including the NumberND subtype. -
getX
public final double getX() -
getY
public final double getY() -
setX
public final void setX(double val) -
setY
public final void setY(double val) -
setTo
public final void setTo(double bx, double by) -
setTo
-
setTo
-
setTo
-
setTo
-
toString
Description copied from class:NumberNDReturns this NumberND as a nicely formatted String. -
toCoordinates
Description copied from class:NumberNDReturns this NumberND in mathematical coordinates as a formatted String.- Specified by:
toCoordinatesin classNumberND
-
toPoint2D
-
toArrayAsDouble
public double[] toArrayAsDouble()- Specified by:
toArrayAsDoublein classNumberND
-
clone
-
hashCode
public final int hashCode()Description copied from class:NumberNDProvides a hashcode for this NumberND. -
equals
Description copied from class:NumberNDReturns whether this NumberND is equivalent to some other NumberND. -
distance
public double distance(double x, double y) Returns the distance FROM this MutableDouble2D TO the specified point -
distance
Returns the distance FROM this MutableDouble2D TO the specified point. -
distance
Returns the distance FROM this MutableDouble2D TO the specified point. -
distance
Returns the distance FROM this MutableDouble2D TO the specified point. -
distance
Returns the distance FROM this MutableDouble2D TO the specified point. -
distance
Returns the distance FROM this MutableDouble2D TO the specified point. -
distanceSq
public double distanceSq(double x, double y) Returns the distance FROM this MutableDouble2D TO the specified point -
distanceSq
Returns the distance FROM this MutableDouble2D TO the specified point. -
distanceSq
Returns the distance FROM this MutableDouble2D TO the specified point. -
distanceSq
Returns the distance FROM this MutableDouble2D TO the specified point. -
distanceSq
Returns the distance FROM this MutableDouble2D TO the specified point. -
distanceSq
Returns the distance FROM this Point2D TO the specified point -
manhattanDistance
public double manhattanDistance(double x, double y) Returns the manhtattan distance FROM this MuableDouble2D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point -
addIn
Adds other into me, returning me. -
addIn
Adds other into me, returning me. -
addIn
Adds the x and y values into my x and y values, returning me. -
add
Sets me to the sum of other1 and other2, returning me. -
add
Sets me to the sum of other1 and other2, returning me. -
add
Sets me to the sum of other1 and other2, returning me. -
dup
Equivalent to (new MutableDouble2D(d)), but (d.dup()) shorter of course, but perhaps not quite as fast. -
subtractIn
Sets me to me minus other, returning me. -
subtractIn
Sets me to me minus other, returning me. -
subtract
Subtracts other2 from other1, setting me to the result and returning me. -
subtract
Subtracts other2 from other1, setting me to the result and returning me. -
subtract
Subtracts other2 from other1, setting me to the result and returning me. -
length
public final double length()Returns the length of the vector. -
lengthSq
public final double lengthSq()Returns the square of the length of the MutableDouble2D. -
angle
public final double angle()Returns the length of the vector between -Pi and Pi. -
multiplyIn
Extends my length so that it is multiplied by val, and returns me. -
multiply
Multiplies other by val, setting me to the result and returning me. -
multiply
Multiplies other by val, setting me to the result and returning me. -
normalize
-
setLength
Deprecated.use resize instead [renaming]Sets my length, which should be >= 0. -
resize
Sets my length, which should be >= 0. -
rotate
Rotates me by theta radians, returning me. -
dot
Returns the dot product of myself against other, that is me DOT other. -
perpDot
2D version of the cross product: returns the dot product of me rotated 90 degrees dotted against the other vector. Does not modify either vector. -
zero
Sets the values to 0 and returns it. -
setToMinus
Sets the values to the negation of the values in the provided MutableDouble2D -
negate
Negates the MutableDouble2D's values and returns it.
-