Logo Euclid

Rotation2D Type

A struct containing 2 floats, representing a 2D counter-clockwise rotation. It can be applied in World X, Y or Z plane. Internally stored just as a Sine and Cosine value. For arbitrary rotations use Quaternions or 4x4 Matrix. However this module has much better performance than the more general Matrix4x4 or a Quaternion. Note: Never use the struct default constructor Rotation2D() as it will create an invalid zero Rotation2D. Use Rotation2D.createFromRadians, Rotation2D.createFromDegrees, or Rotation2D.createUnchecked instead.

Record fields

Record Field Description

Cos

Full Usage: Cos

Field type: float

The Cosine component of this rotation. The range of this field is -1.0 to +1.0

Field type: float

Sin

Full Usage: Sin

Field type: float

The Sine component of this rotation. The range of this field is -1.0 to +1.0

Field type: float

Instance members

Instance member Description

this.AddDegrees

Full Usage: this.AddDegrees

Parameters:
    deg : float

Returns: Rotation2D
Modifiers: inline

Create a new 2D Rotation that adds a counter-clockwise angle in degrees to the existing one.

deg : float
Returns: Rotation2D

this.AddRadians

Full Usage: this.AddRadians

Parameters:
    rad : float

Returns: Rotation2D
Modifiers: inline

Create a new 2D Rotation that adds a counter-clockwise angle in radians to the existing one.

rad : float
Returns: Rotation2D

this.AngleInDegrees

Full Usage: this.AngleInDegrees

Returns: float
Modifiers: inline

Returns the angle represented by this 2D Rotation in degrees. The returned angle is in the range [-180°, +180°].

Returns: float

this.AngleInRadians

Full Usage: this.AngleInRadians

Returns: float
Modifiers: inline

Returns the angle represented by this 2D Rotation in radians. The returned angle is in the range [-π, π] (-180° to +180°).

Returns: float

this.AsFSharpCode

Full Usage: this.AsFSharpCode

Returns: string

Format Rotation2D into an F# code string that can be used to recreate the rotation.

Returns: string

this.AsString

Full Usage: this.AsString

Returns: string

Format rotation into string showing angle in degrees as nicely formatted floating point number. But without type name as in r.ToString()

Returns: string

this.Half

Full Usage: this.Half

Returns: Rotation2D The half rotation.
Modifiers: inline

Returns half the shortest signed rotation. For a 180-degree rotation, returns +90 degrees (counter-clockwise)

Returns: Rotation2D

The half rotation.

this.Inverse

Full Usage: this.Inverse

Returns: Rotation2D
Modifiers: inline

Returns the 2D Rotation in the opposite direction.

Returns: Rotation2D

this.ScaleAngle

Full Usage: this.ScaleAngle

Parameters:
    factor : float - The finite multiplier applied to the signed angle.

Returns: Rotation2D A new 2D rotation; identity remains identity.

Scales AngleInRadians, the signed angle in [-180, 180] degrees. Negative factors reverse the rotation; factors above one extend it. The factor is not clamped. Full turns are not retained by Rotation2D: scaling a 270-degree rotation by 0.25 gives -22.5 degrees. Fails if the factor or scaled angle is NaN or infinite.

factor : float

The finite multiplier applied to the signed angle.

Returns: Rotation2D

A new 2D rotation; identity remains identity.

this.Slerp

Full Usage: this.Slerp

Parameters:
    finish : Rotation2D - The rotation at factor 1.
    factor : float - The finite interpolation factor.

Returns: Rotation2D A new 2D rotation.

Spherical linear interpolation from this rotation to another one. The angle changes at a constant rate along the shortest way from this rotation to finish. If the two rotations are exactly 180 degrees apart, the way goes counter-clockwise. Factor 0 returns this rotation and factor 1 returns finish. The factor is not clamped: negative factors and factors above one extrapolate the rotation. Fails if the factor is NaN or infinite.

finish : Rotation2D

The rotation at factor 1.

factor : float

The finite interpolation factor.

Returns: Rotation2D

A new 2D rotation.

this.Then

Full Usage: this.Then

Parameters:
    ro : Rotation2D - The other rotation (applied second).

Returns: Rotation2D A new 2D Rotation that rotates like this one followed by ro.
Modifiers: inline

Combines this rotation with another one. The resulting rotation will first do this rotation and then the other one, like Quaternion.Then, Matrix.Then and RigidMatrix.Then. In 2D the rotation angles just add up.

ro : Rotation2D

The other rotation (applied second).

Returns: Rotation2D

A new 2D Rotation that rotates like this one followed by ro.

Static members

Static member Description

Rotation2D.Identity

Full Usage: Rotation2D.Identity

Returns: Rotation2D Sine zero and cosine one.
Modifiers: inline

The rotation that leaves points and vectors unchanged.

Returns: Rotation2D

Sine zero and cosine one.

Rotation2D.addDegrees deg r

Full Usage: Rotation2D.addDegrees deg r

Parameters:
Returns: Rotation2D
Modifiers: inline

Create a new 2D Rotation that adds a counter-clockwise angle in degrees to the existing one.

deg : float
r : Rotation2D
Returns: Rotation2D

Rotation2D.addRadians rad r

Full Usage: Rotation2D.addRadians rad r

Parameters:
Returns: Rotation2D
Modifiers: inline

Create a new 2D Rotation that adds a counter-clockwise angle in radians to the existing one.

rad : float
r : Rotation2D
Returns: Rotation2D

Rotation2D.andThen ro r

Full Usage: Rotation2D.andThen ro r

Parameters:
Returns: Rotation2D A new 2D Rotation that rotates like r followed by ro.
Modifiers: inline

Combines two rotations for use in a pipeline: 'r |> Rotation2D.andThen ro' first does r and then ro. Same as r.Then ro.

ro : Rotation2D

The rotation applied second.

r : Rotation2D

The rotation applied first.

Returns: Rotation2D

A new 2D Rotation that rotates like r followed by ro.

Rotation2D.angleInDegrees r

Full Usage: Rotation2D.angleInDegrees r

Parameters:
Returns: float
Modifiers: inline

Returns the angle represented by this 2D Rotation in degrees. The returned angle is in the range [-180°, +180°].

r : Rotation2D
Returns: float

Rotation2D.angleInRadians r

Full Usage: Rotation2D.angleInRadians r

Parameters:
Returns: float
Modifiers: inline

Returns the angle represented by this 2D Rotation in radians. The returned angle is in the range [-π, π] (-180° to +180°).

r : Rotation2D
Returns: float

Rotation2D.asFSharpCode r

Full Usage: Rotation2D.asFSharpCode r

Parameters:
Returns: string
Modifiers: inline

Format Rotation2D into an F# code string that can be used to recreate the rotation.

r : Rotation2D
Returns: string

Rotation2D.asString r

Full Usage: Rotation2D.asString r

Parameters:
Returns: string
Modifiers: inline

Format rotation into string showing angle in degrees as nicely formatted floating point number. But without type name as in r.ToString()

r : Rotation2D
Returns: string

Rotation2D.create sine cosine

Full Usage: Rotation2D.create sine cosine

Parameters:
    sine : float
    cosine : float

Returns: Rotation2D

Construct a 2D rotation from sine and cosine components. Fails if the components do not form a unit-length pair. Unlike Quaternion.create, this does not normalize its input, it only validates it.

sine : float
cosine : float
Returns: Rotation2D

Rotation2D.createFromCosine cos

Full Usage: Rotation2D.createFromCosine cos

Parameters:
    cos : float

Returns: Rotation2D
Modifiers: inline

Construct a counter-clockwise 2D Rotation from angle given in its cosine value. The input must be in the range [-1.0, +1.0]. Note: Only angles in the range [0°, 180°] can be created since acos returns values in [0, π].

cos : float
Returns: Rotation2D

Rotation2D.createFromDegrees deg

Full Usage: Rotation2D.createFromDegrees deg

Parameters:
    deg : float

Returns: Rotation2D
Modifiers: inline

Construct a counter-clockwise 2D Rotation from angle in degrees. Use negative degrees for clockwise rotation.

deg : float
Returns: Rotation2D

Rotation2D.createFromRadians rad

Full Usage: Rotation2D.createFromRadians rad

Parameters:
    rad : float

Returns: Rotation2D
Modifiers: inline

Construct a counter-clockwise 2D Rotation from angle in radians. Use negative radians for clockwise rotation.

rad : float
Returns: Rotation2D

Rotation2D.createFromSine sin

Full Usage: Rotation2D.createFromSine sin

Parameters:
    sin : float

Returns: Rotation2D
Modifiers: inline

Construct a counter-clockwise 2D Rotation from angle given in its sine value. The input must be in the range [-1.0, +1.0]. Note: Only angles in the range [-90°, +90°] can be created since asin returns values in [-π/2, π/2].

sin : float
Returns: Rotation2D

Rotation2D.createFromUnitVcs a b

Full Usage: Rotation2D.createFromUnitVcs a b

Parameters:
Returns: Rotation2D

Construct a 2D Rotation from two unit vectors. The rotation represents the counter-clockwise angle from vector 'a' to vector 'b'. Uses the dot product for cosine and cross product for sine.

a : UnitVc
b : UnitVc
Returns: Rotation2D

Rotation2D.createFromVcs a b

Full Usage: Rotation2D.createFromVcs a b

Parameters:
Returns: Rotation2D

Construct a 2D Rotation from two 2D vectors. The rotation represents the counter-clockwise angle from vector 'a' to vector 'b'. Normalizes both vectors internally and uses dot product for cosine and cross product for sine. Fails if either vector has near-zero length.

a : Vc
b : Vc
Returns: Rotation2D

Rotation2D.createUnchecked (sine, cosine)

Full Usage: Rotation2D.createUnchecked (sine, cosine)

Parameters:
    sine : float
    cosine : float

Returns: Rotation2D
Modifiers: inline

Construct 2D Rotation from sine and corresponding cosine directly. Input is unchecked and not validated.

sine : float
cosine : float
Returns: Rotation2D

Rotation2D.equalsExact a b

Full Usage: Rotation2D.equalsExact a b

Parameters:
Returns: bool
Modifiers: inline

Checks if two 2D Rotations are exactly equal. Compares each field with the = operator, so a NaN value is never equal.

a : Rotation2D
b : Rotation2D
Returns: bool

Rotation2D.equalsWithin tol a b

Full Usage: Rotation2D.equalsWithin tol a b

Parameters:
Returns: bool
Modifiers: inline

Checks if two 2D Rotations are equal within tolerance. By comparing the fields Sin and Cos each with the given tolerance. The range of these fields is -1.0 to +1.0 Use Rotation2D.equalsExact to check for an exact match.

tol : float
a : Rotation2D
b : Rotation2D
Returns: bool

Rotation2D.half rotation

Full Usage: Rotation2D.half rotation

Parameters:
Returns: Rotation2D The half rotation.
Modifiers: inline

Returns half the shortest signed rotation. For a 180-degree rotation, returns +90 degrees (counter-clockwise)

rotation : Rotation2D

The rotation to halve.

Returns: Rotation2D

The half rotation.

Rotation2D.inverse r

Full Usage: Rotation2D.inverse r

Parameters:
Returns: Rotation2D
Modifiers: inline

Returns the 2D Rotation in the opposite direction.

r : Rotation2D
Returns: Rotation2D

Rotation2D.scaleAngle factor rotation

Full Usage: Rotation2D.scaleAngle factor rotation

Parameters:
    factor : float - The finite angle multiplier; negative values and values above one are supported.
    rotation : Rotation2D - The 2D rotation whose signed angle is scaled.

Returns: Rotation2D A new 2D rotation; identity remains identity.
Modifiers: inline

Scales AngleInRadians, the signed angle in [-180, 180] degrees. The factor is not clamped. Full turns are not retained by Rotation2D. Fails if the factor or scaled angle is NaN or infinite.

factor : float

The finite angle multiplier; negative values and values above one are supported.

rotation : Rotation2D

The 2D rotation whose signed angle is scaled.

Returns: Rotation2D

A new 2D rotation; identity remains identity.

Rotation2D.slerp start finish factor

Full Usage: Rotation2D.slerp start finish factor

Parameters:
    start : Rotation2D - The rotation at factor 0.
    finish : Rotation2D - The rotation at factor 1.
    factor : float - The finite interpolation factor.

Returns: Rotation2D A new 2D rotation.
Modifiers: inline

Spherical linear interpolation between two rotations. The angle changes at a constant rate along the shortest way from start to finish. If the two rotations are exactly 180 degrees apart, the way goes counter-clockwise. Factor 0 returns start and factor 1 returns finish. The factor is not clamped: negative factors and factors above one extrapolate the rotation. Fails if the factor is NaN or infinite.

start : Rotation2D

The rotation at factor 0.

finish : Rotation2D

The rotation at factor 1.

factor : float

The finite interpolation factor.

Returns: Rotation2D

A new 2D rotation.

Type something to start searching.