Package sim.util

Class MutableDouble2D

All Implemented Interfaces:
Serializable, Cloneable

public final class MutableDouble2D extends MutableNumberND
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 Details

    • x

      public double x
    • y

      public double y
  • Constructor Details

    • 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(Point p)
    • MutableDouble2D

      public MutableDouble2D(Point2D.Double p)
    • MutableDouble2D

      public MutableDouble2D(Point2D.Float p)
    • MutableDouble2D

      public MutableDouble2D(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)
    • MutableDouble2D

      public MutableDouble2D(double[] vals)
  • Method Details

    • mutable

      public boolean mutable()
      Description copied from class: NumberND
      Returns whether this NumberND is mutable. This is equivalent to asking (instanceof val MutableNumberND)
      Overrides:
      mutable in class NumberND
    • numDimensions

      public int numDimensions()
      Description copied from class: NumberND
      Returns the number of dimensions of this NumberND (normally 2 or 3)
      Specified by:
      numDimensions in class NumberND
    • getVal

      public double getVal(int val)
      Description copied from class: NumberND
      Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)
      Specified by:
      getVal in class NumberND
    • setVal

      public void setVal(int val, double to)
      Specified by:
      setVal in class MutableNumberND
    • toBytes

      public byte[] toBytes()
      Description copied from class: NumberND
      Flattens out the NumberND to an array of bytes, including the NumberND subtype.
      Specified by:
      toBytes in class NumberND
    • 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 String toString()
      Description copied from class: NumberND
      Returns this NumberND as a nicely formatted String.
      Specified by:
      toString in class NumberND
    • toCoordinates

      public String toCoordinates()
      Description copied from class: NumberND
      Returns this NumberND in mathematical coordinates as a formatted String.
      Specified by:
      toCoordinates in class NumberND
    • toPoint2D

      public Point2D.Double toPoint2D()
    • toArrayAsDouble

      public double[] toArrayAsDouble()
      Specified by:
      toArrayAsDouble in class NumberND
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • hashCode

      public final int hashCode()
      Description copied from class: NumberND
      Provides a hashcode for this NumberND.
      Specified by:
      hashCode in class NumberND
    • equals

      public final boolean equals(Object obj)
      Description copied from class: NumberND
      Returns whether this NumberND is equivalent to some other NumberND.
      Specified by:
      equals in class NumberND
    • 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(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(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(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.