sim.util
Class MutableDouble2D

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

public final class MutableDouble2D
extends java.lang.Object
implements java.io.Serializable

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(MutableDouble2D other1, MutableDouble2D other2)
          Sets me to the sum of other1 and other2, 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.
 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.
 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.
 void negate()
          Negates the MutableDouble2D's values
 MutableDouble2D normalize()
          Normalizes me (sets my length to 1.0), returning me.
 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 rotate(double theta)
          Rotates me by theta radians, returning me.
 MutableDouble2D setLength(double val)
          Sets my length, which should be >= 0.
 void setTo(Double2D b)
           
 void setTo(double bx, double by)
           
 void setTo(Int2D b)
           
 void setTo(MutableDouble2D b)
           
 void setTo(MutableInt2D b)
           
 void 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(MutableDouble2D other1, MutableDouble2D other2)
          Subtracts other2 from other1, setting me to the result and returning me.
 MutableDouble2D subtractIn(MutableDouble2D other)
          Sets me to me minus other, returning me.
 java.lang.String toCoordinates()
           
 java.lang.String toString()
           
 void zero()
          Sets the values to 0.
 
Methods inherited from class java.lang.Object
clone, 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()

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


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.


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(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.


length

public final double length()
Returns the length of the vector.


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.


normalize

public final MutableDouble2D normalize()
Normalizes me (sets my length to 1.0), returning me. Throws an error if my previous length wasof length 0.


setLength

public final MutableDouble2D setLength(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 void zero()
Sets the values to 0.


setToMinus

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


negate

public final void negate()
Negates the MutableDouble2D's values


lengthSq

public final double lengthSq()
Returns the square of the length of the MutableDouble2D.