Lemmings
Remappable Gestures For Unity
Loading...
Searching...
No Matches
Lemmings.LemmingRotater Struct Reference

A struct for managing and interpreting Quaternion rotations, including angular comparison, interpolation, remapping, and directional checks. More...

Inherits Lemmings.ILemmingConverter.

Public Member Functions

 LemmingRotater (Quaternion raw, float maxAngle, float minAngle)
 Constructs a new LemmingRotater with a rotation and max angle.
float AngleTo (Quaternion target)
 Returns the angular difference in degrees between this rotation and another quaternion.
float AngleTo (Vector3 direction)
 Returns the angular difference in degrees between the direction this quaternion faces and a world-space direction vector.
Quaternion ToQuaternion (Quaternion a, Quaternion b)
 Interpolates between two quaternions based on the normalized value.
Vector3 ToVector (Vector3 a, Vector3 b)
 Interpolates between two vectors using the normalized factor.
float ToFloatRange (float outMin, float outMax)
 Remaps the normalized value to a float between outMin and outMax.
int ToIntRange (int minimum, int maximum)
 Remaps the normalized value to an integer range.
string ToLabel (string[] labels)
 Maps the current value to a label from a list using normalized indexing.
float ToCurve (AnimationCurve curve)
 Evaluates the normalized value on a Unity AnimationCurve.
Vector3 Axis ()
 Returns the axis of rotation from the stored quaternion.
float Angle ()
 Returns the rotation angle (in degrees) represented by the quaternion.
Vector3 ProjectOnto (Vector3 direction)
 Projects the forward direction of this rotation onto the given vector.
Vector3 ProjectOnto (Quaternion rotation)
 Projects the forward direction of this rotation onto another rotation's forward direction.
bool IsMatchingRotation (Quaternion target, float threshold=0.95f)
 Checks whether this rotation is facing approximately the same direction as another.
Quaternion ToRotationAroundAxis (Vector3 axis, float minAngle, float maxAngle)
 Converts the normalized rotation value to a rotation around the given axis using a remapped angle range.
bool IsFacingPosition (Vector3 targetPosition, Vector3 currentPosition, float threshold=0.95f)
 Checks if this rotation is approximately facing toward a given world position.
bool IsFacingDirection (Vector3 direction, float threshold=0.95f)
 Checks if the rotation is pointed towards a given direction using a threshold.
int ToIndex (int arraySize)
 Maps the normalized value to an array index.
ToEnum< T > ()
 Maps the normalized value to an enum value based on index.
override string ToString ()
 Returns a formatted string summarizing the raw rotation, angle, and normalized value.
void SetRaw (Quaternion newRotation)
 Sets the internal rotation to a new value.
void SetRange (float newMax, float newMin)
 Sets the maxAngle used for normalization.
void Reset (Quaternion newRotation, float newMaxAngle, float newMinAngle)
 Resets the internal rotation and maxAngle to new values.

Data Fields

Quaternion raw
 The raw Quaternion value representing a 3D rotation.
float maxAngle
 The maximum angle used to normalize the rotation magnitude.
float minAngle
 The minimum angle used to normalize the rotation magnitude.

Properties

object Raw [get]
 The raw Quaternion value representing a 3D rotation.
float Normalized [get]
 Returns the normalized value between minAngle and maxAngle.
bool Over [get]
 Returns true if the angle is greater than the maximum angle set.
bool InRange [get]
 Returns true if the angle is within the specified range.
bool Under [get]
 Returns true if the angle is less than the maximum angle set.
bool IsZero [get]
 Returns true if the quaternion represents the identity rotation (no rotation).
Vector3 Direction [get]
 Returns the direction the quaternion is facing.
float AsAxis [get]
 This provides the normalized value in a range of -1 to 1, useful for input mapping and relative values.

Detailed Description

A struct for managing and interpreting Quaternion rotations, including angular comparison, interpolation, remapping, and directional checks.

Quaternions represent 3D rotation in a stable, interpolation-friendly form. Use them for smooth orientation tracking, angle comparisons, and gesture dynamics. They avoid gimbal lock and provide consistent behavior when interpolating or blending.

Constructor & Destructor Documentation

◆ LemmingRotater()

Lemmings.LemmingRotater.LemmingRotater ( Quaternion raw,
float maxAngle,
float minAngle )
inline

Constructs a new LemmingRotater with a rotation and max angle.

Parameters
rawThe rotation to store.
maxAngleThe angle to use for normalization reference.

Member Function Documentation

◆ Angle()

float Lemmings.LemmingRotater.Angle ( )
inline

Returns the rotation angle (in degrees) represented by the quaternion.

Returns
The angle in degrees around the axis of rotation.

◆ AngleTo() [1/2]

float Lemmings.LemmingRotater.AngleTo ( Quaternion target)
inline

Returns the angular difference in degrees between this rotation and another quaternion.

Parameters
targetThe target rotation to compare to.
Returns
The angle in degrees between the two rotations.

◆ AngleTo() [2/2]

float Lemmings.LemmingRotater.AngleTo ( Vector3 direction)
inline

Returns the angular difference in degrees between the direction this quaternion faces and a world-space direction vector.

Parameters
directionThe world-space direction to compare against.
Returns
The angle in degrees between this rotation's forward direction and the given direction.

◆ Axis()

Vector3 Lemmings.LemmingRotater.Axis ( )
inline

Returns the axis of rotation from the stored quaternion.

Returns
A normalized Vector3 representing the axis of rotation.

◆ IsFacingDirection()

bool Lemmings.LemmingRotater.IsFacingDirection ( Vector3 direction,
float threshold = 0::95f )
inline

Checks if the rotation is pointed towards a given direction using a threshold.

Parameters
directionDirection to check against
thresholdThe dot product threshold for detection (default = 0.95)
Returns

◆ IsFacingPosition()

bool Lemmings.LemmingRotater.IsFacingPosition ( Vector3 targetPosition,
Vector3 currentPosition,
float threshold = 0::95f )
inline

Checks if this rotation is approximately facing toward a given world position.

Parameters
targetPositionThe position to face.
currentPositionThe current position.
thresholdThe dot product threshold (default = 0.95).
Returns
True if the rotation is approximately facing the target.

◆ IsMatchingRotation()

bool Lemmings.LemmingRotater.IsMatchingRotation ( Quaternion target,
float threshold = 0::95f )
inline

Checks whether this rotation is facing approximately the same direction as another.

Parameters
targetThe target rotation to compare to.
thresholdThe dot product threshold to consider as aligned (default = 0.95).
Returns
True if the dot product is greater than or equal to the threshold.

◆ ProjectOnto() [1/2]

Vector3 Lemmings.LemmingRotater.ProjectOnto ( Quaternion rotation)
inline

Projects the forward direction of this rotation onto another rotation's forward direction.

Parameters
rotationThe rotation whose direction to project onto.
Returns
The projected vector.

◆ ProjectOnto() [2/2]

Vector3 Lemmings.LemmingRotater.ProjectOnto ( Vector3 direction)
inline

Projects the forward direction of this rotation onto the given vector.

Parameters
directionThe direction to project onto.
Returns
The projected vector.

◆ Reset()

void Lemmings.LemmingRotater.Reset ( Quaternion newRotation,
float newMaxAngle,
float newMinAngle )
inline

Resets the internal rotation and maxAngle to new values.

Parameters
newRotationThe new Quaternion value.
newMaxAngleThe new maximum angle.

///

Parameters
newMinAngleThe new minimum angle.

◆ SetRange()

void Lemmings.LemmingRotater.SetRange ( float newMax,
float newMin )
inline

Sets the maxAngle used for normalization.

Parameters
newMaxThe new maximum angle.

///

Parameters
newMinThe new minimum angle.

◆ SetRaw()

void Lemmings.LemmingRotater.SetRaw ( Quaternion newRotation)
inline

Sets the internal rotation to a new value.

Parameters
newRotationThe new Quaternion rotation.

◆ ToCurve()

float Lemmings.LemmingRotater.ToCurve ( AnimationCurve curve)
inline

Evaluates the normalized value on a Unity AnimationCurve.

Parameters
curveThe curve to evaluate.
Returns
A float representing the curve output at the normalized position.

Implements Lemmings.ILemmingConverter.

◆ ToEnum< T >()

T Lemmings.LemmingRotater.ToEnum< T > ( )
inline

Maps the normalized value to an enum value based on index.

Template Parameters
TThe enum type to convert to.
Returns
An enum value mapped from the normalized value.
Type Constraints
T :Enum 

◆ ToFloatRange()

float Lemmings.LemmingRotater.ToFloatRange ( float outMin,
float outMax )
inline

Remaps the normalized value to a float between outMin and outMax.

Parameters
outMinMinimum output value.
outMaxMaximum output value.
Returns
A float value interpolated from outMin to outMax.

◆ ToIndex()

int Lemmings.LemmingRotater.ToIndex ( int arraySize)
inline

Maps the normalized value to an array index.

Parameters
arraySizeThe total number of elements in the array.
Returns
An index in the range [0, arraySize - 1].

◆ ToIntRange()

int Lemmings.LemmingRotater.ToIntRange ( int minimum,
int maximum )
inline

Remaps the normalized value to an integer range.

Parameters
minimumMinimum integer output value.
maximumMaximum integer output value.
Returns
Integer within [minimum , maximum ].

◆ ToLabel()

string Lemmings.LemmingRotater.ToLabel ( string[] labels)
inline

Maps the current value to a label from a list using normalized indexing.

Parameters
labelsAn array of string labels.
Returns
A string from the array corresponding to the current value.

◆ ToQuaternion()

Quaternion Lemmings.LemmingRotater.ToQuaternion ( Quaternion a,
Quaternion b )
inline

Interpolates between two quaternions based on the normalized value.

Parameters
aThe start rotation.
bThe end rotation.
Returns
An interpolated Quaternion based on the normalized factor.

◆ ToRotationAroundAxis()

Quaternion Lemmings.LemmingRotater.ToRotationAroundAxis ( Vector3 axis,
float minAngle,
float maxAngle )
inline

Converts the normalized rotation value to a rotation around the given axis using a remapped angle range.

Parameters
axisThe axis to rotate around (e.g., Vector3.up).
minAngleThe minimum angle in degrees.
maxAngleThe maximum angle in degrees.
Returns
A Quaternion representing the rotation around the specified axis.

◆ ToString()

override string Lemmings.LemmingRotater.ToString ( )
inline

Returns a formatted string summarizing the raw rotation, angle, and normalized value.

Returns
A human-readable string for debugging or display.

◆ ToVector()

Vector3 Lemmings.LemmingRotater.ToVector ( Vector3 a,
Vector3 b )
inline

Interpolates between two vectors using the normalized factor.

Parameters
aThe start vector.
bThe end vector.
Returns
An interpolated Vector3 between a and b.

Property Documentation

◆ AsAxis

float Lemmings.LemmingRotater.AsAxis
get

This provides the normalized value in a range of -1 to 1, useful for input mapping and relative values.

Implements Lemmings.ILemmingConverter.

◆ InRange

bool Lemmings.LemmingRotater.InRange
get

Returns true if the angle is within the specified range.

Implements Lemmings.ILemmingConverter.

◆ Normalized

float Lemmings.LemmingRotater.Normalized
get

Returns the normalized value between minAngle and maxAngle.

Implements Lemmings.ILemmingConverter.

◆ Over

bool Lemmings.LemmingRotater.Over
get

Returns true if the angle is greater than the maximum angle set.

Implements Lemmings.ILemmingConverter.

◆ Raw

object Lemmings.LemmingRotater.Raw
get

The raw Quaternion value representing a 3D rotation.

Implements Lemmings.ILemmingConverter.

◆ Under

bool Lemmings.LemmingRotater.Under
get

Returns true if the angle is less than the maximum angle set.

Implements Lemmings.ILemmingConverter.


The documentation for this struct was generated from the following file:
  • Assets/Lemmings/Scripts/Namespace/LemmingConverterStructs.cs