A Base Curve class, which all other curve types extend.
Based on the three.js Curve classes created by zz85
new Curve(type)
name  type  description 

type  string 
The curve type. 
For a curve on a Path, false
means the Path will ignore this curve.
The quantity of arc length divisions within the curve.
An array of cached arc length values.
The default number of divisions within the curve.
Does the data of this curve need updating?
String based identifier for the type of curve.
Draws this curve on the given Graphics object.
The curve is drawn using Graphics.strokePoints
so will be drawn at whatever the present Graphics stroke color is.
The Graphics object is not cleared before the draw, so the curve will appear ontop of anything else already rendered to it.
name  type  arguments  Default  description 

graphics  Phaser.GameObjects.Graphics 
The Graphics instance onto which this curve will be drawn. 

pointsTotal  number  <optional>  32 
The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. 
The Graphics object to which the curve was drawn.
Returns a Rectangle where the position and dimensions match the bounds of this Curve.
You can control the accuracy of the bounds. The value given is used to work out how many points to plot across the curve. Higher values are more accurate at the cost of calculation speed.
name  type  arguments  Default  description 

out  Phaser.Geom.Rectangle  <optional> 
The Rectangle to store the bounds in. If falsey a new object will be created. 

accuracy  number  <optional>  16 
The accuracy of the bounds calculations. 
A Rectangle object holding the bounds of this curve. If out
was given it will be this object.
Returns an array of points, spaced out X distance pixels apart. The smaller the distance, the larger the array will be.
name  type  description 

distance  number 
The distance, in pixels, between each point along the curve. 
An Array of Point objects.
Get a point at the end of the curve.
name  type  arguments  description 

out  Phaser.Math.Vector2  <optional> 
Optional Vector object to store the result in. 
Vector2 containing the coordinates of the curves end point.
Get total curve arc length
The total length of the curve.
Get a list of cumulative segment lengths.
These lengths are
name  type  arguments  description 

divisions  number  <optional> 
The number of divisions or segments. 
An array of cumulative lengths.
Get a point at a relative position on the curve, by arc length.
name  type  arguments  description 

u  number 
The relative position, [0..1]. 

out  Phaser.Math.Vector2  <optional> 
A point to store the result in. 
The point.
Get a sequence of evenly spaced points from the curve.
You can pass divisions
, stepRate
, or neither.
The number of divisions will be
divisions
, if divisions
> 0; orthis.getLength / stepRate
, if stepRate
> 0; orthis.defaultDivisions
1 + divisions
points will be returned.
name  type  arguments  description 

divisions  number  <optional> 
The number of divisions to make. 
stepRate  number  <optional> 
The curve distance between points, implying 
out  array  Array.<Phaser.Math.Vector2>  <optional> 
An optional array to store the points in. 
An array of Points from the curve.
Get a random point from the curve.
name  type  arguments  description 

out  Phaser.Math.Vector2  <optional> 
A point object to store the result in. 
The point.
Get a sequence of equally spaced points (by arc distance) from the curve.
1 + divisions
points will be returned.
name  type  arguments  Default  description 

divisions  number  <optional>  this.defaultDivisions 
The number of divisions to make. 
stepRate  number  <optional> 
Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive. 

out  array  Array.<Phaser.Math.Vector2>  <optional> 
An optional array to store the points in. 
An array of points.
Get a point at the start of the curve.
name  type  arguments  description 

out  Phaser.Math.Vector2  <optional> 
A point to store the result in. 
The point.
Given a distance in pixels, get a t to find p.
name  type  arguments  description 

distance  number 
The distance, in pixels. 

divisions  number  <optional> 
Optional amount of divisions. 
The distance.
Get a unit vector tangent at a relative position on the curve. In case any sub curve does 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
name  type  arguments  description 

t  number 
The relative position on the curve, [0..1]. 

out  Phaser.Math.Vector2  <optional> 
A vector to store the result in. 
Vector approximating the tangent line at the point t (delta +/ 0.0001)
Get a unit vector tangent at a relative position on the curve, by arc length.
name  type  arguments  description 

u  number 
The relative position on the curve, [0..1]. 

out  Phaser.Math.Vector2  <optional> 
A vector to store the result in. 
The tangent vector.
Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant.
name  type  arguments  description 

u  number 
A float between 0 and 1. 

distance  number 
The distance, in pixels. 

divisions  number  <optional> 
Optional amount of divisions. 
The equidistant value.
Calculate and cache the arc lengths.