## 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) = P_0 + f * (P_1 - P_0)\newline X(f) = (1-f)*P_0 + f * P_0$

### Methods

Name Description
constructor(point0: Point3d, point1: Point3d): Protected CAPTURE point references as a LineSegment3d
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): 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.
constructOffsetXY(offsetDistanceOrOptions: number | OffsetOptions): undefined | CurvePrimitive | CurvePrimitive[] Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).
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
fractionToPointAndDerivative(fraction: number, result?: Ray3d): Return the point and derivative vector at fractional position along the line segment.
getFractionToDistanceScale(): undefined | number 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
projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): undefined | Range1d Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of projection.
quickLength(): number Return the length of the segment.
rangeBetweenFractions(fraction0: number, fraction1: number, transform?: Transform): Returns a (high accuracy) range of the curve between fractional positions
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:
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.
collectCurvePrimitives(collectorArray?: CurvePrimitive[], smallestPossiblePrimitives: boolean = false, explodeLinestrings: boolean = false): CurvePrimitive Return an array containing only the curve primitives.
collectCurvePrimitivesGo(collectorArray: CurvePrimitive[], _smallestPossiblePrimitives: boolean, _explodeLinestrings: boolean = false): void CurvePrimitive Return an array containing only the curve primitives.
computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentMap?: StrokeCountMap): void CurvePrimitive attach StrokeCountMap structure to this primitive (and recursively to any children)
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
fractionAndDistanceToPointOnTangent(fraction: number, distance: number): CurvePrimitive Construct a point extrapolated along tangent at fraction.
fractionToCurvature(fraction: number): undefined | number CurvePrimitive Returns the (absolute) curvature magnitude.
fractionToFrenetFrame(fraction: number, result?: Transform): undefined | Transform CurvePrimitive Construct a frenet frame:
fractionToPointAndUnitTangent(fraction: number, result?: Ray3d): CurvePrimitive Returns a ray whose origin is the curve point and direction is the unit tangent.
fractionToSignedXYRadiusOfCurvature(fraction: number): number CurvePrimitive Construct signed distance from a point on the curve to its center of curvature (in xy only).
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): CurvePrimitive return the range of the entire (tree) GeometryQuery
rangeBetweenFractionsByClone(fraction0: number, fraction1: number, transform?: Transform): CurvePrimitive Returns a (high accuracy) range of the curve between fractional positions
rangeBetweenFractionsByCount(fraction0: number, fraction1: number, count: number, transform?: Transform, extrapolationFactor: number = 0.0): CurvePrimitive Returns an approximate range based on a fixed number of evaluations
tryTranslateInPlace(dx: number, dy: number = 0.0, dz: number = 0.0): boolean CurvePrimitive try to move the geometry by dx,dy,dz
areAlmostEqual(a: undefined | GeometryQuery, b: undefined | GeometryQuery): boolean Static CurvePrimitive apply instance method isAlmostEqual if both are defined.
installStrokeCountMap(curve: CurvePrimitive, curveMap: StrokeCountMap, parentMap?: StrokeCountMap): void Static CurvePrimitive final install step to save curveMap in curve.

### Properties

Name Type Description
curvePrimitiveType Readonly "lineSegment" String name for schema properties
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 undefined | GeometryQuery[] CurvePrimitive return GeometryQuery children for recursive queries.

* leaf classes do not need to implement.
geometryCategory Readonly "curvePrimitive" CurvePrimitive String name for schema properties
parent undefined | any CurvePrimitive data attached by various algorithms (e.g.
strokeData undefined | StrokeCountMap CurvePrimitive data attached during stroking for facets.

### Defined in

Last Updated: 22 March, 2023