Package geomss.geom
Class LineSegment
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<T>
-
- geomss.geom.AbstractCurve<LineSegment>
-
- geomss.geom.LineSegment
-
- All Implemented Interfaces:
Curve<LineSegment>,GeomElement<LineSegment>,ParametricGeometry<LineSegment>,PointGeometry<LineSegment>,Transformable<LineSegment>,java.io.Serializable,java.lang.Cloneable,java.lang.Comparable,javolution.lang.Reusable,javolution.xml.XMLSerializable
- Direct Known Subclasses:
LineSeg,LineSegTrans
public abstract class LineSegment extends AbstractCurve<LineSegment> implements PointGeometry<LineSegment>
The interface and implementation in common to all line segments in n-dimensional space.Modified by: Joseph A. Huwaldt
- Version:
- April 3, 2018
- 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
-
-
Constructor Summary
Constructors Constructor Description LineSegment()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PointString<SubrangePoint>extractGrid(GridRule gridRule, java.util.List<java.lang.Double> spacing)Return a string of points that are gridded onto the curve using the specified spacing and gridding rule.Parameter<javax.measure.quantity.Length>getArcLength(double s1, double s2, double eps)Return the arc length of a segment of this curve.ParametergetCurvature(double s)Return the curvature (kappa = 1/rho; where rho = the radius of curvature) of the curve at the parametric positions.abstract GeomVector<javax.measure.quantity.Length>getDerivativeVector()Return the dimensional direction/derivative vector for this line segment.abstract GeomPointgetEnd()Return the end point of the line segment.SubrangePointgetLimitPoint(int dim, boolean max, double tol)Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this curve.intgetNumberOfPoints()Return the total number of points in this geometry element.intgetPhyDimension()Returns the number of physical dimensions of the geometry element.SubrangePointgetPointAtArcLength(Parameter<javax.measure.quantity.Length> targetArcLength, double tol)Return a subrange point at the position on the curve with the specified arc-length.abstract GeomPointgetStart()Return the starting point of the line segment.ParametergetTorsion(double s)Return the torsion of the curve at the parametric positions.LineSegTransgetTransformed(GTransform transform)Returns transformed version of this element.javax.measure.unit.Unit<javax.measure.quantity.Length>getUnit()Returns the unit in which this curve is stated.abstract GeomVector<javax.measure.quantity.Dimensionless>getUnitVector()Get unit direction vector for the line segment.ParametergetVariationOfCurvature(double s)Return the variation of curvature or rate of change of curvature (VOC or dKappa(s)/ds) at the parametric positions.PointString<SubrangePoint>gridToTolerance(Parameter<javax.measure.quantity.Length> tol)Return a string of points that are gridded onto the curve with the number of points and spacing chosen to result in straight line segments between the points that have mid-points that are all within the specified tolerance of this curve.PointString<SubrangePoint>intersect(GeomPlane plane, double tol)Return the intersection between a plane and this curve.GeomList<PointString<SubrangePoint>>intersect(LineSegment line, Parameter<javax.measure.quantity.Length> tol)Return the intersection between a line segment and this curve.booleanisCircular(Parameter<javax.measure.quantity.Length> tol)Returnstrueif this curve is a circular arc to within the specified tolerance.booleanisLine(Parameter<javax.measure.quantity.Length> tol)Returnstrueif this curve is a line to within the specified tolerance.booleanisPlanar(Parameter<javax.measure.quantity.Length> tol)Returntrueif this curve is planar orfalseif it is not.booleanisValid()Returntrueif this LineSegment contains valid and finite numerical components.intsize()Returns the number of child-elements that make up this geometry element.GeomList<LineSegment>splitAt(double s)Split this curve at the specified parametric position returning a list containing two curves (a lower curve with smaller parametric positions than "s" and an upper curve with larger parametric positions).abstract LineSegmentto(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns the equivalent to this LineSegment object but stated in the specified unit.NurbsCurvetoNurbs()Return a NURBS curve representation of this line segment.NurbsCurvetoNurbs(Parameter<javax.measure.quantity.Length> tol)Return a NURBS curve representation of this line segment.javolution.text.TexttoText()Returns the text representation of this geometry element that consists of the name followed by the start and end points.-
Methods inherited from class geomss.geom.AbstractCurve
getArcLength, 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, equals, getAllUserData, getID, getName, getUserData, hashCode, putAllUserData, putUserData, removeChangeListener, removeUserData, reset, setName, toString
-
Methods inherited from interface geomss.geom.Curve
copy, copyToReal, getRealPoint, getSDerivatives, reverse, toDimension
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getBoundsMax, getBoundsMin, getID, getName, getParDimension, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName
-
-
-
-
Constructor Detail
-
LineSegment
public LineSegment()
-
-
Method Detail
-
getStart
public abstract GeomPoint getStart()
Return the starting point of the line segment.- Returns:
- The starting point for this line segment.
-
getEnd
public abstract GeomPoint getEnd()
Return the end point of the line segment.- Returns:
- The end point of this line segment.
-
getUnitVector
public abstract GeomVector<javax.measure.quantity.Dimensionless> getUnitVector()
Get unit direction vector for the line segment.- Returns:
- A unit vector indicating the direction of this line segment.
-
getDerivativeVector
public abstract GeomVector<javax.measure.quantity.Length> getDerivativeVector()
Return the dimensional direction/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.- Returns:
- The dimensional derivative vector for this line segment.
-
size
public int size()
Returns the number of child-elements that make up this geometry element. This implementation always returns 2 as a LineSegment has two end points.- Specified by:
sizein interfaceGeomElement<LineSegment>- Returns:
- The number of points in this line segment (always returns 2).
-
getPhyDimension
public int getPhyDimension()
Returns the number of physical dimensions of the geometry element.- Specified by:
getPhyDimensionin interfaceGeomElement<LineSegment>- Returns:
- The number of physical dimensions of this geometry element.
-
getNumberOfPoints
public int getNumberOfPoints()
Return the total number of points in this geometry element.- Specified by:
getNumberOfPointsin interfacePointGeometry<LineSegment>- Returns:
- Always returns 2.
-
splitAt
public GeomList<LineSegment> splitAt(double s)
Split this curve at the specified parametric position returning a list containing two curves (a lower curve with smaller parametric positions than "s" and an upper curve with larger parametric positions).- Specified by:
splitAtin interfaceCurve<LineSegment>- Parameters:
s- The parametric position where this curve should be split (must not be 0 or 1!).- Returns:
- A list containing two curves: 0 == the lower curve, 1 == the upper curve.
-
getCurvature
public Parameter getCurvature(double s)
Return the curvature (kappa = 1/rho; where rho = the radius of curvature) of the curve at the parametric positions. This implementation always returns zero.- Specified by:
getCurvaturein interfaceCurve<LineSegment>- Overrides:
getCurvaturein classAbstractCurve<LineSegment>- Parameters:
s- Parametric distance to calculate the curvature for (0.0 to 1.0 inclusive).- Returns:
- The curvature of the curve at the specified parametric position in units of 1/Length.
-
getVariationOfCurvature
public Parameter getVariationOfCurvature(double s)
Return the variation of curvature or rate of change of curvature (VOC or dKappa(s)/ds) at the parametric positions. The VOC for a line segment is always zero.- Specified by:
getVariationOfCurvaturein interfaceCurve<LineSegment>- Overrides:
getVariationOfCurvaturein classAbstractCurve<LineSegment>- Parameters:
s- Parametric distance to calculate the variation of curvature for (0.0 to 1.0 inclusive).- Returns:
- The variation of curvature of the curve at the specified parametric position in units of 1/Length.
-
getTorsion
public Parameter getTorsion(double s)
Return the torsion of the curve at the parametric positions. The torsion is a measure of the rotation or twist about the tangent vector. Torsion for a line segment is always zero.- Specified by:
getTorsionin interfaceCurve<LineSegment>- Overrides:
getTorsionin classAbstractCurve<LineSegment>- Parameters:
s- Parametric distance to calculate the torsion for (0.0 to 1.0 inclusive).- Returns:
- The torsion of the curve at the specified parametric position in units of 1/Length.
-
getArcLength
public Parameter<javax.measure.quantity.Length> getArcLength(double s1, double s2, double eps)
Return the arc length of a segment of this curve.- Specified by:
getArcLengthin interfaceCurve<LineSegment>- Overrides:
getArcLengthin classAbstractCurve<LineSegment>- Parameters:
s1- The starting parametric distance along the curve to begin the arc-length calculation from.s2- The ending parametric distance along the curve to end the arc-length calculation at.eps- The desired fractional accuracy on the arc-length. For this curve type, this parameter is ignored and the exact arc length is returned.- Returns:
- The arc length of the specified segment of the curve.
-
getPointAtArcLength
public SubrangePoint getPointAtArcLength(Parameter<javax.measure.quantity.Length> targetArcLength, double tol)
Return a subrange point at the position on the curve with the specified arc-length. If the requested arc-length is ≤ 0, the start of the curve is returned. If the requested arc length is > the total arc length of the curve, then the end point is returned.- Specified by:
getPointAtArcLengthin interfaceCurve<LineSegment>- Overrides:
getPointAtArcLengthin classAbstractCurve<LineSegment>- Parameters:
targetArcLength- The target arc length to find in meters. May not be null.tol- Fractional tolerance (in parameter space) to refine the point position to. For this curve, this parameter is ignored and the exact point position is always returned.- Returns:
- A subrange point on the curve at the specified arc-length position.
-
extractGrid
public PointString<SubrangePoint> extractGrid(GridRule gridRule, java.util.List<java.lang.Double> spacing)
Return a string of points that are gridded onto the curve using the specified spacing and gridding rule.- Specified by:
extractGridin interfaceCurve<LineSegment>- Overrides:
extractGridin classAbstractCurve<LineSegment>- Parameters:
gridRule- Specifies whether the subdivision spacing is applied with respect to arc-length in real space or parameter space. May not be null.spacing- A list of values used to define the subdivision spacing.gridRulespecifies whether the subdivision spacing is applied with respect to arc-length in real space or parameter space. If the spacing is arc-length, then the values are interpreted as fractions of the arc length of the curve from 0 to 1. May not be null.- Returns:
- A string of subrange points gridded onto the curve at the specified parametric positions.
-
gridToTolerance
public PointString<SubrangePoint> gridToTolerance(Parameter<javax.measure.quantity.Length> tol)
Return a string of points that are gridded onto the curve with the number of points and spacing chosen to result in straight line segments between the points that have mid-points that are all within the specified tolerance of this curve.- Specified by:
gridToTolerancein interfaceCurve<LineSegment>- Overrides:
gridToTolerancein classAbstractCurve<LineSegment>- Parameters:
tol- The maximum distance that a straight line between gridded points may deviate from this curve. Ignored by this implementation.- Returns:
- A string of subrange points gridded onto the curve.
-
intersect
public PointString<SubrangePoint> intersect(GeomPlane plane, double tol)
Return the intersection between a plane and this curve.- Specified by:
intersectin interfaceCurve<LineSegment>- Overrides:
intersectin classAbstractCurve<LineSegment>- Parameters:
plane- The plane to intersect with this curve. May not be null.tol- Fractional tolerance (in parameter space) to refine the point positions to. For this curve, this parameter is ignored and the exact point positions are returned.- Returns:
- A PointString containing zero or one subrange points made by the intersection of this curve with the specified plane. If no intersection is found, an empty PointString is returned.
-
intersect
public GeomList<PointString<SubrangePoint>> intersect(LineSegment line, Parameter<javax.measure.quantity.Length> tol)
Return the intersection between a line segment and this curve.- Specified by:
intersectin interfaceCurve<LineSegment>- Overrides:
intersectin classAbstractCurve<LineSegment>- Parameters:
line- The line segment to intersect. May not be null.tol- Tolerance (in physical space) to refine the point positions to. A null value indicates an exact intersection is required.- Returns:
- A list containing two PointString instances each containing zero or 1 subrange points, on this line segment and the input line segment respectively, made by the intersection of this line segment with the specified line segment. If no intersections are found a list of two empty PointStrings are returned.
-
getLimitPoint
public SubrangePoint getLimitPoint(int dim, boolean max, double tol)
Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this curve.- Specified by:
getLimitPointin interfaceGeomElement<LineSegment>- Overrides:
getLimitPointin classAbstractCurve<LineSegment>- Parameters:
dim- An index indicating the dimension to find the min/max point for (0=X, 1=Y, 2=Z, etc).max- Set totrueto return the maximum value,falseto return the minimum.tol- Fractional tolerance (in parameter space) to refine the min/max point position to.- Returns:
- The point found on this curve that is the min or max in the specified coordinate direction.
- See Also:
GeomElement.getBoundsMin(),GeomElement.getBoundsMax()
-
isValid
public boolean isValid()
Returntrueif this LineSegment contains valid and finite numerical components. A value offalsewill be returned if any of the coordinate values are NaN or Inf.- Specified by:
isValidin interfaceGeomElement<LineSegment>- Returns:
- true if this line segment contains valid and finite data.
-
isLine
public boolean isLine(Parameter<javax.measure.quantity.Length> tol)
Returnstrueif this curve is a line to within the specified tolerance. This implementation always returnstrueif the line is not degenerate.- Specified by:
isLinein interfaceCurve<LineSegment>- Overrides:
isLinein classAbstractCurve<LineSegment>- Parameters:
tol- The tolerance for determining if this curve is a line. May not be null.- Returns:
- Always returns
trueif the line is not degenerate.
-
isPlanar
public boolean isPlanar(Parameter<javax.measure.quantity.Length> tol)
Returntrueif this curve is planar orfalseif it is not. This implementation always returnstrue- Specified by:
isPlanarin interfaceCurve<LineSegment>- Overrides:
isPlanarin classAbstractCurve<LineSegment>- Parameters:
tol- The geometric tolerance to use in determining if the curve is planar. Ignored by this implementation.- Returns:
- Always returns true.
-
isCircular
public boolean isCircular(Parameter<javax.measure.quantity.Length> tol)
Returnstrueif this curve is a circular arc to within the specified tolerance. This implementation always returnsfalse.- Specified by:
isCircularin interfaceCurve<LineSegment>- Overrides:
isCircularin classAbstractCurve<LineSegment>- Parameters:
tol- The tolerance for determining if this curve is a circular arc. Ignored by this implementation.- Returns:
- Always returns false.
-
getTransformed
public LineSegTrans getTransformed(GTransform transform)
Returns transformed version of this element. The returned object implementsGeomTransformand contains this element as a child.- Specified by:
getTransformedin interfaceTransformable<LineSegment>- Parameters:
transform- The transformation to apply to this geometry. May not be null.- Returns:
- A new line segment that is identical to this one with the specified transformation applied.
- Throws:
DimensionException- if this point is not 3D.
-
getUnit
public javax.measure.unit.Unit<javax.measure.quantity.Length> getUnit()
Returns the unit in which this curve is stated.- Specified by:
getUnitin interfaceGeomElement<LineSegment>- Returns:
- The unit in which this curve is stated.
-
toNurbs
public NurbsCurve toNurbs(Parameter<javax.measure.quantity.Length> tol)
Return a NURBS curve representation of this line segment. An exact representation is returned and the tolerance parameter is ignored.- Specified by:
toNurbsin interfaceCurve<LineSegment>- Parameters:
tol- Ignored. May passnull.- Returns:
- A NURBS curve that exactly represents this line segment.
-
toNurbs
public NurbsCurve toNurbs()
Return a NURBS curve representation of this line segment. An exact representation is returned.- Returns:
- A NURBS curve that exactly represents this line segment.
-
toText
public javolution.text.Text toText()
Returns the text representation of this geometry element that consists of the name followed by the start and end points. For example:{aLine = {{0.0 m, 0.0 m},{1.0 , 0.0 }}If there is no name, then the output looks like this:{{0.0 m, 0.0 m},{1.0 , 0.0 }}- Specified by:
toTextin interfaceGeomElement<LineSegment>- Overrides:
toTextin classAbstractGeomElement<LineSegment>- Returns:
- the text representation of this geometry element.
-
to
public abstract LineSegment to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this LineSegment object but stated in the specified unit.- Specified by:
toin interfaceCurve<LineSegment>- Specified by:
toin interfaceGeomElement<LineSegment>- Specified by:
toin interfaceParametricGeometry<LineSegment>- Specified by:
toin interfacePointGeometry<LineSegment>- Parameters:
unit- the length unit of the line segment to be returned. May not be null.- Returns:
- an equivalent to this line segment object but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException- if the the input unit is not a length unit.
-
-