public static void Validate(this AffineTransform a) { a.LinearTransform.Validate(); a.Translation.Validate(); }
///<summary> /// Inverts an affine transform. ///</summary> ///<param name="transform">Transform to invert.</param> /// <param name="inverse">Inverse of the transform.</param> public static void Invert(ref AffineTransform transform, out AffineTransform inverse) { Matrix3x3.Invert(ref transform.LinearTransform, out inverse.LinearTransform); Matrix3x3.Transform(ref transform.Translation, ref inverse.LinearTransform, out inverse.Translation); Vector3.Negate(ref inverse.Translation, out inverse.Translation); }
/// <summary> /// Creates an affine transform from a rigid transform. /// </summary> /// <param name="rigid">Rigid transform to base the affine transform on.</param> /// <param name="affine">Affine transform created from the rigid transform.</param> public static void CreateFromRigidTransform(ref RigidTransform rigid, out AffineTransform affine) { affine.Translation = rigid.Position; Matrix3x3.CreateFromQuaternion(ref rigid.Orientation, out affine.LinearTransform); }
///<summary> /// Transforms a vector by an affine transform. ///</summary> ///<param name="position">Position to transform.</param> ///<param name="transform">Transform to apply.</param> ///<param name="transformed">Transformed position.</param> public static void Transform(ref Vector3 position, ref AffineTransform transform, out Vector3 transformed) { Matrix3x3.Transform(ref position, ref transform.LinearTransform, out transformed); Vector3.Add(ref transformed, ref transform.Translation, out transformed); }