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

A struct for managing and interpreting a Vector3 value, including normalization, projection, direction checks, and remapping. More...

Inherits Lemmings.ILemmingConverter.

Public Member Functions

 LemmingVectorizer (Vector3 raw, float minMagnitude, float maxMagnitude)
 Constructs a new LemmingVectorizer.
Vector3 ProjectOnto (Vector3 direction)
 Projects this vector onto another and returns the scalar projection (dot product).
Vector3 ProjectOnto (Quaternion rotation)
 Projects this vector onto the forward direction of a rotation and returns the scalar projection (dot product).
float AngleTo (Vector3 other)
 Returns the angle in degrees between this vector and another vector.
float AngleTo (Quaternion rotation)
 Returns the angle in degrees between this vector and the forward direction of a rotation.
float SignedAngle (Vector3 other, Vector3 axis)
 Returns the signed angle between this vector and another, relative to a given axis.
float ToFloatRange (float outMin, float outMax)
 Remaps the normalized magnitude to a float within a custom range.
int ToIntRange (int minimum, int maximum)
 Remaps the normalized value to an integer range.
int ToIndex (int arraySize)
 Remaps the normalized magnitude to an integer index for an array.
string ToLabel (string[] labels)
 Maps the current value to a label from a list using normalized indexing.
ToEnum< T > ()
 Maps the current value to a member of the specified enum using normalized indexing.
Vector3 ToVector (Vector3 a, Vector3 b)
 Interpolates between two vectors using the normalized magnitude.
Quaternion ToQuaternion (Quaternion a, Quaternion b)
 Interpolates between two rotations using the normalized magnitude.
Quaternion ToRotationAroundAxis (Vector3 axis, float minAngle, float maxAngle)
 Creates a rotation around the given axis based on the normalized magnitude.
Quaternion ToLookRotation (Vector3 up)
 Converts this vector into a look rotation.
float ToCurve (AnimationCurve curve)
 Evaluates the normalized magnitude on an AnimationCurve.
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.
bool IsFacingObject (Transform target, float threshold=0.95f)
 Checks if this vector is facing toward a given Transform.
bool IsFacingObject (GameObject target, float threshold=0.95f)
 Checks if this vector is facing toward a given GameObject.
override string ToString ()
 Returns a string representation of the vector, its magnitude, and normalized value.
void SetRaw (Vector3 newRaw)
 Sets a new raw vector value.
void SetRange (float newMax, float newMin)
 Sets a new maximum magnitude for normalization.
void Reset (Vector3 newRaw, float newMax, float newMin)
 Resets the vector and maximum magnitude.

Data Fields

Vector3 raw
 The raw vector input.
float maxMagnitude
 The maximum expected magnitude used for normalization.
float minMagnitude
 The minimum expected magnitude used for normalization.

Properties

object Raw [get]
float Normalized [get]
 Returns the magnitude of the vector normalized to the range [0, 1].
bool Over [get]
 Returns true if the distance is greater than the maximum Magnitude set.
bool InRange [get]
 Returns true if the magnitude is within the specified range.
bool Under [get]
 Returns true if the distance is less than the minimum Magnitude set.
Vector3 Direction [get]
 Returns the normalized direction of the vector.
bool IsZero [get]
 Returns true if the vector is (0, 0, 0).
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 a Vector3 value, including normalization, projection, direction checks, and remapping.

Constructor & Destructor Documentation

◆ LemmingVectorizer()

Lemmings.LemmingVectorizer.LemmingVectorizer ( Vector3 raw,
float minMagnitude,
float maxMagnitude )
inline

Constructs a new LemmingVectorizer.

Parameters
rawThe input vector.
maxMagnitudeThe maximum magnitude for normalization.
minMagnitudeThe minimum magnitude for normalization

Member Function Documentation

◆ AngleTo() [1/2]

float Lemmings.LemmingVectorizer.AngleTo ( Quaternion rotation)
inline

Returns the angle in degrees between this vector and the forward direction of a rotation.

Parameters
rotationThe rotation whose forward vector is used for comparison.
Returns
The angle in degrees.

◆ AngleTo() [2/2]

float Lemmings.LemmingVectorizer.AngleTo ( Vector3 other)
inline

Returns the angle in degrees between this vector and another vector.

Parameters
otherThe vector to compare against.
Returns
The angle in degrees.

◆ IsFacingDirection()

bool Lemmings.LemmingVectorizer.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

◆ IsFacingObject() [1/2]

bool Lemmings.LemmingVectorizer.IsFacingObject ( GameObject target,
float threshold = 0::95f )
inline

Checks if this vector is facing toward a given GameObject.

Parameters
targetThe target GameObject.
thresholdDot product threshold (default = 0.95).
Returns
True if the vector is approximately facing the GameObject.

◆ IsFacingObject() [2/2]

bool Lemmings.LemmingVectorizer.IsFacingObject ( Transform target,
float threshold = 0::95f )
inline

Checks if this vector is facing toward a given Transform.

Parameters
targetThe target transform.
thresholdDot product threshold (default = 0.95).
Returns
True if the vector is approximately facing the target.

◆ IsFacingPosition()

bool Lemmings.LemmingVectorizer.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.

◆ ProjectOnto() [1/2]

Vector3 Lemmings.LemmingVectorizer.ProjectOnto ( Quaternion rotation)
inline

Projects this vector onto the forward direction of a rotation and returns the scalar projection (dot product).

  • Use this when you want to measure alignment between two directions such as checking if a hand is pointing toward a target or a body part is aligned with a reference axis.
  • Is an object above or below another one, in front or behind? ** example: 1 Vector3 directionToTarget = target.position - transform.position; 2 float alignment = vectorizer.ProjectOnto(directionToTarget);
Parameters
rotationThe rotation whose forward direction is used for projection.
Returns
The projected vector.

◆ ProjectOnto() [2/2]

Vector3 Lemmings.LemmingVectorizer.ProjectOnto ( Vector3 direction)
inline

Projects this vector onto another and returns the scalar projection (dot product).

  • Use this when you want to measure alignment between two directions such as checking if a hand is pointing toward a target or a body part is aligned with a reference axis.
  • Is an object above or below another one, in front or behind? ** example: 1 Vector3 directionToTarget = target.position - transform.position; 2 float alignment = vectorizer.ProjectOnto(directionToTarget);
Parameters
directionThe direction to project onto.
Returns
The projected vector.

◆ Reset()

void Lemmings.LemmingVectorizer.Reset ( Vector3 newRaw,
float newMax,
float newMin )
inline

Resets the vector and maximum magnitude.

Parameters
newRawNew vector value.
newMaxNew max magnitude.
newMinNew min magnitude.

◆ SetRange()

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

Sets a new maximum magnitude for normalization.

Parameters
newMaxThe new max magnitude.
newMinNew min magnitude.

◆ SetRaw()

void Lemmings.LemmingVectorizer.SetRaw ( Vector3 newRaw)
inline

Sets a new raw vector value.

Parameters
newRawThe new vector value.

◆ SignedAngle()

float Lemmings.LemmingVectorizer.SignedAngle ( Vector3 other,
Vector3 axis )
inline

Returns the signed angle between this vector and another, relative to a given axis.

  • Use this to measure rotation in a specific plane, such as turning left/right around the Y axis—great for determining rotation direction relative to a fixed axis.
  • A simpler alternative to tracking rotations without neccesarily using quaternions.
Parameters
otherThe other vector.
axisThe axis around which to measure the angle.
Returns
Signed angle in degrees.

◆ ToCurve()

float Lemmings.LemmingVectorizer.ToCurve ( AnimationCurve curve)
inline

Evaluates the normalized magnitude on an AnimationCurve.

Parameters
curveThe curve to evaluate.
Returns
The curve output at the normalized magnitude.

Implements Lemmings.ILemmingConverter.

◆ ToEnum< T >()

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

Maps the current value to a member of the specified enum using normalized indexing.

Template Parameters
TThe enum type to map to.
Returns
A member of the enum.
Type Constraints
T :Enum 

◆ ToFloatRange()

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

Remaps the normalized magnitude to a float within a custom range.

Parameters
outMinThe minimum output value.
outMaxThe maximum output value.
Returns
A float between outMin and outMax.

◆ ToIndex()

int Lemmings.LemmingVectorizer.ToIndex ( int arraySize)
inline

Remaps the normalized magnitude to an integer index for an array.

Parameters
arraySizeThe size of the array.
Returns
Clamped array index based on normalized value.

◆ ToIntRange()

int Lemmings.LemmingVectorizer.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.LemmingVectorizer.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.

◆ ToLookRotation()

Quaternion Lemmings.LemmingVectorizer.ToLookRotation ( Vector3 up)
inline

Converts this vector into a look rotation.

Parameters
upThe up vector to use for rotation stability.
Returns
A Quaternion facing in the direction of the vector.

◆ ToQuaternion()

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

Interpolates between two rotations using the normalized magnitude.

Parameters
aStart rotation.
bEnd rotation.
Returns
An interpolated Quaternion.

◆ ToRotationAroundAxis()

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

Creates a rotation around the given axis based on the normalized magnitude.

Parameters
axisAxis to rotate around (should be normalized).
minAngleMinimum rotation in degrees.
maxAngleMaximum rotation in degrees.
Returns
A Quaternion representing the rotation.

◆ ToVector()

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

Interpolates between two vectors using the normalized magnitude.

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

Property Documentation

◆ AsAxis

float Lemmings.LemmingVectorizer.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.LemmingVectorizer.InRange
get

Returns true if the magnitude is within the specified range.

Implements Lemmings.ILemmingConverter.

◆ Normalized

float Lemmings.LemmingVectorizer.Normalized
get

Returns the magnitude of the vector normalized to the range [0, 1].

Implements Lemmings.ILemmingConverter.

◆ Over

bool Lemmings.LemmingVectorizer.Over
get

Returns true if the distance is greater than the maximum Magnitude set.

Implements Lemmings.ILemmingConverter.

◆ Raw

object Lemmings.LemmingVectorizer.Raw
get

◆ Under

bool Lemmings.LemmingVectorizer.Under
get

Returns true if the distance is less than the minimum Magnitude set.

Implements Lemmings.ILemmingConverter.


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