## LineSegment3d Class

A LineSegment3d is:

• A 3d line segment represented by its start and end coordinates
• startPoint
• endPoint
• The segment is parameterized with fraction 0 at the start and fraction 1 at the end, i.e. either of these equivalent forms to map fraction `f` to a point `X(f)`
• `X(f) = startPoint + f * (endPoint - startPoint)`
• `X(f) = (1-f)*startPoint + f * endPoint`

### Methods

Name Description
constructor(): Protected
announceClipIntervals(clipper: Clipper, announce?: AnnounceNumberNumberCurvePrimitive): boolean Find intervals of this curve primitive that are interior to a clipper
appendPlaneIntersectionPoints(plane: PlaneAltitudeEvaluator, result: CurveLocationDetail[]): number Compute points of simple (transverse) with a plane.
clone(): Clone the LineSegment3d
clonePartialCurve(fractionA: number, fractionB: number): CurvePrimitive | undefined Return (if possible) a curve primitive which is a portion of this curve.
cloneTransformed(transform: Transform): Clone and apply transform to the clone.
closestPoint(spacePoint: Point3d, extend: VariantCurveExtendParameter, result?: CurveLocationDetail): Returns a curve location detail with both xyz and fractional coordinates of the closest point.
computeStrokeCountForOptions(options?: StrokeOptions): number return the stroke count required for given options.
curveLength(): number Return the length of the segment.
curveLengthBetweenFractions(fraction0: number, fraction1: number): number Return the length of the partial segment between fractions.
dispatchToGeometryHandler(handler: GeometryHandler): any Second step of double dispatch: call `handler.handleLineSegment3d(this)`
emitStrokableParts(handler: IStrokeHandler, options?: StrokeOptions): void Emit strokes to caller-supplied handler
emitStrokes(dest: LineString3d, options?: StrokeOptions): void Emit strokes to caller-supplied linestring
endPoint(result?: Point3d): Return a (clone of) the end point.
extendRange(range: Range3d, transform?: Transform): void Extend a range to include the (optionally transformed) line segment
fractionToPoint(fraction: number, result?: Point3d): Return the point at fractional position along the line segment.
fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Construct a plane with
origin at the fractional position along the line segment
x axis is the first derivative, i.e.

fractionToPointAndDerivative(fraction: number, result?: Ray3d): Return the point and derivative vector at fractional position along the line segment.
getFractionToDistanceScale(): number | undefined A simple line segment's fraction and distance are proportional.
isAlmostEqual(other: GeometryQuery): boolean Near equality test with `other`.
isInPlane(plane: PlaneAltitudeEvaluator): boolean Test if both endpoints are in a plane (within tolerance)
isSameGeometryClass(other: GeometryQuery): boolean test if `other` is of class `LineSegment3d`
quickLength(): number Return the length of the segment.
reverseInPlace(): void swap the endpoint references.
set(point0: Point3d, point1: Point3d): void Set the start and endpoints by cloning the input parameters.
setFrom(other: LineSegment3d): void copy (clone) data from other
setFromJSON(json?: any): void Construct a line from either of these json forms:

object with named start and end:
`{startPoint: pointValue, endPoint: pointValue}`
array of two point values:
`[pointValue, pointValue]`
The point values are any values accepted by the Point3d method setFromJSON.

setRefs(point0: Point3d, point1: Point3d): void Set the start and endpoints by capturing input references.
startPoint(result?: Point3d): Return a (clone of) the start point.
toJSON(): any Place the lineSegment3d start and points in a json object
tryTransformInPlace(transform: Transform): boolean Transform the two endpoints of this LinSegment.
create(point0: Point3d, point1: Point3d, result?: LineSegment3d): Static Create with start and end points.
createCapture(point0: Point3d, point1: Point3d): Static Create with start and end points.
createXYXY(x0: number, y0: number, x1: number, y1: number, z: number = 0, result?: LineSegment3d): Static create a LineSegment3d from xy coordinates of start and end, with common z.
createXYZXYZ(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, result?: LineSegment3d): Static create a LineSegment3d from xy coordinates of start and end, with common z.
fromJSON(json?: any): Static Create a new `LineSegment3d` with coordinates from json object.

### Inherited methods

Name Inherited from Description
addMappedStrokesToLineString3D(map: StrokeCountMap, linestring: LineString3d): number CurvePrimitive * evaluate strokes at fractions indicated in a StrokeCountMap.
computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentMap?: StrokeCountMap): void CurvePrimitive attach StrokeCountMap structure to this primitive (and recursively to any children)
* Base class implementation (here) gets the simple count from computeStrokeCountForOptions and attaches it.
curveLengthWithFixedIntervalCountQuadrature(fraction0: number, fraction1: number, numInterval: number, numGauss: number = 5): number CurvePrimitive Run an integration (with a default gaussian quadrature) with a fixed fractional step
This is typically called by specific curve type implementations of curveLengthBetweenFractions.
fractionAndDistanceToPointOnTangent(fraction: number, distance: number): CurvePrimitive Construct a point extrapolated along tangent at fraction.
fractionToFrenetFrame(fraction: number, result?: Transform): Transform | undefined CurvePrimitive Construct a frenet frame:
origin at the point on the curve
x axis is unit vector along the curve (tangent)
* y axis is perpendicular and in the plane of the osculating circle.
fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): CurvePrimitive Returns a ray whose origin is the curve point and direction is the unit tangent.
moveSignedDistanceFromFraction(startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail): CurvePrimitive * (Attempt to) find a position on the curve at a signed distance from start fraction.
moveSignedDistanceFromFractionGeneric(startFraction: number, signedDistance: number, allowExtension: boolean, result?: CurveLocationDetail): Protected CurvePrimitive Generic algorithm to search for point at signed distance from a fractional startPoint.
range(transform?: Transform, result?: Range3d): GeometryQuery return the range of the entire (tree) GeometryQuery
tryTranslateInPlace(dx: number, dy: number = 0, dz: number = 0): boolean GeometryQuery try to move the geometry by dx,dy,dz
installStrokeCountMap(curve: CurvePrimitive, curveMap: StrokeCountMap, parentMap?: StrokeCountMap): void Static CurvePrimitive final install step to save curveMap in curve.

### Properties

Name Type Description
curvePrimitiveType "lineSegment" = "lineSegment"
isExtensibleFractionSpace Accessor ReadOnly boolean A LineSegment3d extends along its infinite line.
point0Ref Accessor ReadOnly Return REFERENCE to the start point of this segment.
point1Ref Accessor ReadOnly Return REFERENCE to the end point of this segment.

### Inherited properties

Name Type Inherited from Description
children Accessor ReadOnly GeometryQuery[] | undefined GeometryQuery return GeometryQuery children for recursive queries.

* leaf classes do not need to implement.
geometryCategory "curvePrimitive" = "curvePrimitive" CurvePrimitive
strokeData undefined | StrokeCountMap CurvePrimitive data attached during stroking for facets.

### Defined in

Last Updated: 10 September, 2019