public static void Decompose(this __type__ trafo, out __vnt__ scale, out __vnt__ rotationInRadians, out __vnt__ translation) { translation = trafo.GetModelOrigin(); var rt = trafo.GetOrthoNormalOrientation(); if (rt.Forward.Determinant.IsTiny()) { rotationInRadians = __vnt__.Zero; } else { var rot = __rotnt__.FromFrame(rt.Forward.C0.XYZ, rt.Forward.C1.XYZ, rt.Forward.C2.XYZ); rotationInRadians = rot.GetEulerAngles(); } scale = trafo.GetScaleVector(); // if matrix is left-handed there must be some negative scale // since rotation remains the x-axis, the y-axis must be flipped if (trafo.Forward.Determinant < 0) { scale.Y = -scale.Y; } }
public __type__(__rotnt__ rot) { Rot = rot; Trans = __vnt__.Zero; }
public static __vnt__ InvTransformDir(this __type__ r, __vnt__ v) { return(r.Rot.InvTransform(v)); }
public static __vnt__ TransformPos(this __type__ r, __vnt__ p) { return(r.Rot.Transform(p) + r.Trans); }
public __type__(__type__ e) { Rot = e.Rot; Trans = e.Trans; }
public __type__(__rotnt__ rot, __vnt__ trans) { Rot = rot; Trans = trans; }
public __type__(__mnnt__ linear, __vnt__ translation) { Debug.Assert(linear.Invertible); Linear = linear; Trans = translation; }
public __type__(/*# nfields.ForEach(f => { */ __ftype__ t__f__ /*# }, comma);*/) { Rot = __rotnt__.Identity; Trans = new __vnt__(/*# nfields.ForEach(f => { */ t__f__ /*# }, comma);*/); }
public static __vnt__ TransformPos(this __type__ t, __vnt__ p) { return(t.Euclidean.TransformPos(t.Scale * p)); }
public static __vnt__ TransformDir(this __type__ t, __vnt__ v) { return(t.Euclidean.TransformDir(t.Scale * v)); }
public __type__(__ftype__ scale, __rotnt__ rotation, __vnt__ translation) { Scale = scale; Euclidean = new __euclideannt__(rotation, translation); }
public __type__(__mnnt__ linear) { Debug.Assert(linear.Invertible); Linear = linear; Trans = __vnt__.Zero; }
public __type__(__mnnt__ linear, /*# nfields.ForEach(f => { */ __ftype__ t__f__ /*# }, comma); */) { Debug.Assert(linear.Invertible); Linear = linear; Trans = new __vnt__(/*# nfields.ForEach(f => { */ t__f__ /*# }, comma); */); }
public static __vnt__ TransposedTransformPosProj(this __type__ a, __vnt__ v) { var s = /*# nfields.ForEach(f => {*/ v.__f__ * a.Trans.__f__ /*# }, add);*/ + 1; return(TransposedTransform(a, v) * (1 / s)); }
public static __vnt__ TransposedTransform(this __type__ a, __vnt__ v) { return(new __vnt__(/*# nfields.ForEach((fi, i) => { */ /*# nfields.ForEach((fj, j) => { */ v.__fj__ * a.Linear.M__j____i__ /*# }, add); }, comma);*/)); }
public static __vnt__ InvTransformPos(this __type__ r, __vnt__ p) { return(r.Rot.InvTransform(p - r.Trans)); }
public __type__(__vnt__ trans) { Rot = __rotnt__.Identity; Trans = trans; }
public static __vnt__ InvTransformDir(this __type__ t, __vnt__ v) { return(t.Euclidean.InvTransformDir(v) / t.Scale); }
public static __vnt__ InvTransformPos(this __type__ t, __vnt__ p) { return(t.Euclidean.InvTransformPos(p) / t.Scale); }
public __type__(__type__ affine) { Linear = affine.Linear; Trans = affine.Trans; }