Package geomss.geom
Class MutablePoint
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<GeomPoint>
-
- geomss.geom.GeomPoint
-
- geomss.geom.MutablePoint
-
- All Implemented Interfaces:
GeomElement<GeomPoint>,PointGeometry<GeomPoint>,Transformable<GeomPoint>,XYPoint,java.io.Serializable,java.lang.Cloneable,java.lang.Comparable,javolution.lang.Reusable,javolution.xml.XMLSerializable
public final class MutablePoint extends GeomPoint
A mutable container that holds changeable coordinates of a point in n-dimensional space.Modified by: Joseph A. Huwaldt
- Version:
- February 17, 2025
- Author:
- Joseph A. Huwaldt, Date: December 11, 1999
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MutablePointcopy()Returns a copy of this MutablePoint instanceallocatedby the calling thread (possibly on the stack).PointcopyToReal()Return a copy of this object with any transformations or subranges removed (applied).booleanequals(java.lang.Object obj)Compares this Point against the specified object for strict equality (same values and same units).intgetPhyDimension()Returns the number of physical dimensions of the geometry element.javax.measure.unit.Unit<javax.measure.quantity.Length>getUnit()Returns the unit in which thevaluesin this point are stated in.doublegetValue(int i)Returns the value of a coordinate in this point as adouble, stated in this point'sunit.doublegetValue(int i, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns the value of a coordinate in this point as adouble, stated in the specified unit.inthashCode()Returns the hash code for this parameter.Pointimmutable()Return an immutable version of this point.Pointminus(GeomPoint that)Returns the difference between this point and the one specified.Pointminus(Parameter<javax.measure.quantity.Length> that)Subtracts the specified parameter from each component of this point.static MutablePointnewInstance(int dim)Returns aMutablePointinstance of the specified dimension with zero meters for each coordinate value.static MutablePointnewInstance(int dim, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns aPointinstance of the specified dimension and units with zero for each coordinate value.doublenormSqValue()Returns the square of the Euclidean norm, magnitude, or length value of the vector from the origin to this point (the dot product of the origin-to-this-point vector and itself).Pointopposite()Returns the negation of this point (all the values of each dimension negated).Pointplus(GeomPoint that)Returns the sum of this point with the one specified.Pointplus(Parameter<javax.measure.quantity.Length> that)Adds the specified parameter to each component of this point.static voidrecycle(MutablePoint instance)Recycles aMutablePointinstance immediately (on the stack when executing in aStackContext).voidset(int i, Parameter<javax.measure.quantity.Length> value)Set the value of a point dimension to the specified Parameter.voidset(GeomPoint p)Set the value of elements of this point to the elements of the specified point.voidset(GeomVector<?> vector)Set the value of elements of this point to the elements of the specified vector of Parameter objects.voidsetValue(int i, double value)Set the value of a point dimension to the specified double in the current point units.Pointtimes(double k)Returns the product of this point with the specified coefficient.MutablePointto(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns the equivalent to this point but stated in the specified unit.MutablePointtoDimension(int newDim)Return the equivalent of this point converted to the specified number of physical dimensions.Float64VectortoFloat64Vector()Returns the values stored in this point, stated in this point'sunit, as a Float64Vector.static MutablePointvalueOf(double... x)Returns aMutablePointinstance holding the specifieddoublevalue or values stated in meters.static MutablePointvalueOf(double x, double y, double z, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns a 3DMutablePointinstance holding the specifieddoublevalues stated in the specified units.static MutablePointvalueOf(double x, double y, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns a 2DMutablePointinstance holding the specifieddoublevalue stated in the specified units.static MutablePointvalueOf(double x, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns a 1DMutablePointinstance holding the specifieddoublevalues stated in the specified units.static MutablePointvalueOf(GeomPoint point)Returns aMutablePointinstance containing the specified GeomPoint's data.static MutablePointvalueOf(GeomVector<?> vector)Returns aMutablePointinstance that represents the direction elements of the specified GeomVector given in length or dimensionless units.static MutablePointvalueOf(Coordinate3D<javax.measure.quantity.Length> coord)Returns aMutablePointinstance holding the specified@link jahuwaldt.js.param.Coordinate3D Coordinate3Dvalues.static MutablePointvalueOf(Parameter<javax.measure.quantity.Length>... values)Returns aMutablePointinstance holding the specifiedParametervalues.static MutablePointvalueOf(java.util.List<Parameter<javax.measure.quantity.Length>> values)Returns aMutablePointinstance holding the specifiedParametervalues.static MutablePointvalueOf(javax.measure.unit.Unit<javax.measure.quantity.Length> unit, double... values)Returns aMutablePointinstance holding the specifieddoublevalues stated in the specified units.static <Q extends javax.measure.quantity.Quantity>
MutablePointvalueOf(Vector<Parameter<Q>> vector)Returns aMutablePointinstance containing the specified vector of Parameter values with length units.static MutablePointvalueOf(Vector<Float64> vector, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns aMutablePointinstance containing the specified vector of Float64 values stated in the specified units.-
Methods inherited from class geomss.geom.GeomPoint
distance, distanceSq, distanceSqValue, distanceValue, divide, divide, get, getBoundsMax, getBoundsMin, getLimitPoint, getNumberOfPoints, getParDimension, getTransformed, getX, getY, getZ, isApproxEqual, isApproxEqual, isValid, max, min, norm, normSq, normValue, size, times, toArray, toArray, toGeomVector, toParameterVector, toText, toVector3D
-
Methods inherited from class geomss.geom.AbstractGeomElement
addChangeListener, clone, compareTo, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, reset, setName, toString
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName
-
-
-
-
Method Detail
-
newInstance
public static MutablePoint newInstance(int dim)
Returns aMutablePointinstance of the specified dimension with zero meters for each coordinate value.- Parameters:
dim- the physical dimension of the point to create.- Returns:
- the point having the specified dimension and zero meters for values.
-
newInstance
public static MutablePoint newInstance(int dim, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns aPointinstance of the specified dimension and units with zero for each coordinate value.- Parameters:
dim- the physical dimension of the point to create.unit- The unit for the point to create. May not be null.- Returns:
- the point having the specified dimension & units and zero for values.
-
valueOf
public static MutablePoint valueOf(double... x)
Returns aMutablePointinstance holding the specifieddoublevalue or values stated in meters.- Parameters:
x- the coordinate values stated in meters. May not be null.- Returns:
- the point having the specified value.
-
valueOf
public static MutablePoint valueOf(double x, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns a 1DMutablePointinstance holding the specifieddoublevalues stated in the specified units.- Parameters:
x- the x value stated in the specified unit.unit- the unit in which the coordinates are stated. May not be null.- Returns:
- the point having the specified value.
-
valueOf
public static MutablePoint valueOf(double x, double y, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns a 2DMutablePointinstance holding the specifieddoublevalue stated in the specified units.- Parameters:
x- the x value stated in the specified unit.y- the y value stated in the specified unit.unit- the unit in which the coordinates are stated. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static MutablePoint valueOf(double x, double y, double z, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns a 3DMutablePointinstance holding the specifieddoublevalues stated in the specified units.- Parameters:
x- the x value stated in the specified unit.y- the y value stated in the specified unit.z- the z value stated in the specified unit.unit- the unit in which the coordinates are stated. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static MutablePoint valueOf(javax.measure.unit.Unit<javax.measure.quantity.Length> unit, double... values)
Returns aMutablePointinstance holding the specifieddoublevalues stated in the specified units.- Parameters:
unit- the length unit in which the coordinates are stated. May not be null.values- the list of values stated in the specified unit. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static MutablePoint valueOf(Parameter<javax.measure.quantity.Length>... values)
Returns aMutablePointinstance holding the specifiedParametervalues. All the values are converted to the same units as the 1st value.- Parameters:
values- The list of values to be stored. May not be null.- Returns:
- the point having the specified values in the units of the 1st value.
-
valueOf
public static MutablePoint valueOf(java.util.List<Parameter<javax.measure.quantity.Length>> values)
Returns aMutablePointinstance holding the specifiedParametervalues. All the values are converted to the same units as the 1st value.- Parameters:
values- The list of values to be stored. May not be null.- Returns:
- the point having the specified values in the units of the 1st value.
-
valueOf
public static MutablePoint valueOf(Coordinate3D<javax.measure.quantity.Length> coord)
Returns aMutablePointinstance holding the specified@link jahuwaldt.js.param.Coordinate3D Coordinate3Dvalues.- Parameters:
coord- TheCoordinate3Dto be stored. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static MutablePoint valueOf(Vector<Float64> vector, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns aMutablePointinstance containing the specified vector of Float64 values stated in the specified units.- Parameters:
vector- the vector of Float64 values stated in the specified unit. May not be null.unit- the unit in which the values are stated. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> MutablePoint valueOf(Vector<Parameter<Q>> vector)
Returns aMutablePointinstance containing the specified vector of Parameter values with length units. All the values are converted to the same units as the 1st value.- Type Parameters:
Q- The Quantity (unit type) of this point.- Parameters:
vector- the vector of Parameter values stated in length or dimensionless units. If in dimensionless units, the values are interpreted as being in meters. May not be null.- Returns:
- the point having the specified values.
- Throws:
javax.measure.converter.ConversionException- if the input vector is not in length (or Dimensionless) units.
-
valueOf
public static MutablePoint valueOf(GeomVector<?> vector)
Returns aMutablePointinstance that represents the direction elements of the specified GeomVector given in length or dimensionless units. If the user wishes for the point to represent the end or tip of the vehicle they should use the following:MutablePoint p = MutablePoint.valueOf(vector).plus(vector.getOrigin());- Parameters:
vector- the GeomVector stated in length or dimensionless units. If in dimensionless units, the values are interpreted as being in meters. May not be null.- Returns:
- the point having the specified values of the vector end point or tip.
- Throws:
javax.measure.converter.ConversionException- if the input vector is not in length (or Dimensionless) units.
-
valueOf
public static MutablePoint valueOf(GeomPoint point)
Returns aMutablePointinstance containing the specified GeomPoint's data.- Parameters:
point- the GeomPoint to be copied into a new Point. May not be null.- Returns:
- the point having the specified values.
-
recycle
public static void recycle(MutablePoint instance)
Recycles aMutablePointinstance immediately (on the stack when executing in aStackContext).- Parameters:
instance- The instance to be recycled.
-
getPhyDimension
public int getPhyDimension()
Returns the number of physical dimensions of the geometry element.- Returns:
- The number of physical dimensions of the geometry element.
-
set
public void set(GeomPoint p)
Set the value of elements of this point to the elements of the specified point. If the input GeomPoint is of type "Point", then the data stored in this MutablePoint is set to the data stored in "p" without creating any new object instances (copy by value).- Parameters:
p- The new point to make this point equal to. May not be null.- Throws:
DimensionException-(p.getPhyDimension() != getPhyDimension())
-
set
public void set(GeomVector<?> vector)
Set the value of elements of this point to the elements of the specified vector of Parameter objects. The origin of the vector is ignored.- Parameters:
vector- The new vector to make this point equal to in length or dimensionless units. If in dimensionless units, the values are interpreted as being in the same units as this point. May not be null.- Throws:
DimensionException-(vector.getDimension() != getPhyDimension())javax.measure.converter.ConversionException- if the input vector is not in length (or Dimensionless) units.
-
set
public void set(int i, Parameter<javax.measure.quantity.Length> value)
Set the value of a point dimension to the specified Parameter.- Parameters:
i- the dimension index.value- The new value of the parameter to set ati. May not be null.- Throws:
java.lang.IndexOutOfBoundsException-(i < 0) || (i ≥ getPhyDimension())
-
setValue
public void setValue(int i, double value)
Set the value of a point dimension to the specified double in the current point units.- Parameters:
i- the dimension index.value- The new value of the parameter to set atiin the current units of this point.- Throws:
java.lang.IndexOutOfBoundsException-(i < 0) || (i ≥ getPhyDimension())
-
getValue
public double getValue(int i)
Returns the value of a coordinate in this point as adouble, stated in this point'sunit.
-
getValue
public double getValue(int i, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns the value of a coordinate in this point as adouble, stated in the specified unit.
-
normSqValue
public double normSqValue()
Returns the square of the Euclidean norm, magnitude, or length value of the vector from the origin to this point (the dot product of the origin-to-this-point vector and itself). This is slightly faster than callingnormValueif the squared value is all that is needed.- Specified by:
normSqValuein classGeomPoint- Returns:
this.normSq().getValue().- See Also:
GeomPoint.normValue()
-
plus
public Point plus(GeomPoint that)
Returns the sum of this point with the one specified. The unit of the output point will be the units of this point.- Specified by:
plusin classGeomPoint- Parameters:
that- the point to be added. May not be null.- Returns:
this + that.- Throws:
DimensionException- if point dimensions are different.
-
plus
public Point plus(Parameter<javax.measure.quantity.Length> that)
Adds the specified parameter to each component of this point. The unit of the output point will be the units of this point.
-
minus
public Point minus(GeomPoint that)
Returns the difference between this point and the one specified. The unit of the output point will be the units of this point.- Specified by:
minusin classGeomPoint- Parameters:
that- the point to be subtracted from this point. May not be null.- Returns:
this - that.- Throws:
DimensionException- if point dimensions are different.
-
minus
public Point minus(Parameter<javax.measure.quantity.Length> that)
Subtracts the specified parameter from each component of this point. The unit of the output point will be the units of this point.
-
opposite
public Point opposite()
Returns the negation of this point (all the values of each dimension negated).
-
times
public Point times(double k)
Returns the product of this point with the specified coefficient.
-
copy
public MutablePoint copy()
Returns a copy of this MutablePoint instanceallocatedby the calling thread (possibly on the stack).- Specified by:
copyin interfaceGeomElement<GeomPoint>- Specified by:
copyin classGeomPoint- Returns:
- an identical and independent copy of this point.
-
copyToReal
public Point copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Specified by:
copyToRealin interfaceGeomElement<GeomPoint>- Specified by:
copyToRealin classGeomPoint- Returns:
- A copy of this object with any transformations or subranges removed.
-
getUnit
public final javax.measure.unit.Unit<javax.measure.quantity.Length> getUnit()
Returns the unit in which thevaluesin this point are stated in.- Returns:
- The unit in which the
valuesin this point are stated in.
-
to
public MutablePoint to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this point but stated in the specified unit.- Parameters:
unit- the length unit of the point to be returned. May not be null.- Returns:
- an equivalent of this point but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException- if the the input unit is not a length unit.
-
toDimension
public MutablePoint toDimension(int newDim)
Return the equivalent of this point converted to the specified number of physical dimensions. If the number of dimensions is greater than this element, then zeros are added to the additional dimensions. If the number of dimensions is less than this element, then the extra dimensions are simply dropped (truncated). If the new dimensions are the same as the dimension of this element, then this element is simply returned.- Parameters:
newDim- The dimension of the point to return.- Returns:
- A copy of this point converted to the new dimensions.
-
toFloat64Vector
public final Float64Vector toFloat64Vector()
Returns the values stored in this point, stated in this point'sunit, as a Float64Vector.- Specified by:
toFloat64Vectorin classGeomPoint- Returns:
- A Float64Vector containing the coordinate values for this point.
-
equals
public boolean equals(java.lang.Object obj)
Compares this Point against the specified object for strict equality (same values and same units).- Overrides:
equalsin classAbstractGeomElement<GeomPoint>- Parameters:
obj- the object to compare with.- Returns:
trueif this point is identical to that point;falseotherwise.
-
hashCode
public int hashCode()
Returns the hash code for this parameter.- Overrides:
hashCodein classAbstractGeomElement<GeomPoint>- Returns:
- the hash code value.
-
-