ICurve

Description

`interface` `Tinman.Terrain.Util.ICurve`

Derived from
Extended by

Curve abstract

Base interface for classes that represent a curve that interpolates through a sequence of control points.

A curve has zero or more control points, which may be added with the `Add*` methods and cleared with Clear. Each control point has a required position value and an optional tangent value. Each value is a tuple with 1 to 4 components. By replicating control points, the curve can be further adjusted (see Replicate). Control point information may be queried with Count, Range, HasTangents and GetAt. Interpolation of points (1D through 4D) along the curve is performed by the `Compute*` methods. With Length, WalkIndex and WalkDistance, spatial information about the curve is exposed. Regarding WalkDistance and WalkIndex, the following holds true:

```A,B := control point indices within valid range

WalkIndex(A, WalkDistance(A, B)) ~= B
WalkIndex(B, WalkDistance(B, A)) ~= A

(only almost equal because of numeric algorithm)

WalkDistance(A, B) = -WalkDistance(B, A)```

Walking along a curve is implemented with a recursive numeric algorithm and may involve significant floating-point calculations. Computing the walk distance between integral control point indices will use an internal cache of walk distance values and thus reduces to a simple lookup-table query.

Public / Methods

`public` `method` `Add1` → `(1)`

px in : float64

X-coordinate (position) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that has tangents will specify zero for tangent values.

`public` `method` `Add2` → `(2)`

px in : float64

X-coordinate (position) of the control point.

py in : float64

Y-coordinate (position) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that has tangents will specify zero for tangent values.

`public` `method` `Add3` → `(3)`

px in : float64

X-coordinate (position) of the control point.

py in : float64

Y-coordinate (position) of the control point.

pz in : float64

Z-coordinate (position) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that has tangents will specify zero for tangent values.

`public` `method` `Add4` → `(4)`

px in : float64

X-coordinate (position) of the control point.

py in : float64

Y-coordinate (position) of the control point.

pz in : float64

Z-coordinate (position) of the control point.

pw in : float64

W-coordinate (position) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that has tangents will specify zero for tangent values.

`public` `method` `Add21` → `(2)`

px in : float64

X-coordinate (position) of the control point.

tx in : float64

X-coordinate (tangent) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that does not have tangents will discard the tangent values.

`public` `method` `Add22` → `(4)`

px in : float64

X-coordinate (position) of the control point.

tx in : float64

X-coordinate (tangent) of the control point.

py in : float64

Y-coordinate (position) of the control point.

ty in : float64

Y-coordinate (tangent) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that does not have tangents will discard the tangent values.

`public` `method` `Add23` → `(6)`

px in : float64

X-coordinate (position) of the control point.

tx in : float64

X-coordinate (tangent) of the control point.

py in : float64

Y-coordinate (position) of the control point.

ty in : float64

Y-coordinate (tangent) of the control point.

pz in : float64

Z-coordinate (position) of the control point.

tz in : float64

Z-coordinate (tangent) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that does not have tangents will discard the tangent values.

`public` `method` `Add24` → `(8)`

px in : float64

X-coordinate (position) of the control point.

tx in : float64

X-coordinate (tangent) of the control point.

py in : float64

Y-coordinate (position) of the control point.

ty in : float64

Y-coordinate (tangent) of the control point.

pz in : float64

Z-coordinate (position) of the control point.

tz in : float64

Z-coordinate (tangent) of the control point.

pw in : float64

W-coordinate (position) of the control point.

tw in : float64

W-coordinate (tangent) of the control point.

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that does not have tangents will discard the tangent values.

Clear

`public` `method` `Clear` → `()`

returns → ICurve

this

Removes all control points from this curve.

Compute1​D

`[Pure]`
`public` `method` `Compute1D` → `(1)`

index in : float64

The control point index.

returns → float64

The computed point or Maths.NanD if the curve has no control points.

Computes a 1D point along this curve.

Compute2​D

`[Pure]`
`public` `method` `Compute2D` → `(1)`

index in : float64

The control point index.

returns → Vec2D

The computed point or Vec2D.Undefined if the curve has no control points.

Computes a 2D point along this curve.

Compute3​D

`[Pure]`
`public` `method` `Compute3D` → `(1)`

index in : float64

The control point index.

returns → Vec3D

The computed point or Vec3D.Undefined if the curve has no control points.

Computes a 3D point along this curve.

Compute4​D

`[Pure]`
`public` `method` `Compute4D` → `(1)`

index in : float64

The control point index.

returns → Vec4D

The computed point or Vec4D.Undefined if the curve has no control points.

Computes a 4D point along this curve.

Get​At

`[Pure]`
`public` `method` `GetAt` → `(2)`

index in : int32

`[0..ICurve.Count-1]`
The control point index.

which opt : int32 = 0

Chooses the control point value:
`< 0` : the incoming tangent value,
`= 0` : the position value,
`> 0` : the outgoing tangent value.

returns → Vec4D

The control point.

Returns a control point.

Walk​Distance

`[Pure]`
`public` `method` `WalkDistance` → `(2)`

start in : float64

The start control point index. Will be clamped to Range.

end in : float64

The end control point index. Will be clamped to Range.

returns → float64

The walk distance from start in to end in along the curve, using Compute3D for distance computations.

Computes the walk distance from the given start control point to the given end control point.

ICurve.WalkIndex

Walk​Index

`[Pure]`
`public` `method` `WalkIndex` → `(2)`

index in : float64

The index of the control point where to start walking.

distance in : float64

The distance to walk from the given control point. Positive distance values increase the control point index, negative distance values decrease it.

returns → float64

The resulting control point index.

Walks along this curve for the given distance in, starting at the given control point.

Public / Attributes

Continuity

`[Constant]`
`public` `attribute` `Continuity` → `(get)`

value : Continuity

The continuity of this curve.

The continuity type of this curve.

Count

`public` `attribute` `Count` → `(get)`

value : int32

`[>=0]`
The number of control points.

The number of control points.

ICurve.Range

Has​Tangents

`[Constant]`
`public` `attribute` `HasTangents` → `(get)`

value : bool

`true` if control points have tangent values,
`false` if control points do not have tangent values.

Does this curve have tangent values for control points?

Length

`public` `attribute` `Length` → `(get)`

value : float64

`[>=0]`
The curve length, given as the walk distance from the first control point to the last.

Returns the length curve.

Getting this value is equivalent to calling WalkDistance for Range.

Range

`public` `attribute` `Range` → `(get)`

value : RangeD

The control point index range, where RangeD.Start is always zero. Will be RangeD.Zero if Count is `1` or less.

Returns the range of control point indices.

Control points within this range can be used to compute points, without clamping at the first and last control points.

Replicate

`[Constant]`
`public` `attribute` `Replicate` → `(get)`

value : int32

`[0..2]`
The replication count, see remarks.

Returns how many times a control point may be replicated, in order to control the curve.

A control point is replicated by calling one of the `Add*` methods, passing identical position values. The replication count values have the following meaning:

Since the `Add*` methods will drop control points when the replication count is exceeded, the caller must not assume Count, Length or Range is incremented for each call.

Extensions

`public` `static` `method` `Add1` → `(1)`

in : Vec2D

The control point (position).

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that has tangents will specify zero for tangent values.

`public` `static` `method` `Add2` → `(1)`

in : Vec3D

The control point (position).

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that has tangents will specify zero for tangent values.

`public` `static` `method` `Add3` → `(1)`

in : Vec4D

The control point (position).

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that has tangents will specify zero for tangent values.

`public` `static` `method` `Add21` → `(2)`

in : Vec2D

The control point (position).

in : Vec2D

The control point (tangent).

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that does not have tangents will discard the tangent values.

`public` `static` `method` `Add22` → `(2)`

in : Vec3D

The control point (position).

in : Vec3D

The control point (tangent).

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that does not have tangents will discard the tangent values.

`public` `static` `method` `Add23` → `(2)`

in : Vec4D

The control point (position).

in : Vec4D

The control point (tangent).

returns → ICurve

this

Adds a control point to this curve.

Using this method on a curve that does not have tangents will discard the tangent values.

Walk​Distance

`[Pure]`
`public` `static` `method` `WalkDistance` → `(1)`

range in : RangeD

The control point index range. Will be clamped to Range.

returns → float64

The walk distance from RangeD.Start to RangeD.End.

Computes the walk distance from the given start control point to the given end control point.