Package sim.util
Class MutableDouble3D
java.lang.Object
sim.util.NumberND
sim.util.MutableNumberND
sim.util.MutableDouble3D
- All Implemented Interfaces:
Serializable,Cloneable
MutableDouble3D is more or less the same class as javax.vecmath.Point3d, except that it is hash-equivalent to Double3D.
Just as with MutableInt3D: you use MutableDouble3D as a STORED hash key at your peril: it has the same misfeature as javax.vecmath.Point3d, and you should read the warning in Double3D. However, you can look up Double3D-keyed objects in a hash table by passing in a MutableDouble3D 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
ConstructorsConstructorDescriptionMutableDouble3D(double x, double y, double z) Explicitly assumes the z value is set to 0MutableDouble3D(Double2D p, double z) Explicitly assumes the z value is set to 0MutableDouble3D(Int2D p, double z) Explicitly assumes the z value is set to 0MutableDouble3D(MutableDouble2D p, double z) Explicitly assumes the z value is set to 0MutableDouble3D(MutableInt2D p, double z) -
Method Summary
Modifier and TypeMethodDescriptionfinal MutableDouble3Dadd(MutableDouble3D other1, MutableDouble3D other2) Sets me to the sum of other1 and other2, returning me.final MutableDouble3DaddIn(double x, double y, double z) Adds the x, y, and z values into my x, y, and z values, returning me.final MutableDouble3DAdds other into me, returning me.final MutableDouble3DaddIn(MutableDouble3D other) Adds other into me, returning me.clone()doubledistance(double x, double y, double z) Returns the distance FROM this MutableDouble3D TO the specified pointdoubleReturns the distance FROM this MutableDouble3D TO the specified point.doubleReturns the distance FROM this MutableDouble3D TO the specified point.doubleReturns the distance FROM this MutableDouble3D TO the specified point.doubleReturns the distance FROM this MutableDouble3D TO the specified point.doubledistanceSq(double x, double y, double z) Returns the squared distance FROM this MutableDouble3D TO the specified pointdoubleReturns the squared distance FROM this MutableDouble3D TO the specified point.doubledistanceSq(Int3D p) Returns the squared distance FROM this MutableDouble3D TO the specified point.doubleReturns the squared distance FROM this MutableDouble3D TO the specified point.doubleReturns the squared distance FROM this MutableDouble3D TO the specified point.final doubledot(MutableDouble3D other) Returns the dot product of myself against other, that is me DOT other.final MutableDouble3Ddup()Equivalent to (new MutableDouble3D(d)), but (d.dup()) shorter of course, but perhaps not quite as fast.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 doublegetZ()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 MutableDouble3D.doublemanhattanDistance(double x, double y, double z) Returns the manhtattan distance FROM this MutableDouble3D TO the specified pointdoubleReturns the manhtattan distance FROM this MutableDouble3D TO the specified pointdoubleReturns the manhtattan distance FROM this MutableDouble3D TO the specified pointdoubleReturns the manhtattan distance FROM this MutableDouble3D TO the specified pointdoubleReturns the manhtattan distance FROM this MutableDouble3D TO the specified pointfinal MutableDouble3Dmultiply(MutableDouble3D other, double val) Multiplies other by val, setting me to the result and returning me.final MutableDouble3DmultiplyIn(double val) Extends my length so that it is multiplied by val, and returns me.booleanmutable()Returns whether this NumberND is mutable.final MutableDouble3Dnegate()Negates the MutableDouble3D's valuesfinal MutableDouble3DNormalizes me (sets my length to 1.0), returning me.intReturns the number of dimensions of this NumberND (normally 2 or 3)final MutableDouble3Dresize(double val) Sets my length, which should be >= 0.final MutableDouble3DsetLength(double val) Deprecated.use resize instead [renaming]voidsetTo(double x, double y, double z) voidvoidvoidvoidfinal MutableDouble3DSets the values to the negation of the values in the provided MutableDouble3DvoidsetVal(int val, double to) final voidsetX(double val) final voidsetY(double val) final voidsetZ(double val) final MutableDouble3Dsubtract(MutableDouble3D other1, MutableDouble3D other2) Subtracts other2 from other1, setting me to the result and returning me.final MutableDouble3DsubtractIn(Double3D other) Sets me to me minus other, returning me.final MutableDouble3DsubtractIn(MutableDouble3D 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 MutableDouble3Dzero()Sets the values to 0.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 -
z
public double z
-
-
Constructor Details
-
MutableDouble3D
public MutableDouble3D() -
MutableDouble3D
Explicitly assumes the z value is set to 0 -
MutableDouble3D
-
MutableDouble3D
-
MutableDouble3D
Explicitly assumes the z value is set to 0 -
MutableDouble3D
-
MutableDouble3D
-
MutableDouble3D
Explicitly assumes the z value is set to 0 -
MutableDouble3D
-
MutableDouble3D
-
MutableDouble3D
Explicitly assumes the z value is set to 0 -
MutableDouble3D
-
MutableDouble3D
-
MutableDouble3D
public MutableDouble3D(double x, double y, double z)
-
-
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() -
getZ
public final double getZ() -
setX
public final void setX(double val) -
setY
public final void setY(double val) -
setZ
public final void setZ(double val) -
setTo
public void setTo(double x, double y, double z) -
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
-
toArrayAsDouble
public double[] toArrayAsDouble()- Specified by:
toArrayAsDoublein classNumberND
-
clone
-
hashCode
public 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, double z) Returns the distance FROM this MutableDouble3D TO the specified point -
distance
Returns the distance FROM this MutableDouble3D TO the specified point. -
distance
Returns the distance FROM this MutableDouble3D TO the specified point. -
distance
Returns the distance FROM this MutableDouble3D TO the specified point. -
distance
Returns the distance FROM this MutableDouble3D TO the specified point. -
distanceSq
public double distanceSq(double x, double y, double z) Returns the squared distance FROM this MutableDouble3D TO the specified point -
distanceSq
Returns the squared distance FROM this MutableDouble3D TO the specified point. -
distanceSq
Returns the squared distance FROM this MutableDouble3D TO the specified point. -
distanceSq
Returns the squared distance FROM this MutableDouble3D TO the specified point. -
distanceSq
Returns the squared distance FROM this MutableDouble3D TO the specified point. -
manhattanDistance
public double manhattanDistance(double x, double y, double z) Returns the manhtattan distance FROM this MutableDouble3D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MutableDouble3D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MutableDouble3D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MutableDouble3D TO the specified point -
manhattanDistance
Returns the manhtattan distance FROM this MutableDouble3D TO the specified point -
addIn
Adds other into me, returning me. -
addIn
Adds other into me, returning me. -
add
Sets me to the sum of other1 and other2, returning me. -
addIn
Adds the x, y, and z values into my x, y, and z values, returning me. -
dup
Equivalent to (new MutableDouble3D(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. -
length
public final double length()Returns the length of the vector. -
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. -
normalize
Normalizes me (sets my length to 1.0), returning me. Throws an error if my previous length was of length 0. -
setLength
Deprecated.use resize instead [renaming]Sets my length, which should be >= 0. -
resize
Sets my length, which should be >= 0. -
dot
Returns the dot product of myself against other, that is me DOT other. -
zero
Sets the values to 0. -
setToMinus
Sets the values to the negation of the values in the provided MutableDouble3D -
negate
Negates the MutableDouble3D's values -
lengthSq
public final double lengthSq()Returns the square of the length of the MutableDouble3D.
-