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
|
Full Usage:
Cos
Field type: float
|
The Cosine component of this rotation. The range of this field is -1.0 to +1.0
|
Full Usage:
Sin
Field type: float
|
The Sine component of this rotation. The range of this field is -1.0 to +1.0
|
Instance members
| Instance member |
Description
|
|
Create a new 2D Rotation that adds a counter-clockwise angle in degrees to the existing one.
|
|
Create a new 2D Rotation that adds a counter-clockwise angle in radians to the existing one.
|
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°].
|
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°).
|
Full Usage:
this.AsFSharpCode
Returns: string
|
Format Rotation2D into an F# code string that can be used to recreate the rotation.
|
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 half the shortest signed rotation. For a 180-degree rotation, returns +90 degrees (counter-clockwise)
|
|
Returns the 2D Rotation in the opposite direction.
|
Full Usage:
this.ScaleAngle
Parameters:
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.
|
Full Usage:
this.Slerp
Parameters:
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.
|
Full Usage:
this.Then
Parameters:
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.
|
Static members
| Static member |
Description
|
|
The rotation that leaves points and vectors unchanged.
|
Full Usage:
Rotation2D.addDegrees deg r
Parameters:
float
r : Rotation2D
Returns: Rotation2D
Modifiers: inline |
Create a new 2D Rotation that adds a counter-clockwise angle in degrees to the existing one.
|
Full Usage:
Rotation2D.addRadians rad r
Parameters:
float
r : Rotation2D
Returns: Rotation2D
Modifiers: inline |
Create a new 2D Rotation that adds a counter-clockwise angle in radians to the existing one.
|
Full Usage:
Rotation2D.andThen ro r
Parameters:
Rotation2D
-
The rotation applied second.
r : Rotation2D
-
The rotation applied first.
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.
|
|
Returns the angle represented by this 2D Rotation in degrees. The returned angle is in the range [-180°, +180°].
|
|
Returns the angle represented by this 2D Rotation in radians. The returned angle is in the range [-π, π] (-180° to +180°).
|
|
Format Rotation2D into an F# code string that can be used to recreate the rotation.
|
|
Format rotation into string showing angle in degrees as nicely formatted floating point number. But without type name as in r.ToString()
|
Full Usage:
Rotation2D.create sine cosine
Parameters:
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.
|
Full Usage:
Rotation2D.createFromCosine cos
Parameters:
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, π].
|
Full Usage:
Rotation2D.createFromDegrees deg
Parameters:
float
Returns: Rotation2D
Modifiers: inline |
Construct a counter-clockwise 2D Rotation from angle in degrees. Use negative degrees for clockwise rotation.
|
Full Usage:
Rotation2D.createFromRadians rad
Parameters:
float
Returns: Rotation2D
Modifiers: inline |
Construct a counter-clockwise 2D Rotation from angle in radians. Use negative radians for clockwise rotation.
|
Full Usage:
Rotation2D.createFromSine sin
Parameters:
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].
|
|
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.
|
|
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.
|
Full Usage:
Rotation2D.createUnchecked (sine, cosine)
Parameters:
float
cosine : float
Returns: Rotation2D
Modifiers: inline |
Construct 2D Rotation from sine and corresponding cosine directly. Input is unchecked and not validated.
|
Full Usage:
Rotation2D.equalsExact a b
Parameters:
Rotation2D
b : Rotation2D
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.
|
Full Usage:
Rotation2D.equalsWithin tol a b
Parameters:
float
a : Rotation2D
b : Rotation2D
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.
|
Full Usage:
Rotation2D.half rotation
Parameters:
Rotation2D
-
The rotation to halve.
Returns: Rotation2D
The half rotation.
Modifiers: inline |
Returns half the shortest signed rotation. For a 180-degree rotation, returns +90 degrees (counter-clockwise)
|
|
|
Full Usage:
Rotation2D.scaleAngle factor rotation
Parameters:
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.
|
Full Usage:
Rotation2D.slerp start finish factor
Parameters:
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.
|
Euclid