Package geomss.geom.nurbs
Class ControlPoint
- java.lang.Object
-
- geomss.geom.nurbs.ControlPoint
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,javolution.lang.Immutable,javolution.lang.ValueType,javolution.xml.XMLSerializable
public class ControlPoint extends java.lang.Object implements java.lang.Cloneable, javolution.xml.XMLSerializable, javolution.lang.ValueType
A container that holds the coordinates of a NURBS control point in n-dimensional space.Modified by: Joseph A. Huwaldt
- Version:
- February 17, 2025
- Author:
- Joseph A. Huwaldt, Date: May 14, 2009
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ControlPointapplyWeight()Returns a new ControlPoint with the geometric point portion of this control point multiplied by the weight.ControlPointchangeWeight(double value)Return a new control point that is identical to this one, but with the weight changed to the specified value.java.lang.Objectclone()Returns a copy of this ControlPoint instanceallocatedby the calling thread (possibly on the stack).ControlPointcopy()Returns a copy of this ControlPoint instanceallocatedby the calling thread (possibly on the stack).doubledistance(ControlPoint cp)Return the distance (in homogeneous coordinates) between this control point and another (this treats the weight simply as another dimension).ControlPointdivide(double divisor)Returns a new control point with this point divided by the specified divisor.booleanequals(java.lang.Object obj)Compares this ControlPoint against the specified object for strict equality (same values and same units).PointgetBoundsMax()Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).PointgetBoundsMin()Return the coordinate point representing the minimum bounding box corner (e.g.: min X, min Y, min Z).ControlPointgetHomogeneous()Return a copy of this control point with the values made homogeneous (all the geometric point values are divided by the weight).intgetPhyDimension()Returns the number of physical dimensions of the geometry element.PointgetPoint()Return the Point representation of this ControlPoint.javax.measure.unit.Unit<javax.measure.quantity.Length>getUnit()Returns the unit in which this control point is stated.doublegetValue(int i)Returns the value of the Parameter in this point as adouble, stated in this point's unit.doublegetWeight()Return the weight associated with this control point.inthashCode()Returns the hash code for this parameter.booleanisValid()Returntrueif this control point contains valid and finite numerical components.ControlPointminus(ControlPoint that)Returns a new control point with the difference between this point with the one specified.static ControlPointnewInstance(int dim)Returns aControlPointinstance of the specified dimension with zero meters for each coordinate value and zero weight.static ControlPointnewInstance(int dim, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns aControlPointinstance of the specified dimension and units with zero for each coordinate value and zero weight.doublenormValue()Returns the norm, magnitude, or length value of the vector from the origin to this control point geometric point (square root of the dot product of the origin-to-this-point vector and itself).ControlPointplus(ControlPoint that)Returns a new control point with the sum of this point with the one specified.ControlPointtimes(double k)Returns a new control point with the product of this point with the specified coefficient.ControlPointto(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns the equivalent to this control point but stated in the specified unit.double[]toArray()Returns the values stored in this control point as a Java array, stated in the currentunitswith the weight tacked onto the end of the array.double[]toArray(double[] array)Returns the values stored in this control point, with the coordinate point stated in the currentunitsand the weight tacked onto the end, stored in the input Java array.Float64VectortoFloat64Vector()Returns the values stored in this control point, with the coordinate points stated in this point's unit and the weight tacked onto the end as a Float64Vector.java.lang.StringtoString()Returns the String representation of this control point that consists of the the geometry coordinate values followed by the weighting factor.javolution.text.TexttoText()Returns the text representation of this control point that consists of the the geometry coordinate values followed by the weighting factor.static ControlPointvalueOf(double x, double y, double w)Returns a 2DControlPointinstance holding the specifieddoublevalues stated in meters.static ControlPointvalueOf(double x, double y, double z, double w)Returns a 3DControlPointinstance holding the specifieddoublevalues stated in meters.static ControlPointvalueOf(double x, double y, double z, double w, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns a 3DControlPointinstance holding the specifieddoublevalues stated in the specified units.static ControlPointvalueOf(double x, double y, double w, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns a 2DControlPointinstance holding the specifieddoublevalues stated in the specified units.static ControlPointvalueOf(ControlPoint point)Returns aControlPointinstance containing the specified ControlPoint's data.static ControlPointvalueOf(Point point, double w)Returns aControlPointinstance containing the specified Point's data.static ControlPointvalueOf(javax.measure.unit.Unit<javax.measure.quantity.Length> unit, double[] vector)Returns aControlPointinstance holding the specifieddoublevalues stated in the specified units.static ControlPointvalueOf(Vector<Float64> vector, double w, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns aControlPointinstance holding the specifiedFloat64values plus weight stated in the specified units.static ControlPointvalueOf(Vector<Float64> vector, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns aControlPointinstance holding the specifiedFloat64values stated in the specified units.
-
-
-
Method Detail
-
newInstance
public static ControlPoint newInstance(int dim)
Returns aControlPointinstance of the specified dimension with zero meters for each coordinate value and zero weight.- Parameters:
dim- the physical dimension of the point to create (not including the weighting factor).- Returns:
- the point having the specified dimension and zero meters for values.
-
newInstance
public static ControlPoint newInstance(int dim, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns aControlPointinstance of the specified dimension and units with zero for each coordinate value and zero weight.- Parameters:
dim- the physical dimension of the point to create (not including the weighting factor).unit- the unit for the point coordinate values. May not be null.- Returns:
- the point having the specified dimension & unit and zero for values.
-
valueOf
public static ControlPoint valueOf(double x, double y, double w)
Returns a 2DControlPointinstance holding the specifieddoublevalues stated in meters.- Parameters:
x- the x value stated in meters.y- the y value stated in meters.w- the weighting factor for the control point.- Returns:
- the point having the specified values.
-
valueOf
public static ControlPoint valueOf(double x, double y, double w, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns a 2DControlPointinstance 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.w- the weighting factor for the control point.unit- the unit in which the coordinates are stated. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static ControlPoint valueOf(double x, double y, double z, double w)
Returns a 3DControlPointinstance holding the specifieddoublevalues stated in meters.- Parameters:
x- the x value stated in meters.y- the y value stated in meters.z- the z value stated in meters.w- the weighting factor for the control point.- Returns:
- the point having the specified values.
-
valueOf
public static ControlPoint valueOf(double x, double y, double z, double w, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns a 3DControlPointinstance 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 meters.w- the weighting factor for the control point.unit- the unit in which the coordinates are stated. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static ControlPoint valueOf(Vector<Float64> vector, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns aControlPointinstance holding the specifiedFloat64values stated in the specified units.- Parameters:
vector- the vector of Float64 values stated with all but the last stated in the specified unit (the last is assumed to be the weight). May not be null.unit- the unit in which the coordinates are stated. May not be null.- Returns:
- the point having the specified values.
-
valueOf
public static ControlPoint valueOf(Vector<Float64> vector, double w, javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns aControlPointinstance holding the specifiedFloat64values plus weight stated in the specified units.- Parameters:
vector- the vector of Float64 values representing the geometric point stated in the specified unit. May not be null.w- the weighting factor for the control point.unit- the unit in which the coordinates are stated. May not be null.- Returns:
- the control point having the specified values.
-
valueOf
public static ControlPoint valueOf(javax.measure.unit.Unit<javax.measure.quantity.Length> unit, double[] vector)
Returns aControlPointinstance holding the specifieddoublevalues stated in the specified units.- Parameters:
unit- the unit in which the coordinates are stated. May not be null.vector- the vector of coordinate values with all but the last stated in the specified unit (the last is assumed to be the weight). May not be null.- Returns:
- the control point having the specified values.
-
valueOf
public static ControlPoint valueOf(Point point, double w)
Returns aControlPointinstance containing the specified Point's data.- Parameters:
point- the Point to be copied into a new ControlPoint. May not be null.w- the weighting factor for the control point.- Returns:
- the point having the specified values.
-
valueOf
public static ControlPoint valueOf(ControlPoint point)
Returns aControlPointinstance containing the specified ControlPoint's data.- Parameters:
point- the ControlPoint to be copied into a new ControlPoint. May not be null.- Returns:
- the point having the specified values.
-
getPhyDimension
public int getPhyDimension()
Returns the number of physical dimensions of the geometry element. This implementation returns the dimensions of the point and does not count the weighting factor.- Returns:
- The physical dimensions of the control points not counting the weighting factor.
-
getValue
public double getValue(int i)
Returns the value of the Parameter in this point as adouble, stated in this point's unit.- Parameters:
i- the dimension index.- Returns:
- the value of the Parameter at
i. - Throws:
java.lang.IndexOutOfBoundsException-(i < 0) || (i > getPhyDimension() - 1)
-
getPoint
public Point getPoint()
Return the Point representation of this ControlPoint.- Returns:
- A Point representation of this control point.
-
getWeight
public double getWeight()
Return the weight associated with this control point.- Returns:
- The weighting factor associated with this control point.
-
changeWeight
public ControlPoint changeWeight(double value)
Return a new control point that is identical to this one, but with the weight changed to the specified value.- Parameters:
value- The new weighting factor.- Returns:
- A new ControlPoint identical to this one but with the specified weight.
-
getHomogeneous
public ControlPoint getHomogeneous()
Return a copy of this control point with the values made homogeneous (all the geometric point values are divided by the weight).- Returns:
- A new ControlPoint with the values made homogeneous.
-
applyWeight
public ControlPoint applyWeight()
Returns a new ControlPoint with the geometric point portion of this control point multiplied by the weight.- Returns:
- A new ControlPoint with the geometric point multiplied by the weight.
-
plus
public ControlPoint plus(ControlPoint that)
Returns a new control point with the sum of this point with the one specified.- Parameters:
that- the point to be added to this one. May not be null.- Returns:
- A new ControlPoint with this + that.
- Throws:
DimensionException- if point dimensions are different.
-
minus
public ControlPoint minus(ControlPoint that)
Returns a new control point with the difference between this point with the one specified.- Parameters:
that- the point to be subtracted from this one. May not be null.- Returns:
- A new ControlPoint with this - that.
- Throws:
DimensionException- if point dimensions are different.
-
times
public ControlPoint times(double k)
Returns a new control point with the product of this point with the specified coefficient.- Parameters:
k- the coefficient multiplier.- Returns:
- A new ControlPoint with this*k.
-
divide
public ControlPoint divide(double divisor)
Returns a new control point with this point divided by the specified divisor.- Parameters:
divisor- the divisor.- Returns:
- A new ControlPoint with this / divisor.
-
normValue
public double normValue()
Returns the norm, magnitude, or length value of the vector from the origin to this control point geometric point (square root of the dot product of the origin-to-this-point vector and itself).- Returns:
- The magnitude of the vector from the origin to this control point. geometric point.
-
distance
public double distance(ControlPoint cp)
Return the distance (in homogeneous coordinates) between this control point and another (this treats the weight simply as another dimension).- Parameters:
cp- The control point to find the homogeneous distance to. May not be null.- Returns:
- The homogeneous distance to the specified control point from this one.
-
getBoundsMin
public Point getBoundsMin()
Return the coordinate point representing the minimum bounding box corner (e.g.: min X, min Y, min Z).- Returns:
- The minimum bounding box coordinate for this geometry element.
-
getBoundsMax
public Point getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).- Returns:
- The maximum bounding box coordinate for this geometry element.
-
isValid
public boolean isValid()
Returntrueif this control point contains valid and finite numerical components. A value offalsewill be returned if any of the coordinate values are NaN or Inf (including the weight).- Returns:
- true if this control point contains valid and finite values.
-
getUnit
public javax.measure.unit.Unit<javax.measure.quantity.Length> getUnit()
Returns the unit in which this control point is stated.- Returns:
- The unit in which this control point is stated.
-
to
public ControlPoint to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this control point but stated in the specified unit.- Parameters:
unit- The length unit of the control point to be returned. May not be null.- Returns:
- An equivalent to this control point but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException- if the the input unit is not a length unit.
-
toFloat64Vector
public Float64Vector toFloat64Vector()
Returns the values stored in this control point, with the coordinate points stated in this point's unit and the weight tacked onto the end as a Float64Vector.- Returns:
- A Float64Vector representation of this control point.
-
toArray
public double[] toArray()
Returns the values stored in this control point as a Java array, stated in the currentunitswith the weight tacked onto the end of the array.- Returns:
- A new array with the control point values copied into it with the weight at the end.
-
toArray
public double[] toArray(double[] array)
Returns the values stored in this control point, with the coordinate point stated in the currentunitsand the weight tacked onto the end, stored in the input Java array.- Parameters:
array- An existing array that has at least as many elements as the physical dimension of this point + 1 for the weight.- Returns:
- A reference to the input array after the control point values have been copied over to it.
- See Also:
getPhyDimension()
-
copy
public ControlPoint copy()
Returns a copy of this ControlPoint instanceallocatedby the calling thread (possibly on the stack).- Specified by:
copyin interfacejavolution.lang.ValueType- Returns:
- an identical and independent copy of this point.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a copy of this ControlPoint instanceallocatedby the calling thread (possibly on the stack).- Returns:
- an identical and independent copy of this point.
- Throws:
java.lang.CloneNotSupportedException- Never thrown.
-
equals
public boolean equals(java.lang.Object obj)
Compares this ControlPoint against the specified object for strict equality (same values and same units).- Overrides:
equalsin classjava.lang.Object- 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 classjava.lang.Object- Returns:
- the hash code value.
-
toText
public javolution.text.Text toText()
Returns the text representation of this control point that consists of the the geometry coordinate values followed by the weighting factor. For example:{{10 ft, -3 ft, 4.56 ft}, 1.0}- Returns:
- the text representation of this geometry element.
-
toString
public java.lang.String toString()
Returns the String representation of this control point that consists of the the geometry coordinate values followed by the weighting factor. For example:{{10 ft, -3 ft, 4.56 ft}, 1.0}- Overrides:
toStringin classjava.lang.Object- Returns:
- the text representation of this geometry element.
-
-