public class ControlPoint extends java.lang.Object implements java.lang.Cloneable, javolution.xml.XMLSerializable, javolution.lang.ValueType
Modified by: Joseph A. Huwaldt
Modifier and Type | Method and Description |
---|---|
ControlPoint |
applyWeight()
Returns a new ControlPoint with the geometric point portion of this control point
multiplied by the weight.
|
ControlPoint |
changeWeight(double value)
Return a new control point that is identical to this one, but with the weight
changed to the specified value.
|
java.lang.Object |
clone()
Returns a copy of this ControlPoint instance
allocated by the calling thread
(possibly on the stack). |
ControlPoint |
copy()
Returns a copy of this ControlPoint instance
allocated by the calling thread
(possibly on the stack). |
double |
distance(ControlPoint cp)
Return the distance (in homogeneous coordinates) between this control point and
another (this treats the weight simply as another dimension).
|
ControlPoint |
divide(double divisor)
Returns a new control point with this point divided by the specified divisor.
|
boolean |
equals(java.lang.Object obj)
Compares this ControlPoint against the specified object for strict equality (same
values and same units).
|
Point |
getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max
X, max Y, max Z).
|
Point |
getBoundsMin()
Return the coordinate point representing the minimum bounding box corner (e.g.: min
X, min Y, min Z).
|
ControlPoint |
getHomogeneous()
Return a copy of this control point with the values made homogeneous (all the
geometric point values are divided by the weight).
|
int |
getPhyDimension()
Returns the number of physical dimensions of the geometry element.
|
Point |
getPoint()
Return the Point representation of this ControlPoint.
|
Unit<Length> |
getUnit()
Returns the unit in which this control point is stated.
|
double |
getValue(int i)
Returns the value of the Parameter in this point as a
double , stated
in this point's unit. |
double |
getWeight()
Return the weight associated with this control point.
|
int |
hashCode()
Returns the hash code for this parameter.
|
boolean |
isValid()
Return
true if this control point contains valid and finite numerical
components. |
ControlPoint |
minus(ControlPoint that)
Returns a new control point with the difference between this point with the one
specified.
|
static ControlPoint |
newInstance(int dim)
Returns a
ControlPoint instance of the specified dimension with zero meters
for each coordinate value and zero weight. |
static ControlPoint |
newInstance(int dim,
Unit<Length> unit)
Returns a
ControlPoint instance of the specified dimension and units with
zero for each coordinate value and zero weight. |
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).
|
ControlPoint |
plus(ControlPoint that)
Returns a new control point with the sum of this point with the one specified.
|
ControlPoint |
times(double k)
Returns a new control point with the product of this point with the specified
coefficient.
|
ControlPoint |
to(Unit<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
current
units with 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 current
units and the weight tacked onto the end, stored in the input Java array. |
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.
|
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.
|
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.
|
static ControlPoint |
valueOf(ControlPoint point)
Returns a
ControlPoint instance containing the specified ControlPoint's
data. |
static ControlPoint |
valueOf(double x,
double y,
double w)
Returns a 2D
ControlPoint instance holding the specified
double values stated in meters. |
static ControlPoint |
valueOf(double x,
double y,
double z,
double w)
Returns a 3D
ControlPoint instance holding the specified
double values stated in meters. |
static ControlPoint |
valueOf(double x,
double y,
double z,
double w,
Unit<Length> unit)
Returns a 3D
ControlPoint instance holding the specified
double values stated in the specified units. |
static ControlPoint |
valueOf(double x,
double y,
double w,
Unit<Length> unit)
Returns a 2D
ControlPoint instance holding the specified
double values stated in the specified units. |
static ControlPoint |
valueOf(Point point,
double w)
Returns a
ControlPoint instance containing the specified Point's data. |
static ControlPoint |
valueOf(Unit<Length> unit,
double[] vector)
Returns a
ControlPoint instance holding the specified double
values stated in the specified units. |
static ControlPoint |
valueOf(Vector<Float64> vector,
double w,
Unit<Length> unit)
Returns a
ControlPoint instance holding the specified Float64
values plus weight stated in the specified units. |
static ControlPoint |
valueOf(Vector<Float64> vector,
Unit<Length> unit)
Returns a
ControlPoint instance holding the specified Float64
values stated in the specified units. |
public static ControlPoint newInstance(int dim)
ControlPoint
instance of the specified dimension with zero meters
for each coordinate value and zero weight.dim
- the physical dimension of the point to create (not including the
weighting factor).public static ControlPoint newInstance(int dim, Unit<Length> unit)
ControlPoint
instance of the specified dimension and units with
zero for each coordinate value and zero weight.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.public static ControlPoint valueOf(double x, double y, double w)
ControlPoint
instance holding the specified
double
values stated in meters.x
- the x value stated in meters.y
- the y value stated in meters.w
- the weighting factor for the control point.public static ControlPoint valueOf(double x, double y, double w, Unit<Length> unit)
ControlPoint
instance holding the specified
double
values stated in the specified units.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.public static ControlPoint valueOf(double x, double y, double z, double w)
ControlPoint
instance holding the specified
double
values stated in meters.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.public static ControlPoint valueOf(double x, double y, double z, double w, Unit<Length> unit)
ControlPoint
instance holding the specified
double
values stated in the specified units.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.public static ControlPoint valueOf(Vector<Float64> vector, Unit<Length> unit)
ControlPoint
instance holding the specified Float64
values stated in the specified units.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.public static ControlPoint valueOf(Vector<Float64> vector, double w, Unit<Length> unit)
ControlPoint
instance holding the specified Float64
values plus weight stated in the specified units.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.public static ControlPoint valueOf(Unit<Length> unit, double[] vector)
ControlPoint
instance holding the specified double
values stated in the specified units.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.public static ControlPoint valueOf(Point point, double w)
ControlPoint
instance containing the specified Point's data.point
- the Point to be copied into a new ControlPoint. May not be null.w
- the weighting factor for the control point.public static ControlPoint valueOf(ControlPoint point)
ControlPoint
instance containing the specified ControlPoint's
data.point
- the ControlPoint to be copied into a new ControlPoint. May not be
null.public int getPhyDimension()
public double getValue(int i)
double
, stated
in this point's unit.i
- the dimension index.i
.java.lang.IndexOutOfBoundsException
- (i < 0) || (i >
getPhyDimension() - 1)
public Point getPoint()
public double getWeight()
public ControlPoint changeWeight(double value)
value
- The new weighting factor.public ControlPoint getHomogeneous()
public ControlPoint applyWeight()
public ControlPoint plus(ControlPoint that)
that
- the point to be added to this one. May not be null.DimensionException
- if point dimensions are different.public ControlPoint minus(ControlPoint that)
that
- the point to be subtracted from this one. May not be null.DimensionException
- if point dimensions are different.public ControlPoint times(double k)
k
- the coefficient multiplier.public ControlPoint divide(double divisor)
divisor
- the divisor.public double normValue()
public double distance(ControlPoint cp)
cp
- The control point to find the homogeneous distance to. May not be null.public Point getBoundsMin()
public Point getBoundsMax()
public boolean isValid()
true
if this control point contains valid and finite numerical
components. A value of false
will be returned if any of the coordinate
values are NaN or Inf (including the weight).public Unit<Length> getUnit()
public ControlPoint to(Unit<Length> unit) throws ConversionException
unit
- The length unit of the control point to be returned. May not be null.ConversionException
- if the the input unit is not a length unit.public Float64Vector toFloat64Vector()
public double[] toArray()
units
with the weight tacked onto the end of the array.public double[] toArray(double[] array)
units
and the weight tacked onto the end, stored in the input Java array.array
- An existing array that has at least as many elements as the physical
dimension of this point + 1 for the weight.getPhyDimension()
public ControlPoint copy()
allocated
by the calling thread
(possibly on the stack).copy
in interface javolution.lang.ValueType
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
allocated
by the calling thread
(possibly on the stack).clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- Never thrown.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare with.true
if this point is identical to that point;
false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
public javolution.text.Text toText()
{{10 ft, -3 ft, 4.56 ft}, 1.0}
public java.lang.String toString()
{{10 ft, -3 ft, 4.56 ft}, 1.0}
toString
in class java.lang.Object