Package geomss.geom
Class GeomPoint
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<GeomPoint>
-
- geomss.geom.GeomPoint
-
- 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
- Direct Known Subclasses:
GeomPointTrans
,MutablePoint
,Point
,SubrangePoint
public abstract class GeomPoint extends AbstractGeomElement<GeomPoint> implements PointGeometry<GeomPoint>, Transformable<GeomPoint>, XYPoint
A container that holds the coordinates of a point in n-dimensional space.* Modified by: Joseph A. Huwaldt
- Version:
- February 5, 2018
- Author:
- Joseph A. Huwaldt, Date: December 11, 1999
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
W
Constant used to identify the W or 4th coordinate.static int
X
Constant used to identify the X or 1st coordinate.static int
Y
Constant used to identify the Y or 2nd coordinate.static int
Z
Constant used to identify the Z or 3rd coordinate.-
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES
-
-
Constructor Summary
Constructors Constructor Description GeomPoint()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract GeomPoint
copy()
Returns a copy of thisGeomPoint
instanceallocated
by the calling thread (possibly on the stack).abstract Point
copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).Parameter<javax.measure.quantity.Length>
distance(GeomPoint that)
Return the Euclidian distance between this point and the one specified.Parameter<javax.measure.quantity.Area>
distanceSq(GeomPoint that)
Return the square of the Euclidian distance between this point and the one specified.double
distanceSqValue(GeomPoint that)
Return the Euclidian distance squared between this point and the one specified as adouble
.double
distanceValue(GeomPoint that)
Return the Euclidian distance between this point and the one specified as adouble
.Point
divide(double divisor)
Returns this point with each element divided by the specified divisor.Point
divide(Parameter<javax.measure.quantity.Dimensionless> divisor)
Returns this point with each element divided by the specified dimensionless Parameter.Parameter<javax.measure.quantity.Length>
get(int i)
Returns the value of a Parameter from this point.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).GeomPoint
getLimitPoint(int dim, boolean max, double tol)
Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this geometry element.int
getNumberOfPoints()
Return the total number of points in this geometry element.int
getParDimension()
Returns the number of parametric dimensions of the geometry element.GeomPointTrans
getTransformed(GTransform transform)
Returns transformed version of this element.abstract double
getValue(int i)
Returns the value of a coordinate in this point as adouble
, stated in this point'sunit
.abstract 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.double
getX()
Return the X-coordinate of this point as adouble
, stated in this point'sunit
.double
getY()
Return the Y-coordinate of this point as adouble
, stated in this point'sunit
.double
getZ()
Return the Z-coordinate of this point as adouble
, stated in this point'sunit
.abstract Point
immutable()
Return an immutable version of this point.boolean
isApproxEqual(GeomPoint obj)
Compares this point against the specified point for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance).boolean
isApproxEqual(GeomPoint obj, Parameter<javax.measure.quantity.Length> tol)
Compares this point against the specified point for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance).boolean
isValid()
Returntrue
if this point contains valid and finite numerical components.Point
max(GeomPoint that)
Returns a point consisting of the maximum value in each dimension between this point and the input point.Point
min(GeomPoint that)
Returns a point consisting of the minimum value in each dimension between this point and the input point.abstract Point
minus(GeomPoint that)
Returns the difference between this point and the one specified.abstract Point
minus(Parameter<javax.measure.quantity.Length> that)
Subtracts the specified parameter from each component of this point.Parameter<javax.measure.quantity.Length>
norm()
Returns the Euclidian norm, magnitude, or length of the vector from the origin to this point (square root of the dot product of the origin-to-this-point vector and itself).Parameter<javax.measure.quantity.Area>
normSq()
Returns the square of the Euclidean norm, magnitude, or length of the vector from the origin to this point (the dot product of the origin-to-this-point vector and itself).abstract 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).double
normValue()
Returns thenorm()
, magnitude, or length value of the vector from the origin to this point (square root of the dot product of the origin-to-this-point vector and itself).abstract Point
opposite()
Returns the negation of this point (all the values of each dimension negated).abstract Point
plus(GeomPoint that)
Returns the sum of this point with the one specified.abstract Point
plus(Parameter<javax.measure.quantity.Length> that)
Adds the specified parameter to each component of this point.int
size()
Returns the number of child-elements that make up this geometry element.abstract Point
times(double k)
Returns the product of this point with the specified coefficient.Point
times(Parameter<javax.measure.quantity.Dimensionless> k)
Returns the product of this point with the specified dimensionless Parameter.double[]
toArray()
Returns the values stored in this point as a Java array, stated in the currentunits
.double[]
toArray(double[] array)
Returns the values stored in this point, stated in the currentunits
stored in the input Java array.abstract Float64Vector
toFloat64Vector()
Returns the values stored in this point, stated in the currentunits
, as a Float64Vector.Vector<javax.measure.quantity.Length>
toGeomVector()
Returns aGeomVector
representation of this point.ParameterVector<javax.measure.quantity.Length>
toParameterVector()
Returns a ParameterVector representation of this point.javolution.text.Text
toText()
Returns the text representation of this geometry element that consists of the name followed by the coordinate values.Vector3D<javax.measure.quantity.Length>
toVector3D()
Returns a Vector3D representation of this point if possible.-
Methods inherited from class geomss.geom.AbstractGeomElement
addChangeListener, clone, compareTo, equals, getAllUserData, getID, getName, getUserData, hashCode, putAllUserData, putUserData, removeChangeListener, removeUserData, reset, setName, toString
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getID, getName, getPhyDimension, getUnit, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, toDimension
-
Methods inherited from interface geomss.geom.PointGeometry
to
-
-
-
-
Field Detail
-
X
public static final int X
Constant used to identify the X or 1st coordinate.- See Also:
- Constant Field Values
-
Y
public static final int Y
Constant used to identify the Y or 2nd coordinate.- See Also:
- Constant Field Values
-
Z
public static final int Z
Constant used to identify the Z or 3rd coordinate.- See Also:
- Constant Field Values
-
W
public static final int W
Constant used to identify the W or 4th coordinate.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GeomPoint
public GeomPoint()
-
-
Method Detail
-
immutable
public abstract Point immutable()
Return an immutable version of this point.- Returns:
- an immutable version of this point.
-
size
public int size()
Returns the number of child-elements that make up this geometry element. This implementation always returns 0 as a GeomPoint is not made up of any other elements.- Specified by:
size
in interfaceGeomElement<GeomPoint>
- Returns:
- The number of child-elements that make up this geometry element.
-
getParDimension
public int getParDimension()
Returns the number of parametric dimensions of the geometry element. This implementation always returns 0 as a GeomPoint is not parametric.- Specified by:
getParDimension
in interfaceGeomElement<GeomPoint>
- Returns:
- The number of parametric dimensions of this geometry element.
-
get
public Parameter<javax.measure.quantity.Length> get(int i)
Returns the value of a Parameter from this point.- Parameters:
i
- the dimension index.- Returns:
- the value of the parameter at
i
. - Throws:
java.lang.IndexOutOfBoundsException
-(i < 0) || (i ≥ getPhyDimension())
-
getValue
public abstract double getValue(int i)
Returns the value of a coordinate in this point as adouble
, stated in this point'sunit
.- Parameters:
i
- the dimension index.- Returns:
- the value of the Parameter at
i
. - Throws:
java.lang.IndexOutOfBoundsException
-(i < 0) || (i ≥ getPhyDimension())
-
getValue
public abstract 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.- Parameters:
i
- the dimension index.unit
- the unit to return the value in. May not be null.- Returns:
- the value of the Parameter at
i
in the specified unit. - Throws:
java.lang.IndexOutOfBoundsException
-(i < 0) || (i ≥ dimension())
-
getX
public double getX()
Return the X-coordinate of this point as adouble
, stated in this point'sunit
.
-
getY
public double getY()
Return the Y-coordinate of this point as adouble
, stated in this point'sunit
.
-
getZ
public double getZ()
Return the Z-coordinate of this point as adouble
, stated in this point'sunit
.- Returns:
- the value of the Z-coordinate in the current units.
-
normSqValue
public abstract 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 callingnormValue
if the squared value is all that is needed.- Returns:
this.normSq().getValue()
.- See Also:
normValue()
-
normSq
public Parameter<javax.measure.quantity.Area> normSq()
Returns the square of the Euclidean norm, magnitude, or length 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 callingnormValue
if the squared value is all that is needed.- Returns:
this · this
.- See Also:
norm()
-
normValue
public double normValue()
Returns thenorm()
, magnitude, or length value of the vector from the origin to this point (square root of the dot product of the origin-to-this-point vector and itself).- Returns:
this.norm().doubleValue()
.- See Also:
normSqValue()
-
norm
public Parameter<javax.measure.quantity.Length> norm()
Returns the Euclidian norm, magnitude, or length of the vector from the origin to this point (square root of the dot product of the origin-to-this-point vector and itself).- Returns:
sqrt(this · this)
.- See Also:
normValue()
-
plus
public abstract 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.- Parameters:
that
- the point to be added. May not be null.- Returns:
this + that
.- Throws:
DimensionException
- if point dimensions are different.
-
plus
public abstract 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.- Parameters:
that
- the parameter to be added to each component of this point. May not be null.- Returns:
this + that
.
-
minus
public abstract 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.- 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 abstract 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.- Parameters:
that
- the parameter to be subtracted from each component of this point. May not be null.- Returns:
this - that
.
-
opposite
public abstract Point opposite()
Returns the negation of this point (all the values of each dimension negated).- Returns:
-this
-
times
public abstract Point times(double k)
Returns the product of this point with the specified coefficient.- Parameters:
k
- the coefficient multiplier.- Returns:
this · k
-
times
public Point times(Parameter<javax.measure.quantity.Dimensionless> k)
Returns the product of this point with the specified dimensionless Parameter.- Parameters:
k
- the dimensionless Parameter multiplier. May not be null.- Returns:
this · k
-
divide
public Point divide(double divisor)
Returns this point with each element divided by the specified divisor.- Parameters:
divisor
- the divisor.- Returns:
this / divisor
.
-
divide
public Point divide(Parameter<javax.measure.quantity.Dimensionless> divisor)
Returns this point with each element divided by the specified dimensionless Parameter.- Parameters:
divisor
- the dimensionless Parameter divisor. May not be null.- Returns:
this / divisor
.
-
distanceSq
public Parameter<javax.measure.quantity.Area> distanceSq(GeomPoint that)
Return the square of the Euclidian distance between this point and the one specified. This is slightly faster than callingdistance
if the squared value is all that you need.- Parameters:
that
- The point to determine the distance squared from this point to. May not be null.- Returns:
- the distance squared from this point to the one specified.
- See Also:
distance(geomss.geom.GeomPoint)
-
distanceSqValue
public double distanceSqValue(GeomPoint that)
Return the Euclidian distance squared between this point and the one specified as adouble
. This is slightly faster than callingdistance
if the squared value is all that you need.- Parameters:
that
- The point to determine the distance squared from this point to. May not be null.- Returns:
- the distance squared from this point to the one specified.
- See Also:
distanceValue(geomss.geom.GeomPoint)
-
distance
public Parameter<javax.measure.quantity.Length> distance(GeomPoint that)
Return the Euclidian distance between this point and the one specified.- Parameters:
that
- The point to determine the distance from this point to. May not be null.- Returns:
- the distance from this point to the one specified.
- See Also:
distanceSq(geomss.geom.GeomPoint)
-
distanceValue
public double distanceValue(GeomPoint that)
Return the Euclidian distance between this point and the one specified as adouble
.- Parameters:
that
- The point to determine the distance from this point to. May not be null.- Returns:
- the distance from this point to the one specified.
- See Also:
distanceSqValue(geomss.geom.GeomPoint)
-
min
public Point min(GeomPoint that)
Returns a point consisting of the minimum value in each dimension between this point and the input point. This is used to find points that bound a geometry.- Parameters:
that
- The point being compared with this one for minimum values in each dimension. May not be null.- Returns:
- A point consisting of the minimum value in each dimension between this point and the input point.
-
max
public Point max(GeomPoint that)
Returns a point consisting of the maximum value in each dimension between this point and the input point. This is used to find points that bound a geometry.- Parameters:
that
- The point being compared with this one for maximum values in each dimension. May not be null.- Returns:
- A point consisting of the maximum value in each dimension between this point and the input point.
-
getBoundsMin
public Point getBoundsMin()
Return the coordinate point representing the minimum bounding box corner (e.g.: min X, min Y, min Z).- Specified by:
getBoundsMin
in interfaceGeomElement<GeomPoint>
- 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).- Specified by:
getBoundsMax
in interfaceGeomElement<GeomPoint>
- Returns:
- The maximum bounding box coordinate for this geometry element.
-
getLimitPoint
public GeomPoint getLimitPoint(int dim, boolean max, double tol)
Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this geometry element. This implementation always returns this point's coordinate.- Specified by:
getLimitPoint
in interfaceGeomElement<GeomPoint>
- Parameters:
dim
- An index indicating the dimension to find the min/max point for (0=X, 1=Y, 2=Z, etc).max
- Set totrue
to return the maximum value,false
to return the minimum.tol
- Fractional tolerance to refine the min/max point position to if necessary.- Returns:
- The point found on this element that is the min or max in the specified coordinate direction.
- See Also:
getBoundsMin()
,getBoundsMax()
-
getNumberOfPoints
public int getNumberOfPoints()
Return the total number of points in this geometry element. This implementation always returns 1.- Specified by:
getNumberOfPoints
in interfacePointGeometry<GeomPoint>
- Returns:
- The total number of points in this geometry element.
-
isValid
public boolean isValid()
Returntrue
if this point contains valid and finite numerical components. A value offalse
will be returned if any of the coordinate values are NaN or Inf.- Specified by:
isValid
in interfaceGeomElement<GeomPoint>
- Returns:
- true if this geometry element contains valid and finite data.
-
copyToReal
public abstract Point copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Specified by:
copyToReal
in interfaceGeomElement<GeomPoint>
- Returns:
- A copy of this object with any transformations removed (applied).
-
copy
public abstract GeomPoint copy()
Returns a copy of thisGeomPoint
instanceallocated
by the calling thread (possibly on the stack).- Specified by:
copy
in interfaceGeomElement<GeomPoint>
- Returns:
- an identical and independent copy of this point.
-
toVector3D
public Vector3D<javax.measure.quantity.Length> toVector3D()
Returns a Vector3D representation of this point if possible.- Returns:
- A Vector3D that is equivalent to this point
- Throws:
DimensionException
- if this point has any number of dimensions other than 3.
-
toParameterVector
public ParameterVector<javax.measure.quantity.Length> toParameterVector()
Returns a ParameterVector representation of this point.- Returns:
- A ParameterVector that is equivalent to this point
-
toGeomVector
public Vector<javax.measure.quantity.Length> toGeomVector()
Returns aGeomVector
representation of this point.- Returns:
- A GeomVector that is equivalent to this point
-
toFloat64Vector
public abstract Float64Vector toFloat64Vector()
Returns the values stored in this point, stated in the currentunits
, as a Float64Vector.- Returns:
- A Float64Vector containing the values stored in this point in the current units.
-
toArray
public double[] toArray()
Returns the values stored in this point as a Java array, stated in the currentunits
.- Returns:
- A new array with the point values copied into it.
-
toArray
public double[] toArray(double[] array)
Returns the values stored in this point, stated in the currentunits
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.- Returns:
- A reference to the input array after the point values have been copied over to it.
- See Also:
GeomElement.getPhyDimension()
-
getTransformed
public GeomPointTrans getTransformed(GTransform transform)
Returns transformed version of this element. The returned object implementsGeomTransform
and contains this element as a child.- Specified by:
getTransformed
in interfaceTransformable<GeomPoint>
- Parameters:
transform
- The transformation to apply to this geometry. May not be null.- Returns:
- A new triangle that is identical to this one with the specified transformation applied.
- Throws:
DimensionException
- if this point is not 3D.
-
toText
public javolution.text.Text toText()
Returns the text representation of this geometry element that consists of the name followed by the coordinate values. For example:{aPoint = {10 ft, -3 ft, 4.56 ft}}
If there is no name, then the output looks like this:{10 ft, -3 ft, 4.56 ft}
- Specified by:
toText
in interfaceGeomElement<GeomPoint>
- Overrides:
toText
in classAbstractGeomElement<GeomPoint>
- Returns:
- the text representation of this geometry element.
-
isApproxEqual
public boolean isApproxEqual(GeomPoint obj)
Compares this point against the specified point for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance).- Parameters:
obj
- The GeomPoint object to compare with.- Returns:
true
if this point is approximately identical to that point;false
otherwise.
-
isApproxEqual
public boolean isApproxEqual(GeomPoint obj, Parameter<javax.measure.quantity.Length> tol)
Compares this point against the specified point for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance).- Parameters:
obj
- The GeomPoint object to compare with.tol
- The amount use to define approximate equality. Ifnull
is passed, exact numerical equality will be required.- Returns:
true
if this point is approximately identical to that point;false
otherwise.
-
-