Haply::Inverse::Unity::Utilities::TypeExtensions
Public Functions
Name | |
---|---|
Vector3 | Invert(this Vector3 vec) Inverts a scale vector by dividing 1 by each component. |
bool | CloseTo(this Quaternion q, Quaternion value, float precision) Determines whether two quaternions are close to each other, within a specified precision. |
string | TruncateMiddle(this string input, int maxLength) Truncates a string to a specified maximum length, replacing the middle part with an ellipsis ("...") if necessary. |
Public Functions Documentation
function Invert
static Vector3 Invert(
this Vector3 vec
)
Inverts a scale vector by dividing 1 by each component.
function CloseTo
static bool CloseTo(
this Quaternion q,
Quaternion value,
float precision
)
Determines whether two quaternions are close to each other, within a specified precision.
Parameters:
- q The first quaternion to compare.
- value The second quaternion to compare.
- precision The precision within which the two quaternions are considered close. This is a non-negative value where 0 indicates exact equality, and values closer to 1 allow for greater deviation.
Return: true
if the dot product of the two quaternions is within the specified precision of 1, indicating closeness; otherwise, false
.
This method evaluates the closeness of two quaternions by calculating the dot product between them. A dot product of 1 indicates identical orientation, while values closer to -1 indicate opposite orientations. The precision parameter allows for a margin of error in this comparison, accommodating minor differences between the quaternions.
function TruncateMiddle
static string TruncateMiddle(
this string input,
int maxLength
)
Truncates a string to a specified maximum length, replacing the middle part with an ellipsis ("...") if necessary.
Parameters:
- input The string to truncate.
- maxLength The maximum length of the string after truncation, including the ellipsis.
Return: A string that is truncated in the middle to fit the maxLength, with an ellipsis indicating the truncation point. If the original string is shorter than or equal to maxLength, it is returned unchanged.
This method is useful for displaying long strings in a limited space where the beginning and end of the string contain important information. The method ensures that the total length of the returned string does not exceed maxLength. If truncation is necessary, the method evenly divides the available space (minus three characters for the ellipsis) between the start and end of the string.