/// <summary> /// Transforms a vector using the transpose of a matrix. /// </summary> /// <param name="v">Vector to transform.</param> /// <param name="matrix">Transform to tranpose and apply to the vector.</param> /// <param name="result">Transformed vector.</param> public static void TransformTranspose(fix3 v, fix4x4 matrix, out fix4 result) { result.x = v.x * matrix.M11 + v.y * matrix.M21 + v.z * matrix.M31 + matrix.M41; result.y = v.x * matrix.M12 + v.y * matrix.M22 + v.z * matrix.M32 + matrix.M42; result.z = v.x * matrix.M13 + v.y * matrix.M23 + v.z * matrix.M33 + matrix.M43; result.w = v.x * matrix.M14 + v.y * matrix.M24 + v.z * matrix.M34 + matrix.M44; }
/// <summary> /// Transforms a vector using a matrix. /// </summary> /// <param name="v">Vector to transform.</param> /// <param name="matrix">Transform to apply to the vector.</param> /// <param name="result">Transformed vector.</param> public static void Transform(fix3 v, fix4x4 matrix, out fix4 result) { result.x = v.x * matrix.M11 + v.y * matrix.M12 + v.z * matrix.M13 + matrix.M14; result.y = v.x * matrix.M21 + v.y * matrix.M22 + v.z * matrix.M23 + matrix.M24; result.z = v.x * matrix.M31 + v.y * matrix.M32 + v.z * matrix.M33 + matrix.M34; result.w = v.x * matrix.M41 + v.y * matrix.M42 + v.z * matrix.M43 + matrix.M44; }
/// <summary> /// Transforms a vector using the transpose of a matrix. /// </summary> /// <param name="v">Vector to transform.</param> /// <param name="matrix">Transform to tranpose and apply to the vector.</param> /// <returns>Transformed vector.</returns> public static fix4 TransformTranspose(fix4 v, fix4x4 matrix) { fix4 toReturn; TransformTranspose(v, matrix, out toReturn); return(toReturn); }
/// <summary> /// Transforms a vector using the transpose of a matrix. /// </summary> /// <param name="v">Vector to transform.</param> /// <param name="matrix">Transform to tranpose and apply to the vector.</param> /// <param name="result">Transformed vector.</param> public static void TransformTranspose(fix4 v, fix4x4 matrix, out fix4 result) { fix vX = v.x; fix vY = v.y; fix vZ = v.z; fix vW = v.w; result.x = vX * matrix.M11 + vY * matrix.M21 + vZ * matrix.M31 + vW * matrix.M41; result.y = vX * matrix.M12 + vY * matrix.M22 + vZ * matrix.M32 + vW * matrix.M42; result.z = vX * matrix.M13 + vY * matrix.M23 + vZ * matrix.M33 + vW * matrix.M43; result.w = vX * matrix.M14 + vY * matrix.M24 + vZ * matrix.M34 + vW * matrix.M44; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { SerializedProperty xProp = property.FindPropertyRelative(nameof(fix4.x)).FindPropertyRelative(nameof(fix.RawValue)); SerializedProperty yProp = property.FindPropertyRelative(nameof(fix4.y)).FindPropertyRelative(nameof(fix.RawValue)); SerializedProperty zProp = property.FindPropertyRelative(nameof(fix4.z)).FindPropertyRelative(nameof(fix.RawValue)); SerializedProperty wProp = property.FindPropertyRelative(nameof(fix4.w)).FindPropertyRelative(nameof(fix.RawValue)); fix xVal; fix yVal; fix zVal; fix wVal; xVal.RawValue = xProp.longValue; yVal.RawValue = yProp.longValue; zVal.RawValue = zProp.longValue; wVal.RawValue = wProp.longValue; fix4 oldFixVec = new fix4(xVal, yVal, zVal, wVal); // Using BeginProperty / EndProperty on the parent property means that // prefab override logic works on the entire property. EditorGUI.BeginProperty(position, label, property); // Editor Field Vector4 oldVec = oldFixVec.ToUnityVec(); Vector4 newVec = EditorGUI.Vector4Field(position, label, oldVec); // Change ? if (oldVec != newVec) { fix4 newFixVec = newVec.ToFixVec(); xProp.longValue = newFixVec.x.RawValue; yProp.longValue = newFixVec.y.RawValue; zProp.longValue = newFixVec.z.RawValue; wProp.longValue = newFixVec.w.RawValue; } EditorGUI.EndProperty(); }
public static fix distancemanhattan(fix4 x, fix4 y) { return(lengthmanhattan(y - x)); }
public static fix lengthmanhattan(fix4 v) => abs(v.x) + abs(v.y) + abs(v.z) + abs(v.w);
public static int4 ceilToInt(fix4 v) => int4(global::fix.CeilingToInt(v.x), global::fix.CeilingToInt(v.y), global::fix.CeilingToInt(v.z), global::fix.CeilingToInt(v.w));
public static int4 floorToInt(fix4 v) => int4(global::fix.FloorToInt(v.x), global::fix.FloorToInt(v.y), global::fix.FloorToInt(v.z), global::fix.FloorToInt(v.w));
public static int4 roundToInt(fix4 v) => int4(global::fix.RoundToInt(v.x), global::fix.RoundToInt(v.y), global::fix.RoundToInt(v.z), global::fix.RoundToInt(v.w));