# Segment2D

@Serializable
data class Segment2D(val start: Vector2, val control: List<Vector2>, val end: Vector2, val corner: Boolean = false) : BezierSegment<Vector2> , ShapeContourProvider(source)

Creates a new Segment2D, which specifies a linear or a Bézier curve path between two anchor points (and up to two control points for curvature).

## Constructors

constructor(start: Vector2, control: List<Vector2>, end: Vector2, corner: Boolean = false)

## Functions

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

Recursively subdivides Segment2D to approximate Bézier curve.

open fun adaptivePositionsWithT(distanceTolerance: Double = 0.5): List<Pair<Vector2, Double>>
open override fun derivative(t: Double): Vector2
open fun direction(): Vector2

Returns the direction T of between the Segment2D anchor points.

open fun direction(t: Double): Vector2
operator fun div(scale: Double): Segment2D
open operator override fun equals(other: Any?): Boolean
open fun equidistantPositions(pointCount: Int, distanceTolerance: Double = 0.5): List<Vector2>

Samples specified amount of points on the Segment2D.

open fun equidistantPositionsWithT(pointCount: Int, distanceTolerance: Double = 0.5): List<Pair<Vector2, Double>>

Returns the t values of the extrema for the current Segment2D.

Returns the extrema points as Vector2s for current Segment2D

open override fun hashCode(): Int

Calculates a List of all points where two Segment2Ds intersect.

Calculates a List of all points of where a Segment2D and a Shape intersect.

Calculates a List of all points of where a Segment2D and a ShapeContour intersect.

fun isStraight(tolerance: Double = 0.01): Boolean

Determines if the Segment2D forms a straight line.

fun lut(size: Int = 100): List<Vector2>
operator fun minus(right: Segment2D): Segment2D

Find point on segment nearest to given point.

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

Returns a normal Vector2 at given value of t in the range of `0.0` to `1.0`.

fun on(point: Vector2, error: Double = 5.0): Double?
operator fun plus(right: Segment2D): Segment2D
open fun pointAtLength(length: Double, distanceTolerance: Double): Vector2

Calculates the point at a given distance along this Segment2D.

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

Calculates the pose Matrix44 (i.e. translation and rotation) that describes an orthonormal basis formed by normal and tangent of the contour at t.

open override fun position(ut: Double): Vector2

Returns a point on the segment.

open override fun split(t: Double): Array<Segment2D>

Splits the path into one or two parts, depending on if the cut was successful.

open override fun sub(t0: Double, t1: Double): Segment2D

Samples a new Segment2D from the current Segment2D starting at t0 and ending at t1.

open override fun tForLength(length: Double): Double

Estimate t value for a given length

operator fun times(scale: Double): Segment2D
open override fun toString(): String
fun transform(transform: Matrix44): Segment2D

Applies given linear transformation.

## Properties

Returns the bounding box.

open override val contour: ShapeContour

the provided contour

open override val control: List<Vector2>
val corner: Boolean = false
open override val cubic: Segment2D

Converts the Segment2D to a cubic Bézier curve.

open override val end: Vector2
open override val length: Double

Calculates approximate Euclidean length of the Segment2D.

@Transient
open val linear: Boolean

Indicates whether the Segment2D is linear.

Converts the Segment2D to a quadratic Bézier curve.