Segment1d Class
- A Segment1d is an interval of an axis named x.
- The interval is defined by two values x0 and x1.
- The x0 and x1 values can be in either order.
- if
x0 < x1
fractional coordinates within the segment move from left to right. - if
x0 > x1
fractional coordinates within the segment move from right to left.
- if
- This differs from a Range1d in that:
- For a Range1d the reversed ordering of its limit values means "empty interval".
- For a Segment1d the reversed ordering is a real interval but fractional positions move backwards.
- The segment is parameterized with a fraction
- Fraction 0 is the start (
x0
)
- Fraction 0 is the start (
- Fraction 1 is the end (
x1
)
- Fraction 1 is the end (
- The fraction equation is
x = x0 + fraction * (x1-x0)
or (equivalently)x = (1-fraction) * x0 + fraction * x1
- The fraction equation is
Methods
Name | Description | |
---|---|---|
absoluteDelta(): number | Return the absolute start-to-end shift (aka distance) | |
clampDirectedTo01(): boolean | * On input, (f0,f1) is a (directed) segment. | |
clipBy01FunctionValuesPositive(f0: number, f1: number): boolean | On input, this is an interval of a line. |
|
clone(): Segment1d | clone this Segment1d, return as a separate object. | |
fractionToPoint(fraction: number): number | Evaluate the segment at fractional position | |
isAlmostEqual(other: Segment1d): boolean | Near equality test, using Geometry.isSameCoordinate for tolerances. | |
reverseIfNeededForDeltaSign(sign: number = 1): void | * if x1-x0 multiplied by the scale factor is (strictly) negative, swap the x0 and x1 member values. |
|
reverseInPlace(): void | * swap the x0 and x1 member values. | |
set(x0: number, x1: number): void | replace both end values. | |
setFrom(other: Segment1d): void | Copy both end values from other Segment1d | |
shift(dx: number): void | shift (translate) the segment along its axis by adding dx to both x0 and x1 . |
|
signedDelta(): number | Return the signed start-to-end shift (aka signed distance) | |
create(x0: number = 0, x1: number = 1, result?: Segment1d): Segment1d Static | create segment1d with given end values |
Properties
Defined in
- geometry3d/Segment1d.ts Line 27
Last Updated: 20 June, 2023