Package geomss.geom
Class LineSeg
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<T>
-
- geomss.geom.AbstractCurve<LineSegment>
-
- geomss.geom.LineSegment
-
- geomss.geom.LineSeg
-
- All Implemented Interfaces:
Curve<LineSegment>
,GeomElement<LineSegment>
,ParametricGeometry<LineSegment>
,PointGeometry<LineSegment>
,Transformable<LineSegment>
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,javolution.lang.Immutable
,javolution.lang.Reusable
,javolution.lang.ValueType
,javolution.xml.XMLSerializable
public final class LineSeg extends LineSegment implements javolution.lang.ValueType
A concrete line segment in n-dimensional space.Modified by: Joseph A. Huwaldt
- Version:
- February 17, 2025
- Author:
- Joseph A. Huwaldt Date: January 14, 2012
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class geomss.geom.AbstractCurve
GTOL
-
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LineSeg
copy()
Returns a copy of this LineSeg instanceallocated
by the calling thread (possibly on the stack).LineSeg
copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).boolean
equals(java.lang.Object obj)
Compares this LineSeg against the specified object for strict equality.Parameter<javax.measure.quantity.Length>
getArcLength(double eps)
Return the total arc length of this curve.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 of this geometry element (e.g.: min X, min Y, min Z).GeomVector<javax.measure.quantity.Length>
getDerivativeVector()
Return the dimensional derivative vector for this line segment.Point
getEnd()
Return the end point of the line segment.Point
getRealPoint(double s)
Calculate a point on the curve for the given parametric distance along the curve.java.util.List<Vector<javax.measure.quantity.Length>>
getSDerivatives(double s, int grade)
Calculate all the derivatives from0
tograde
with respect to parametric distance on the curve for the given parametric distance along the curve,d^{grade}p(s)/d^{grade}s
.Point
getStart()
Return the starting point of the line segment.Vector<javax.measure.quantity.Dimensionless>
getUnitVector()
Get a unit direction vector for the line segment.int
hashCode()
Returns the hash code for this parameter.static void
recycle(LineSeg instance)
Recycles aLineSeg
instance immediately (on the stack when executing in aStackContext
).LineSegment
reverse()
Return a new curve that is identical to this one, but with the parameterization reversed.LineSeg
to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns the equivalent to this element but stated in the specified unit.LineSeg
toDimension(int newDim)
Return a copy of this curve converted to the specified number of physical dimensions.static LineSeg
valueOf(Curve lineCrv)
Returns aLineSeg
that represents a straight line between the end points of the input curve.static LineSeg
valueOf(Point p0, GeomVector<javax.measure.quantity.Length> Ldir)
Returns aLineSeg
instance with the specified start point and direction/length vector.static LineSeg
valueOf(Point p0, Point p1)
Returns aLineSeg
instance with the specified end points.-
Methods inherited from class geomss.geom.LineSegment
extractGrid, getArcLength, getCurvature, getLimitPoint, getNumberOfPoints, getPhyDimension, getPointAtArcLength, getTorsion, getTransformed, getUnit, getVariationOfCurvature, gridToTolerance, intersect, intersect, isCircular, isLine, isPlanar, isValid, size, splitAt, toNurbs, toNurbs, toText
-
Methods inherited from class geomss.geom.AbstractCurve
getArcLength, getBinormal, getBinormal, getClosest, getClosest, getClosest, getClosest, getClosest, getClosest, getCurvature, getDerivatives, getEnclosedArea, getFarthest, getFarthest, getFarthest, getParDimension, getPoint, getPoint, getPrincipalNormal, getPrincipalNormal, getRealPoint, getSDerivative, getSDerivatives, getTangencyPoint, getTangent, getTangent, getTorsion, getVariationOfCurvature, intersect, intersect, intersect, isDegenerate, splitAt
-
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, getParDimension, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName
-
-
-
-
Method Detail
-
valueOf
public static LineSeg valueOf(Point p0, Point p1)
Returns aLineSeg
instance with the specified end points. The units of the curve will be the units of the start point.- Parameters:
p0
- The start (beginning) of the line segment. May not be null.p1
- The end of the line segment. May not be null.- Returns:
- A
LineSeg
instance that represents a line between the input points.
-
valueOf
public static LineSeg valueOf(Point p0, GeomVector<javax.measure.quantity.Length> Ldir)
Returns aLineSeg
instance with the specified start point and direction/length vector. The units of the curve will be the units of the start point.- Parameters:
p0
- The start (beginning) of the line segment. May not be null.Ldir
- The vector defining the direction and length of the line segment. May not be null.- Returns:
- A line segment from the input point in the direction and length of the input vector.
-
valueOf
public static LineSeg valueOf(Curve lineCrv)
Returns aLineSeg
that represents a straight line between the end points of the input curve. WARNING: No check is made that the input curve is truly a straight line. The end points of the input curve are simply used to define a straight line segment.- Parameters:
lineCrv
- A curve from which the end points will be used to define a line segment. May not be null.- Returns:
- The line segment between the end points of the input curve.
- See Also:
Curve.isLine(jahuwaldt.js.param.Parameter<javax.measure.quantity.Length>)
-
recycle
public static void recycle(LineSeg instance)
Recycles aLineSeg
instance immediately (on the stack when executing in aStackContext
).- Parameters:
instance
- The instance to recycle immediately.
-
getStart
public Point getStart()
Return the starting point of the line segment.- Specified by:
getStart
in classLineSegment
- Returns:
- The starting point for this line segment.
-
getEnd
public Point getEnd()
Return the end point of the line segment.- Specified by:
getEnd
in classLineSegment
- Returns:
- The end point of this line segment.
-
getUnitVector
public Vector<javax.measure.quantity.Dimensionless> getUnitVector()
Get a unit direction vector for the line segment.- Specified by:
getUnitVector
in classLineSegment
- Returns:
- A unit vector indicating the direction of this line segment.
-
getDerivativeVector
public GeomVector<javax.measure.quantity.Length> getDerivativeVector()
Return the dimensional derivative vector for this line segment. The length of this vector is the length of the line segment, the origin is at the start point and the end of the vector is the line end.- Specified by:
getDerivativeVector
in classLineSegment
- Returns:
- The dimensional derivative vector for this line segment.
-
getRealPoint
public Point getRealPoint(double s)
Calculate a point on the curve for the given parametric distance along the curve.- Specified by:
getRealPoint
in interfaceCurve<LineSegment>
- Parameters:
s
- parametric distance to calculate a point for (0.0 to 1.0 inclusive).- Returns:
- the calculated point
-
getSDerivatives
public java.util.List<Vector<javax.measure.quantity.Length>> getSDerivatives(double s, int grade)
Calculate all the derivatives from0
tograde
with respect to parametric distance on the curve for the given parametric distance along the curve,d^{grade}p(s)/d^{grade}s
.Example:
1st derivative (grade = 1), this returns[p(s), dp(s)/ds]
;
2nd derivative (grade = 2), this returns[p(s), dp(s)/ds, d^2p(s)/d^2s]
; etc.- Specified by:
getSDerivatives
in interfaceCurve<LineSegment>
- Parameters:
s
- Parametric distance to calculate derivatives for (0.0 to 1.0 inclusive).grade
- The maximum grade to calculate the derivatives for (1=1st derivative, 2=2nd derivative, etc)- Returns:
- A list of derivatives up to the specified grade of the curve at the specified parametric position.
- Throws:
java.lang.IllegalArgumentException
- if the grade is < 0.
-
getArcLength
public Parameter<javax.measure.quantity.Length> getArcLength(double eps)
Return the total arc length of this curve.- Specified by:
getArcLength
in interfaceCurve<LineSegment>
- Overrides:
getArcLength
in classAbstractCurve<LineSegment>
- Parameters:
eps
- The desired fractional accuracy on the arc-length. For this curve type, this parameter is ignored and the exact arc length is always returned.- Returns:
- The total arc length of the curve.
-
reverse
public LineSegment reverse()
Return a new curve that is identical to this one, but with the parameterization reversed.- Specified by:
reverse
in interfaceCurve<LineSegment>
- Returns:
- A new curve that is identical to this one, but with the parameterization reversed.
-
getBoundsMin
public Point getBoundsMin()
Return the coordinate point representing the minimum bounding box corner of this geometry element (e.g.: min X, min Y, min Z).- Specified by:
getBoundsMin
in interfaceGeomElement<LineSegment>
- 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<LineSegment>
- Returns:
- The maximum bounding box coordinate for this geometry element.
-
toDimension
public LineSeg toDimension(int newDim)
Return a copy of this curve 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.- Specified by:
toDimension
in interfaceCurve<LineSegment>
- Specified by:
toDimension
in interfaceGeomElement<LineSegment>
- Specified by:
toDimension
in interfaceParametricGeometry<LineSegment>
- Parameters:
newDim
- The dimension of the curve to return.- Returns:
- This curve converted to the new dimensions.
-
to
public LineSeg to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this element but stated in the specified unit.- Specified by:
to
in interfaceCurve<LineSegment>
- Specified by:
to
in interfaceGeomElement<LineSegment>
- Specified by:
to
in interfaceParametricGeometry<LineSegment>
- Specified by:
to
in interfacePointGeometry<LineSegment>
- Specified by:
to
in classLineSegment
- Parameters:
unit
- the length unit of the element to be returned. May not be null.- Returns:
- an equivalent to this element but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException
- if the the input unit is not a length unit.
-
copy
public LineSeg copy()
Returns a copy of this LineSeg instanceallocated
by the calling thread (possibly on the stack).- Specified by:
copy
in interfaceCurve<LineSegment>
- Specified by:
copy
in interfaceGeomElement<LineSegment>
- Specified by:
copy
in interfaceParametricGeometry<LineSegment>
- Specified by:
copy
in interfacejavolution.lang.ValueType
- Returns:
- an identical and independent copy of this line segment.
-
copyToReal
public LineSeg copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Specified by:
copyToReal
in interfaceCurve<LineSegment>
- Specified by:
copyToReal
in interfaceGeomElement<LineSegment>
- Returns:
- A copy of this object with any transformations or subranges removed (applied).
-
equals
public boolean equals(java.lang.Object obj)
Compares this LineSeg against the specified object for strict equality.- Overrides:
equals
in classAbstractGeomElement<LineSegment>
- Parameters:
obj
- the object to compare with.- Returns:
true
if this LineSeg is identical to that LineSeg;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code for this parameter.- Overrides:
hashCode
in classAbstractGeomElement<LineSegment>
- Returns:
- the hash code value.
-
-