10using System.Collections;
18 public static class UnityVectorExtension {
28 return new Vector3(vector.
x, vector.
y, vector.
z);
32 return new Vector3(vector.
x, vector.
y, vector.
z);
43 return new Vector4(vector.
x, vector.
y, vector.
z, 0.0f);
53 public static Vector ToVector(
this Vector3 vector) {
54 return new Vector(vector.x, vector.y, vector.z);
57 public static LEAP_VECTOR ToCVector(
this Vector3 vector) {
69 public static class UnityQuaternionExtension {
105 public static class UnityMatrixExtension {
107 public static readonly
Vector LEAP_UP =
new Vector(0, 1, 0);
109 public static readonly
Vector LEAP_FORWARD =
new Vector(0, 0, -1);
111 public static readonly
Vector LEAP_ORIGIN =
new Vector(0, 0, 0);
113 public static readonly
float MM_TO_M = 1e-3f;
140 public static LeapTransform GetLeapMatrix(
this Transform t) {
141 Vector scale =
new Vector(t.lossyScale.x * MM_TO_M, t.lossyScale.y * MM_TO_M, t.lossyScale.z * MM_TO_M);
150 public static void Transform(
this Transform thisTransform, Matrix4x4 transform) {
151 Matrix4x4 newTransform = transform * thisTransform.localToWorldMatrix;
152 thisTransform.position = newTransform.GetVector3();
153 thisTransform.
rotation = newTransform.GetQuaternion();
154 thisTransform.localScale =
Vector3.Scale(thisTransform.localScale,
155 transform.lossyScale);
The LeapQuaternion struct represents a rotation in three-dimensional space.
The Vector struct represents a three-component mathematical vector or point such as a direction or po...