openrndr / org.openrndr.shape / Segment

# Segment

`class Segment` (source)

Segment describes a linear or bezier path between two points

### Constructors

#### <init>

Linear segment constructor

`Segment(start: Vector2, end: Vector2, corner: Boolean = true)`

`Segment(start: Vector2, c0: Vector2, end: Vector2, corner: Boolean = true)`

Cubic bezier segment constructor

`Segment(start: Vector2, c0: Vector2, c1: Vector2, end: Vector2, corner: Boolean = true)``Segment(start: Vector2, control: Array<Vector2>, end: Vector2, corner: Boolean = true)`

### Properties

#### bounds

bounding box Rectangle

`val bounds: Rectangle`

#### clockwise

`val clockwise: Boolean`

#### contour

`val contour: ShapeContour`

#### control

control points, zero-length iff the segment is linear

`val control: Array<Vector2>`

#### corner

`val corner: Boolean`

#### cubic

Cubic version of segment

`val cubic: Segment`

#### end

the end of the segment

`val end: Vector2`

#### length

calculate (approximate) Euclidean length of the segment

`val length: Double`

#### linear

indicate segment linearity

`val linear: Boolean`

convert to linear to quadratic segment

`val quadratic: Segment`

#### reverse

calculate a reversed version of the segment

`val reverse: Segment`

#### simple

determines if this is a simple segment

`val simple: Boolean`

#### start

the start of the segment

`val start: Vector2`

#### type

The type of the segment

`val type: SegmentType`

### Functions

`fun adaptivePositions(distanceTolerance: Double = 0.5): List<Vector2>`

`fun adaptivePositionsAndNormals(distanceTolerance: Double = 0.5): Pair<List<Vector2>, List<Vector2>>`

#### copy

`fun copy(start: Vector2 = this.start, control: Array<Vector2> = this.control, end: Vector2 = this.end): Segment`

#### derivative

`fun derivative(t: Double): Vector2`

#### direction

`fun direction(): Vector2`
`fun direction(t: Double): Vector2`

#### div

`operator fun div(scale: Double): Segment`

#### equals

`fun equals(other: Any?): Boolean`

#### equidistantPositions

Sample pointCount points on the segment

`fun equidistantPositions(pointCount: Int): List<Vector2>`

#### extrema

extrema t-parameter values

`fun extrema(): List<Double>`

#### extremaPoints

extrema points

`fun extremaPoints(): List<Vector2>`

#### hashCode

`fun hashCode(): Int`

#### isStraight

`fun isStraight(epsilon: Double = 0.01): Boolean`

#### lut

`fun lut(size: Int = 100): List<Vector2>`

#### minus

`operator fun minus(right: Segment): Segment`

#### nearest

Find point on segment nearest to `point`

`fun nearest(point: Vector2): SegmentPoint`

#### normal

`fun normal(ut: Double, polarity: YPolarity = YPolarity.CW_NEGATIVE_Y): Vector2`

#### offset

`fun offset(distance: Double, stepSize: Double = 0.01, yPolarity: YPolarity = YPolarity.CW_NEGATIVE_Y): List<Segment>`

#### on

`fun on(point: Vector2, error: Double = 5.0): Double?`

#### plus

`operator fun plus(right: Segment): Segment`

#### pose

calculate pose matrix for t-parameter value

`fun pose(t: Double, polarity: YPolarity = YPolarity.CW_NEGATIVE_Y): Matrix44`

#### position

Return a point on the segment

`fun position(ut: Double): Vector2`

#### reduced

`fun reduced(stepSize: Double = 0.01): List<Segment>`

#### scale

`fun scale(scale: Double, polarity: YPolarity): Segment`
`fun scale(polarity: YPolarity, scale: (Double) -> Double): Segment`

#### split

Split the contour

`fun split(t: Double): Array<Segment>`

#### sub

Take a sub segment starting at startT and ending at endT

`fun sub(startT: Double, endT: Double): Segment`

#### tForLength

Estimate t parameter value for a given length

`fun tForLength(length: Double): Double`

#### times

`operator fun times(scale: Double): Segment`

#### toString

`fun toString(): String`

#### transform

apply linear transform

`fun transform(transform: Matrix44): Segment`