public float4x3(float3x3 R, float3 t) { M11 = R.M11; M12 = R.M12; M13 = R.M13; M21 = R.M21; M22 = R.M22; M23 = R.M23; M31 = R.M31; M32 = R.M32; M33 = R.M33; M41 = t.x; M42 = t.y; M43 = t.z; }
public float4x4(float3x3 R, float3 t) { M11 = R.M11; M12 = R.M12; M13 = R.M13; M14 = 0; M21 = R.M21; M22 = R.M22; M23 = R.M23; M24 = 0; M31 = R.M31; M32 = R.M32; M33 = R.M33; M34 = 0; M41 = t.x; M42 = t.y; M43 = t.z; M44 = 1; }
public GDI32Transform() { fMatrix = new XFORM(); fTransformMatrix = new float3x3(); // Start out with identity matrix SetToIdentity(); }
// Reset to identity transform public void SetToIdentity() { fTransformMatrix = float3x3.Identity; fMatrix.eM11 = 1F; fMatrix.eM12 = 0F; fMatrix.eM21 = 0F; fMatrix.eM22 = 1F; fMatrix.eDx = 0F; fMatrix.eDy = 0F; }
public float3x4(float3x3 R, float3 t) { M11 = R.M11; M12 = R.M12; M13 = R.M13; M14 = t.x; M21 = R.M21; M22 = R.M22; M23 = R.M23; M24 = t.y; M31 = R.M31; M32 = R.M32; M33 = R.M33; M34 = t.z; }
// transform = 1 / transform // M = A * x + B // Inv(M) = Inv(A) * x - Inv(A) * B public bool Invert() { fTransformMatrix = fTransformMatrix.Inverse; float det = fMatrix.eM11 * fMatrix.eM22 - fMatrix.eM21 * fMatrix.eM12; if (det == 0) return false; XFORM old = new XFORM(fMatrix); fMatrix.eM11 = old.eM22 / det; fMatrix.eM12 = -old.eM12 / det; fMatrix.eM21 = -old.eM21 / det; fMatrix.eM22 = old.eM11 / det; fMatrix.eDx = -(fMatrix.eM11 * old.eDx + fMatrix.eM21 * old.eDy); fMatrix.eDy = -(fMatrix.eM12 * old.eDx + fMatrix.eM22 * old.eDy); return true; }
public bool Rotate(float angle, float x0, float y0) { float3 unity = new float3(new float2(x0, y0)); unity.Unit(); fTransformMatrix = float3x3.Rotate(angle, unity); XFORM xm = new XFORM(); Translate(-x0, -y0); // make (x0,y0) the origin double rad = angle * (Math.PI / 180); xm.eM11 = (float)Math.Cos(rad); xm.eM12 = (float)Math.Sin(rad); xm.eM21 = -xm.eM12; xm.eM22 = xm.eM11; xm.eDx = 0; xm.eDy = 0; Combine(xm); // rotate Translate(x0, y0); // move origin back return true; }