Class EllipseCurve

Creates a 2d curve in the shape of an ellipse. Setting the xRadius equal to the yRadius will result in a circle.

Example

const curve = new EllipseCurve(
0, 0, // ax, aY
10, 10, // xRadius, yRadius
0, 2 * Math.PI, // aStartAngle, aEndAngle
false, // aClockwise
0 // aRotation
);

const points = curve.getPoints( 50 );

Hierarchy

Constructors

  • Create a new instance.

    Parameters

    • Optional x: number

      – The X center of the ellipse. Default is 0.

    • Optional y: number

      – The Y center of the ellipse. Default is 0.

    • Optional xRadius: number

      – The radius of the ellipse in the x direction. Default is 1.

    • Optional yRadius: number

      – The radius of the ellipse in the y direction. Default is 1.

    • Optional startAngle: number

      – The start angle of the curve in radians starting from the positive X axis. Default is 0.

    • Optional endAngle: number

      – The end angle of the curve in radians starting from the positive X axis. Default is 2 x Math.PI.

    • Optional isClockwise: boolean

      – Whether the ellipse is drawn clockwise. Default is false.

    • Optional rotation: number

      The rotation angle of the ellipse in radians, counterclockwise from the positive X axis (optional). Default is 0.

    Returns EllipseCurve

Properties

aClockwise: boolean

Whether the ellipse is drawn clockwise.

Default Value

false

aEndAngle: number

The end angle of the curve in radians starting from the middle right side.

Default

2 * Math.PI

aRotation: number

The rotation angle of the ellipse in radians, counterclockwise from the positive X axis

Default Value

0

aStartAngle: number

The start angle of the curve in radians starting from the middle right side.

Default Value

0

aX: number

The X center of the ellipse.

Default Value

0

aY: number

The Y center of the ellipse.

Default Value

0

arcLengthDivisions: number

Determines the amount of divisions when calculating the cumulative segment lengths of a curve via .getLengths. To ensure precision when using methods like .getSpacedPoints, it is recommended to increase .arcLengthDivisions if the curve is very large.

Default

200

isArcCurve: boolean

subclass should override

Default Value

false

isCatmullRomCurve3: boolean

subclass should override

Default Value

true

isCubicBezierCurve: boolean

subclass should override

Default Value

false

isCubicBezierCurve3: boolean

subclass should override

Default Value

false

isEllipseCurve: boolean

Default Value

true

isLineCurve: boolean

subclass should override

Default Value

false

isLineCurve3: boolean

subclass should override

Default Value

false

isQuadraticBezierCurve: boolean

subclass should override

Default Value

false

isQuadraticBezierCurve3: boolean

subclass should override

Default Value

false

isSplineCurve: boolean

subclass should override

Default Value

false

type: string

The print name of the EllipseCurve.

Default Value

'EllipseCurve'

xRadius: number

The radius of the ellipse in the x direction.

Default Value

1

yRadius: number

The radius of the ellipse in the y direction.

Default Value

1

Methods

  • Creates a new instance with same property values as this curve.

    Returns

    A new Curve instance exactly like this curve.

    Returns Curve<Vector2>

  • Generates the Frenet frames. Learn more at http://www.cs.indiana.edu/pub/techreports/TR425.pdf

    Returns

    An object with shape: { tangents: Vector3[]; normals: Vector3[]; binormals: Vector3[]; }

    Parameters

    • segments: number

      Number of segments

    • Optional closed: boolean

      True if this curve is closed.

    Returns { binormals: Vector3[]; normals: Vector3[]; tangents: Vector3[] }

    • binormals: Vector3[]
    • normals: Vector3[]
    • tangents: Vector3[]
  • Get list of cumulative segment lengths.

    Returns

    Array of points

    Parameters

    • Optional divisions: number

    Returns number[]

  • Find the point (vector) for point t of the curve where t is between 0 and 1.

    Returns

    The point.

    Parameters

    • t: number

      A position on the curve. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector2

      (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector2

  • Find a vector for point at relative position in curve according to arc length

    Returns

    The point.

    Parameters

    • u: number

      A position on the curve according to the arc length. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector2

      (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector2

  • Compute a set of divisions + 1 points using getPoint( t ).

    Returns

    Array of point vectors.

    Parameters

    • Optional divisions: number

      number of pieces to divide the curve into. Default is 5.

    Returns Vector2[]

  • Compute a set of divisions + 1 equi-spaced points using getPointAt( u ).

    Returns

    Array of point vectors.

    Parameters

    • Optional divisions: number

      number of pieces to divide the curve into. Default is 5.

    Returns Vector2[]

  • Compute a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation getTangent(t: number, optionalTarget?: T): T;

    Returns

    A vector tangent to t.

    Parameters

    • t: number

      A position on the curve. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector2

      — (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector2

  • Compute the tangent at a point which is equidistant to the ends of the curve from the point given in getTangent().

    Returns

    a vector tangent to u.

    Parameters

    • u: number

      A position on the curve according to the arc length. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector2

      (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector2

  • Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance

    Parameters

    • u: number
    • distance: number

    Returns number

  • Create a JSON object representation of this instance.

    Returns

    A JSON object

    Returns object