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

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

Functions

Link copied to clipboard
open fun adaptivePositions(distanceTolerance: Double = 0.5): List<Vector2>

Recursively subdivides Segment2D to approximate Bézier curve.

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

Returns the direction T of between the Segment2D anchor points.

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

Samples specified amount of points on the Segment2D.

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

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

Link copied to clipboard

Returns the extrema points as Vector2s for current Segment2D

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

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.

Link copied to clipboard
fun isStraight(tolerance: Double = 0.01): Boolean

Determines if the Segment2D forms a straight line.

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

Find point on segment nearest to given point.

Link copied to clipboard
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.

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

Calculates the point at a given distance along this Segment2D.

Link copied to clipboard
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.

Link copied to clipboard
open override fun position(ut: Double): Vector2

Returns a point on the segment.

Link copied to clipboard
open override fun split(t: Double): Array<Segment2D>

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

Link copied to clipboard
open override fun sub(t0: Double, t1: Double): Segment2D

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

Link copied to clipboard
open override fun tForLength(length: Double): Double

Estimate t value for a given length

Link copied to clipboard
operator fun times(scale: Double): Segment2D
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun transform(transform: Matrix44): Segment2D

Applies given linear transformation.

Properties

Link copied to clipboard

Returns the bounding box.

Link copied to clipboard
Link copied to clipboard
open override val contour: ShapeContour

the provided contour

Link copied to clipboard
open override val control: List<Vector2>
Link copied to clipboard
val corner: Boolean = false
Link copied to clipboard
open override val cubic: Segment2D

Converts the Segment2D to a cubic Bézier curve.

Link copied to clipboard
open override val end: Vector2
Link copied to clipboard
open override val length: Double

Calculates approximate Euclidean length of the Segment2D.

Link copied to clipboard
@Transient
open val linear: Boolean

Indicates whether the Segment2D is linear.

Link copied to clipboard

Converts the Segment2D to a quadratic Bézier curve.

Link copied to clipboard
open override val reverse: Segment2D

Reverses the order of control points of the given path Segment2D.

Link copied to clipboard
Link copied to clipboard
open override val start: Vector2
Link copied to clipboard
@Transient
open val type: SegmentType

Returns the type of the segment.