Skip to main content

Class: abstract Spline

Spline curve representation

You can find more about splines in this video https://www.youtube.com/watch?v=jvPPXbo87ds&t=11m20s

Extended by​

Implements​

Constructors​

new Spline()​

new Spline(props?): Spline

Parameters​

• props?: SplineProps

Returns​

Spline

Defined in​

tools/src/tools/annotation/splines/Spline.ts:36

Accessors​

aabb​

get aabb(): AABB2

Axis-aligned bounding box (minX, minY, maxX, maxY)

Returns​

AABB2

Implementation of​

ISpline.aabb

Defined in​

tools/src/tools/annotation/splines/Spline.ts:100


closed​

get closed(): boolean

Flag that is set to true when the curve is already closed

set closed(closed): void

Set the curve as closed which connects the last to the first point

Parameters​

• closed: boolean

Returns​

boolean

Implementation of​

ISpline.closed

Defined in​

tools/src/tools/annotation/splines/Spline.ts:85


controlPoints​

get protected controlPoints(): Point2[]

Return the control points array

Any external access should be done through getControlPoints because it clones the points to make sure the data will not get changed by the caller

Returns​

Point2[]

Defined in​

tools/src/tools/annotation/splines/Spline.ts:50


fixedResolution​

get fixedResolution(): boolean

Fixed resolution

Linar spline is one of the splines that does not allow changing the resolution for better performance otherwise it would calculate and render 20 line segments instead of a single one..

Returns​

boolean

Implementation of​

ISpline.fixedResolution

Defined in​

tools/src/tools/annotation/splines/Spline.ts:80


invalidated​

get invalidated(): boolean

Flag that is set to true when the spline needs to be updated. The update runs automaticaly when needed (eg: getPolylinePoints).

set invalidated(invalidated): void

Sets the spline as invalid when curve segments need to be recalculated or as valid after recomputing the curves

Parameters​

• invalidated: boolean

Returns​

boolean

Implementation of​

ISpline.invalidated

Defined in​

tools/src/tools/annotation/splines/Spline.ts:115


length​

get length(): number

Length of the spline curve in pixels

Returns​

number

Implementation of​

ISpline.length

Defined in​

tools/src/tools/annotation/splines/Spline.ts:106


numControlPoints​

get numControlPoints(): number

Number of control points

Returns​

number

Implementation of​

ISpline.numControlPoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:55


resolution​

get resolution(): number

Resolution of the spline curve (greater than or equal to 0)

set resolution(resolution): void

Set the resolution of the spline curve

Parameters​

• resolution: number

Returns​

number

Implementation of​

ISpline.resolution

Defined in​

tools/src/tools/annotation/splines/Spline.ts:60

Methods​

addControlPoint()​

addControlPoint(point): void

Add a control point to the end of the array

Parameters​

• point: Point2

Control point (2D)

Returns​

void

Implementation of​

ISpline.addControlPoint

Defined in​

tools/src/tools/annotation/splines/Spline.ts:139


addControlPointAtU()​

addControlPointAtU(u): ControlPointInfo

Add a control point specifying its u value in Parameter Space which is a number from 0 to N where N is the number of curve segments. The integer part is the curve segment index and the decimal part is the t value on that curve segment.

Parameters​

• u: number

u value in Parameter Space

Returns​

ControlPointInfo

Implementation of​

ISpline.addControlPointAtU

Defined in​

tools/src/tools/annotation/splines/Spline.ts:158


addControlPoints()​

addControlPoints(points): void

Add a list of control poits to the end of the array

Parameters​

• points: Point2[]

Control points to be added

Returns​

void

Implementation of​

ISpline.addControlPoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:148


clearControlPoints()​

clearControlPoints(): void

Remove all control points

Returns​

void

Implementation of​

ISpline.clearControlPoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:206


containsPoint()​

containsPoint(point): boolean

Checks if a 2D point is inside the spline curve.

A point is inside a curve/polygon if the number of intersections between the horizontal ray emanating from the given point and to the right and the line segments is odd. https://www.eecs.umich.edu/courses/eecs380/HANDOUTS/PROJ2/InsidePoly.html

Parameters​

• point: Point2

2D Point

Returns​

boolean

True is the point is inside the spline curve or false otherwise

Implementation of​

ISpline.containsPoint

Defined in​

tools/src/tools/annotation/splines/Spline.ts:502


deleteControlPointByIndex()​

deleteControlPointByIndex(index): boolean

Delete a control point given its index

Parameters​

• index: number

Control point index to be removed

Returns​

boolean

True if the control point is removed or false otherwise

Implementation of​

ISpline.deleteControlPointByIndex

Defined in​

tools/src/tools/annotation/splines/Spline.ts:186


getClosestControlPoint()​

getClosestControlPoint(point): ClosestControlPoint

Finds the closest control point given a 2D point

Parameters​

• point: Point2

Reference point

Returns​

ClosestControlPoint

Closest control point

Implementation of​

ISpline.getClosestControlPoint

Defined in​

tools/src/tools/annotation/splines/Spline.ts:254


getClosestControlPointWithinDistance()​

getClosestControlPointWithinDistance(point, maxDist): ClosestControlPoint

Finds the closest control point given a 2D point and a maximum distance

Parameters​

• point: Point2

Reference 2D point

• maxDist: number

Maximum distance

Returns​

ClosestControlPoint

Closest control point that is within the given range or undefined otherwise

Implementation of​

ISpline.getClosestControlPointWithinDistance

Defined in​

tools/src/tools/annotation/splines/Spline.ts:287


getClosestPoint()​

getClosestPoint(point): ClosestSplinePoint

Finds the closest point on the spline curve given 2D point

Parameters​

• point: Point2

Reference 2D point

Returns​

ClosestSplinePoint

Closest point on the spline curve

Implementation of​

ISpline.getClosestPoint

Defined in​

tools/src/tools/annotation/splines/Spline.ts:303


getClosestPointOnControlPointLines()​

getClosestPointOnControlPointLines(point): ClosestPoint

Finds the closest point on the straight line that connects all control points given a 2D point

Parameters​

• point: Point2

Reference point

Returns​

ClosestPoint

Closest point on the straight line that connects all control points

Implementation of​

ISpline.getClosestPointOnControlPointLines

Defined in​

tools/src/tools/annotation/splines/Spline.ts:376


getControlPoints()​

getControlPoints(): Point2[]

Get a list with all control points. The control points are cloned to prevent any caller from changing them resulting in unexpected behaviors

Returns​

Point2[]

  • List of all control points

Implementation of​

ISpline.getControlPoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:242


getPolylinePoints()​

getPolylinePoints(): Point2[]

Get all points necessary to draw a spline curve

Returns​

Point2[]

Array with all points necessary to draw a spline curve

Implementation of​

ISpline.getPolylinePoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:418


getPreviewCurveSegments()​

abstract protected getPreviewCurveSegments(controlPointPreview, closeSpline): SplineCurveSegment[]

Parameters​

• controlPointPreview: Point2

• closeSpline: boolean

Returns​

SplineCurveSegment[]

Defined in​

tools/src/tools/annotation/splines/Spline.ts:563


getPreviewPolylinePoints()​

getPreviewPolylinePoints(controlPointPreview, closeDistance): Point2[]

Get all points necessary to draw the preview of the changes that shall be made to the spline if a new control point is added to it

Parameters​

• controlPointPreview: Point2

New control point preview

• closeDistance: number

Distance to the first control point to consider it a closed spline

Returns​

Point2[]

Array with all points necessary to draw a spline curve preview

Implementation of​

ISpline.getPreviewPolylinePoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:431


getSplineCurves()​

abstract protected getSplineCurves(): SplineCurveSegment[]

Returns​

SplineCurveSegment[]

Defined in​

tools/src/tools/annotation/splines/Spline.ts:561


getTransformMatrix()​

abstract protected getTransformMatrix(): number[]

Returns​

number[]

Defined in​

tools/src/tools/annotation/splines/Spline.ts:559


hasTangentPoints()​

hasTangentPoints(): boolean

Bézier curves have tangent points connected to control points

Returns​

boolean

True if the spline has tangent point or false otherwise

Implementation of​

ISpline.hasTangentPoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:131


isPointNearCurve()​

isPointNearCurve(point, maxDist): boolean

Checks if a point is near to the spline curve

Parameters​

• point: Point2

Reference point

• maxDist: number

Maximum allowed distance

Returns​

boolean

True if the point is close to the spline curve or false otherwise

Implementation of​

ISpline.isPointNearCurve

Defined in​

tools/src/tools/annotation/splines/Spline.ts:465


setControlPoints()​

setControlPoints(points): void

Replace all control points by some new ones

Parameters​

• points: Point2[]

Control points to be added to the array

Returns​

void

Implementation of​

ISpline.setControlPoints

Defined in​

tools/src/tools/annotation/splines/Spline.ts:215


updateControlPoint()​

updateControlPoint(index, newControlPoint): void

Update the coordinate of a control point given its index

Parameters​

• index: number

Control point index

• newControlPoint: Point2

New control point

Returns​

void

Implementation of​

ISpline.updateControlPoint

Defined in​

tools/src/tools/annotation/splines/Spline.ts:225