// Transform by matrix public void PlaneTransformTest1() { PlaneD target = new PlaneD(1, 2, 3, 4); target = PlaneD.Normalize(target); Matrix4x4D m = Matrix4x4D.CreateRotationX(MathHelper.ToRadians(30.0f)) * Matrix4x4D.CreateRotationY(MathHelper.ToRadians(30.0f)) * Matrix4x4D.CreateRotationZ(MathHelper.ToRadians(30.0f)); m.M41 = 10.0f; m.M42 = 20.0f; m.M43 = 30.0f; PlaneD expected = new PlaneD(); Matrix4x4D.Invert(m, out var inv); Matrix4x4D itm = Matrix4x4D.Transpose(inv); double x = target.Normal.X, y = target.Normal.Y, z = target.Normal.Z, w = target.D; expected.Normal = new Vector3D( x * itm.M11 + y * itm.M21 + z * itm.M31 + w * itm.M41, x * itm.M12 + y * itm.M22 + z * itm.M32 + w * itm.M42, x * itm.M13 + y * itm.M23 + z * itm.M33 + w * itm.M43); expected.D = x * itm.M14 + y * itm.M24 + z * itm.M34 + w * itm.M44; PlaneD actual; actual = PlaneD.Transform(target, m); Assert.True(MathHelper.Equal(expected, actual), "PlaneD.Transform did not return the expected value."); }