//public override bool Equals(object o) //{ // if ((o == null) || !(o is Matrix3d)) // { // return false; // } // Matrix3d matrixd = (Matrix3d)o; // return Equals(this, matrixd); //} //public bool Equals(Matrix3d value) //{ // return Equals(this, value); //} //public override int GetHashCode() //{ // if (this.IsDistinguishedIdentity) // { // return 0; // } // return (((((((((((((((this.M11.GetHashCode() ^ this.M12.GetHashCode()) ^ this.M13.GetHashCode()) ^ this.M14.GetHashCode()) ^ this.M21.GetHashCode()) ^ this.M22.GetHashCode()) ^ this.M23.GetHashCode()) ^ this.M24.GetHashCode()) ^ this.M31.GetHashCode()) ^ this.M32.GetHashCode()) ^ this.M33.GetHashCode()) ^ this.M34.GetHashCode()) ^ this.OffsetX.GetHashCode()) ^ this.OffsetY.GetHashCode()) ^ this.OffsetZ.GetHashCode()) ^ this.M44.GetHashCode()); //} //public override string ToString() //{ // return this.ConvertToString(null, null); //} //string IFormattable.ToString(string format, IFormatProvider provider) //{ // return this.ConvertToString(format, provider); //} //private string ConvertToString(string format, IFormatProvider provider) //{ // if (this.IsIdentity) // { // return "Identity"; // } // char numericListSeparator = ','; // return string.Format(provider, "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}{0}{5:" + format + "}{0}{6:" + format + "}{0}{7:" + format + "}{0}{8:" + format + "}{0}{9:" + format + "}{0}{10:" + format + "}{0}{11:" + format + "}{0}{12:" + format + "}{0}{13:" + format + "}{0}{14:" + format + "}{0}{15:" + format + "}{0}{16:" + format + "}", new object[] { // numericListSeparator, this._m11, this._m12, this._m13, this._m14, this._m21, this._m22, this._m23, this._m24, this._m31, this._m32, this._m33, this._m34, this._offsetX, this._offsetY, this._offsetZ, // this._m44 // }); //} public static Matrix3d FromMatrix2d(Matrix2d mat) { Matrix3d mat3d = Matrix3d.CreateIdentity(); mat3d.M11 = mat.M11; mat3d.M12 = mat.M12; mat3d.M13 = mat.M13; mat3d.M21 = mat.M21; mat3d.M22 = mat.M22; mat3d.M23 = mat.M23; mat3d.M31 = mat.M31; mat3d.M32 = mat.M32; mat3d.M33 = mat.M33; mat3d._isNotKnownToBeIdentity = true; return mat3d; }
public static Matrix3d GetMapMatrix(Coordinates center, double fieldWidth, double fieldHeight, double rotation) { double offsetX = 0; double offsetY = 0; offsetX = -(((center.Lng + 180 - (fieldWidth / 2)) / 360)); offsetY = -((1 - ((center.Lat + 90 + (fieldHeight / 2)) / 180))); Matrix2d mat = new Matrix2d(); double scaleX = 0; double scaleY = 0; scaleX = 360 / fieldWidth; scaleY = 180 / fieldHeight; mat = Matrix2d.Multiply(mat, Matrix2d.Translation(offsetX, offsetY)); mat = Matrix2d.Multiply(mat, Matrix2d.Scaling(scaleX, scaleY)); if (rotation != 0) { mat = Matrix2d.Multiply(mat,Matrix2d.Translation(-.5, -.5)); mat = Matrix2d.Multiply(mat,Matrix2d.Rotation(rotation)); mat = Matrix2d.Multiply(mat,Matrix2d.Translation(.5, .5)); } return Matrix3d.FromMatrix2d(mat); }
public static Matrix2d Translation(double x, double y) { Matrix2d mat = new Matrix2d(); mat.M31 = x; mat.M32 = y; return mat; }
public static Matrix2d Scaling(double x, double y) { Matrix2d mat = new Matrix2d(); mat.M11 = x; mat.M22 = y; return mat; }
public static Matrix2d Rotation(double angle) { Matrix2d mat = new Matrix2d(); mat.M11 = Math.Cos(angle); mat.M21 = -Math.Sin(angle); mat.M12 = Math.Sin(angle); mat.M22 = Math.Cos(angle); return mat; }
public static Matrix2d Multiply(Matrix2d matrix1, Matrix2d matrix2) { return Matrix2d.Create ( (((matrix1.M11 * matrix2.M11) + (matrix1.M12 * matrix2.M21)) + (matrix1.M13 * matrix2.M31)), (((matrix1.M11 * matrix2.M12) + (matrix1.M12 * matrix2.M22)) + (matrix1.M13 * matrix2.M32)), (((matrix1.M11 * matrix2.M13) + (matrix1.M12 * matrix2.M23)) + (matrix1.M13 * matrix2.M33)), (((matrix1.M21 * matrix2.M11) + (matrix1.M22 * matrix2.M21)) + (matrix1.M23 * matrix2.M31)), (((matrix1.M21 * matrix2.M12) + (matrix1.M22 * matrix2.M22)) + (matrix1.M23 * matrix2.M32)), (((matrix1.M21 * matrix2.M13) + (matrix1.M22 * matrix2.M23)) + (matrix1.M23 * matrix2.M33)), (((matrix1.M31 * matrix2.M11) + (matrix1.M32 * matrix2.M21)) + (matrix1.M33 * matrix2.M31)), (((matrix1.M31 * matrix2.M12) + (matrix1.M32 * matrix2.M22)) + (matrix1.M33 * matrix2.M32)), (((matrix1.M31 * matrix2.M13) + (matrix1.M32 * matrix2.M23)) + (matrix1.M33 * matrix2.M33)) ); }
public static Matrix2d Create(double m11, double m12, double m13, double m21, double m22, double m23, double m31, double m32, double m33) { Matrix2d mat = new Matrix2d(); mat.M11 = m11; mat.M12 = m12; mat.M13 = m13; mat.M21 = m21; mat.M22 = m22; mat.M23 = m23; mat.M31 = m31; mat.M32 = m32; mat.M33 = m33; return mat; }