sim.util
Class MutableDouble2D

java.lang.Object
  extended by sim.util.MutableDouble2D
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class MutableDouble2D
extends java.lang.Object
implements java.io.Serializable, java.lang.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:
Serialized Form

Field Summary
 double x
           
 double y
           
 
Constructor Summary
MutableDouble2D()
           
MutableDouble2D(Double2D p)
           
MutableDouble2D(double x, double y)
           
MutableDouble2D(Int2D p)
           
MutableDouble2D(MutableDouble2D p)
           
MutableDouble2D(MutableInt2D p)
           
MutableDouble2D(java.awt.Point p)
           
MutableDouble2D(java.awt.geom.Point2D.Double p)
           
MutableDouble2D(java.awt.geom.Point2D.Float p)
           
MutableDouble2D(java.awt.geom.Point2D p)
          Only included for completeness' sakes, in case a new Point2D subclass is created in the future.
 
Method Summary
 MutableDouble2D add(Double2D other1, MutableDouble2D other2)
          Sets me to the sum of other1 and other2, returning me.
 MutableDouble2D add(MutableDouble2D other1, Double2D other2)
          Sets me to the sum of other1 and other2, returning me.
 MutableDouble2D add(MutableDouble2D other1, MutableDouble2D other2)
          Sets me to the sum of other1 and other2, returning me.
 MutableDouble2D addIn(Double2D other)
          Adds other into me, returning me.
 MutableDouble2D addIn(double x, double y)
          Adds the x and y values into my x and y values, returning me.
 MutableDouble2D addIn(MutableDouble2D other)
          Adds other into me, returning me.
 double angle()
          Returns the length of the vector between -Pi and Pi.
 java.lang.Object clone()
           
 double distance(Double2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distance(double x, double y)
          Returns the distance FROM this MutableDouble2D TO the specified point
 double distance(Int2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distance(MutableDouble2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distance(MutableInt2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distance(java.awt.geom.Point2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distanceSq(Double2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distanceSq(double x, double y)
          Returns the distance FROM this MutableDouble2D TO the specified point
 double distanceSq(Int2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distanceSq(MutableDouble2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distanceSq(MutableInt2D p)
          Returns the distance FROM this MutableDouble2D TO the specified point.
 double distanceSq(java.awt.geom.Point2D p)
          Returns the distance FROM this Point2D TO the specified point
 double dot(MutableDouble2D other)
          Returns the dot product of myself against other, that is me DOT other.
 MutableDouble2D dup()
          Equivalent to (new MutableDouble2D(d)), but (d.dup()) shorter of course, but perhaps not quite as fast.
 boolean equals(java.lang.Object obj)
           
 double getX()
           
 double getY()
           
 int hashCode()
           
 double length()
          Returns the length of the vector.
 double lengthSq()
          Returns the square of the length of the MutableDouble2D.
 double manhattanDistance(Double2D p)
          Returns the manhtattan distance FROM this MuableDouble2D TO the specified point
 double manhattanDistance(double x, double y)
          Returns the manhtattan distance FROM this MuableDouble2D TO the specified point
 double manhattanDistance(Int2D p)
          Returns the manhtattan distance FROM this MuableDouble2D TO the specified point
 double manhattanDistance(MutableDouble2D p)
          Returns the manhtattan distance FROM this MuableDouble2D TO the specified point
 double manhattanDistance(MutableInt2D p)
          Returns the manhtattan distance FROM this MuableDouble2D TO the specified point
 double manhattanDistance(java.awt.geom.Point2D p)
          Returns the manhtattan distance FROM this MuableDouble2D TO the specified point
 MutableDouble2D multiply(Double2D other, double val)
          Multiplies other by val, setting me to the result and returning me.
 MutableDouble2D multiply(MutableDouble2D other, double val)
          Multiplies other by val, setting me to the result and returning me.
 MutableDouble2D multiplyIn(double val)
          Extends my length so that it is multiplied by val, and returns me.
 MutableDouble2D negate()
          Negates the MutableDouble2D's values and returns it.
 MutableDouble2D normalize()
           
 double perpDot(MutableDouble2D other)
          2D version of the cross product: returns the dot product of me rotated 90 degrees dotted against the other vector.
 MutableDouble2D resize(double val)
          Sets my length, which should be >= 0.
 MutableDouble2D rotate(double theta)
          Rotates me by theta radians, returning me.
 MutableDouble2D setLength(double val)
          Deprecated. use resize instead [renaming]
 void setTo(Double2D b)
           
 void setTo(double bx, double by)
           
 void setTo(Int2D b)
           
 void setTo(MutableDouble2D b)
           
 void setTo(MutableInt2D b)
           
 MutableDouble2D setToMinus(MutableDouble2D b)
          Sets the values to the negation of the values in the provided MutableDouble2D
 void setX(double val)
           
 void setY(double val)
           
 MutableDouble2D subtract(Double2D other1, MutableDouble2D other2)
          Subtracts other2 from other1, setting me to the result and returning me.
 MutableDouble2D subtract(MutableDouble2D other1, Double2D other2)
          Subtracts other2 from other1, setting me to the result and returning me.
 MutableDouble2D subtract(MutableDouble2D other1, MutableDouble2D other2)
          Subtracts other2 from other1, setting me to the result and returning me.
 MutableDouble2D subtractIn(Double2D other)
          Sets me to me minus other, returning me.
 MutableDouble2D subtractIn(MutableDouble2D other)
          Sets me to me minus other, returning me.
 java.lang.String toCoordinates()
           
 java.awt.geom.Point2D.Double toPoint2D()
           
 java.lang.String toString()
           
 MutableDouble2D zero()
          Sets the values to 0 and returns it.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x

y

public double y
Constructor Detail

MutableDouble2D

public MutableDouble2D()

MutableDouble2D

public MutableDouble2D(Int2D p)

MutableDouble2D

public MutableDouble2D(MutableInt2D p)

MutableDouble2D

public MutableDouble2D(MutableDouble2D p)

MutableDouble2D

public MutableDouble2D(Double2D p)

MutableDouble2D

public MutableDouble2D(java.awt.Point p)

MutableDouble2D

public MutableDouble2D(java.awt.geom.Point2D.Double p)

MutableDouble2D

public MutableDouble2D(java.awt.geom.Point2D.Float p)

MutableDouble2D

public MutableDouble2D(java.awt.geom.Point2D p)
Only included for completeness' sakes, in case a new Point2D subclass is created in the future.


MutableDouble2D

public MutableDouble2D(double x,
                       double y)
Method Detail

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

public final void setTo(Int2D b)

setTo

public final void setTo(Double2D b)

setTo

public final void setTo(MutableInt2D b)

setTo

public final void setTo(MutableDouble2D b)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toCoordinates

public java.lang.String toCoordinates()

toPoint2D

public java.awt.geom.Point2D.Double toPoint2D()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public final boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

distance

public double distance(double x,
                       double y)
Returns the distance FROM this MutableDouble2D TO the specified point


distance

public double distance(MutableDouble2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distance

public double distance(Double2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distance

public double distance(Int2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distance

public double distance(MutableInt2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distance

public double distance(java.awt.geom.Point2D p)
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

public double distanceSq(Double2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distanceSq

public double distanceSq(MutableDouble2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distanceSq

public double distanceSq(Int2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distanceSq

public double distanceSq(MutableInt2D p)
Returns the distance FROM this MutableDouble2D TO the specified point.


distanceSq

public double distanceSq(java.awt.geom.Point2D p)
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

public double manhattanDistance(Double2D p)
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point


manhattanDistance

public double manhattanDistance(Int2D p)
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point


manhattanDistance

public double manhattanDistance(MutableDouble2D p)
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point


manhattanDistance

public double manhattanDistance(MutableInt2D p)
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point


manhattanDistance

public double manhattanDistance(java.awt.geom.Point2D p)
Returns the manhtattan distance FROM this MuableDouble2D TO the specified point


addIn

public final MutableDouble2D addIn(Double2D other)
Adds other into me, returning me.


addIn

public final MutableDouble2D addIn(MutableDouble2D other)
Adds other into me, returning me.


addIn

public final MutableDouble2D addIn(double x,
                                   double y)
Adds the x and y values into my x and y values, returning me.


add

public final MutableDouble2D add(MutableDouble2D other1,
                                 MutableDouble2D other2)
Sets me to the sum of other1 and other2, returning me.


add

public final MutableDouble2D add(Double2D other1,
                                 MutableDouble2D other2)
Sets me to the sum of other1 and other2, returning me.


add

public final MutableDouble2D add(MutableDouble2D other1,
                                 Double2D other2)
Sets me to the sum of other1 and other2, returning me.


dup

public final MutableDouble2D dup()
Equivalent to (new MutableDouble2D(d)), but (d.dup()) shorter of course, but perhaps not quite as fast.


subtractIn

public final MutableDouble2D subtractIn(Double2D other)
Sets me to me minus other, returning me.


subtractIn

public final MutableDouble2D subtractIn(MutableDouble2D other)
Sets me to me minus other, returning me.


subtract

public final MutableDouble2D subtract(MutableDouble2D other1,
                                      MutableDouble2D other2)
Subtracts other2 from other1, setting me to the result and returning me.


subtract

public final MutableDouble2D subtract(Double2D other1,
                                      MutableDouble2D other2)
Subtracts other2 from other1, setting me to the result and returning me.


subtract

public final MutableDouble2D subtract(MutableDouble2D other1,
                                      Double2D other2)
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

public final MutableDouble2D multiplyIn(double val)
Extends my length so that it is multiplied by val, and returns me.


multiply

public final MutableDouble2D multiply(MutableDouble2D other,
                                      double val)
Multiplies other by val, setting me to the result and returning me.


multiply

public final MutableDouble2D multiply(Double2D other,
                                      double val)
Multiplies other by val, setting me to the result and returning me.


normalize

public final MutableDouble2D normalize()

setLength

public final MutableDouble2D setLength(double val)
Deprecated. use resize instead [renaming]

Sets my length, which should be >= 0.


resize

public final MutableDouble2D resize(double val)
Sets my length, which should be >= 0.


rotate

public final MutableDouble2D rotate(double theta)
Rotates me by theta radians, returning me.


dot

public final double dot(MutableDouble2D other)
Returns the dot product of myself against other, that is me DOT other.


perpDot

public double perpDot(MutableDouble2D other)
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

public final MutableDouble2D zero()
Sets the values to 0 and returns it.


setToMinus

public final MutableDouble2D setToMinus(MutableDouble2D b)
Sets the values to the negation of the values in the provided MutableDouble2D


negate

public final MutableDouble2D negate()
Negates the MutableDouble2D's values and returns it.