Package geomss.geom

Class 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:
        size in interface GeomElement<LineSegment>
        Returns:
        The number of points in this line segment (always returns 2).
      • splitAt

        public GeomList<LineSegmentsplitAt​(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:
        splitAt in interface Curve<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 position s. This implementation always returns zero.
        Specified by:
        getCurvature in interface Curve<LineSegment>
        Overrides:
        getCurvature in class AbstractCurve<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 position s. The VOC for a line segment is always zero.
        Specified by:
        getVariationOfCurvature in interface Curve<LineSegment>
        Overrides:
        getVariationOfCurvature in class AbstractCurve<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 position s. The torsion is a measure of the rotation or twist about the tangent vector. Torsion for a line segment is always zero.
        Specified by:
        getTorsion in interface Curve<LineSegment>
        Overrides:
        getTorsion in class AbstractCurve<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:
        getArcLength in interface Curve<LineSegment>
        Overrides:
        getArcLength in class AbstractCurve<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:
        getPointAtArcLength in interface Curve<LineSegment>
        Overrides:
        getPointAtArcLength in class AbstractCurve<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<SubrangePointextractGrid​(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:
        extractGrid in interface Curve<LineSegment>
        Overrides:
        extractGrid in class AbstractCurve<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. gridRule specifies 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<SubrangePointgridToTolerance​(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:
        gridToTolerance in interface Curve<LineSegment>
        Overrides:
        gridToTolerance in class AbstractCurve<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<SubrangePointintersect​(GeomPlane plane,
                                                    double tol)
        Return the intersection between a plane and this curve.
        Specified by:
        intersect in interface Curve<LineSegment>
        Overrides:
        intersect in class AbstractCurve<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:
        intersect in interface Curve<LineSegment>
        Overrides:
        intersect in class AbstractCurve<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:
        getLimitPoint in interface GeomElement<LineSegment>
        Overrides:
        getLimitPoint in class AbstractCurve<LineSegment>
        Parameters:
        dim - An index indicating the dimension to find the min/max point for (0=X, 1=Y, 2=Z, etc).
        max - Set to true to return the maximum value, false to 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()
        Return true if this LineSegment contains valid and finite numerical components. A value of false will be returned if any of the coordinate values are NaN or Inf.
        Specified by:
        isValid in interface GeomElement<LineSegment>
        Returns:
        true if this line segment contains valid and finite data.
      • isLine

        public boolean isLine​(Parameter<javax.measure.quantity.Length> tol)
        Returns true if this curve is a line to within the specified tolerance. This implementation always returns true if the line is not degenerate.
        Specified by:
        isLine in interface Curve<LineSegment>
        Overrides:
        isLine in class AbstractCurve<LineSegment>
        Parameters:
        tol - The tolerance for determining if this curve is a line. May not be null.
        Returns:
        Always returns true if the line is not degenerate.
      • isPlanar

        public boolean isPlanar​(Parameter<javax.measure.quantity.Length> tol)
        Return true if this curve is planar or false if it is not. This implementation always returns true
        Specified by:
        isPlanar in interface Curve<LineSegment>
        Overrides:
        isPlanar in class AbstractCurve<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)
        Returns true if this curve is a circular arc to within the specified tolerance. This implementation always returns false.
        Specified by:
        isCircular in interface Curve<LineSegment>
        Overrides:
        isCircular in class AbstractCurve<LineSegment>
        Parameters:
        tol - The tolerance for determining if this curve is a circular arc. Ignored by this implementation.
        Returns:
        Always returns false.
      • getUnit

        public javax.measure.unit.Unit<javax.measure.quantity.Length> getUnit()
        Returns the unit in which this curve is stated.
        Specified by:
        getUnit in interface GeomElement<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:
        toNurbs in interface Curve<LineSegment>
        Parameters:
        tol - Ignored. May pass null.
        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:
        toText in interface GeomElement<LineSegment>
        Overrides:
        toText in class AbstractGeomElement<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:
        to in interface Curve<LineSegment>
        Specified by:
        to in interface GeomElement<LineSegment>
        Specified by:
        to in interface ParametricGeometry<LineSegment>
        Specified by:
        to in interface PointGeometry<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.