Header menu 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.Add

Full Usage: this.Add

Parameters:
Returns: Rotation2D
Modifiers: inline

Create a new 2D Rotation that adds a 2D Rotation to the existing one.

ro : Rotation2D
Returns: Rotation2D

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.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
Modifiers: inline

Returns half the 2D Rotation in the same direction.

Returns: Rotation2D

this.InDegrees

Full Usage: this.InDegrees

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.InRadians

Full Usage: this.InRadians

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.Inverse

Full Usage: this.Inverse

Returns: Rotation2D
Modifiers: inline

Returns the 2D Rotation in the opposite direction.

Returns: Rotation2D

Static members

Static member Description

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.createFromVectors (a, b)

Full Usage: Rotation2D.createFromVectors (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.createFromVectors (a, b)

Full Usage: Rotation2D.createFromVectors (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.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.equals tol a b

Full Usage: Rotation2D.equals 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 a tolerance of 0.0 to check for an exact match.

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

Type something to start searching.