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.
  • 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 1 is the end (x1)
    • The fraction equation is x = x0 + fraction * (x1-x0) or (equivalently) x = (1-fraction) * x0 + fraction * x1

Methods

Name Description
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.  
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 distance)  
create(x0: number = 0, x1: number = 1, result?: Segment1d): Segment1d Static create segment1d with given end values  

Properties

Name Type Description
isExact01 Accessor ReadOnly boolean Return true if the segment limits are (exactly) 0 and 1  
isExact01Reversed Accessor ReadOnly boolean Return true if the segment limits are (exactly) 1 and 0  
isIn01 Accessor ReadOnly boolean Returns true if both coordinates (x0 and x1) are in the 0..1 range.  
x0 number start coordinate  
x1 number end coordinate  

Defined in

Last Updated: 20 September, 2019