示例#1
0
 public Mat22 MulLocal(Mat22 R)
 {
     MulToOut(R, this);
     return this;
 }
示例#2
0
 /// <summary>
 /// Add B to this matrix locally.
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 public Mat22 AddLocal(Mat22 b)
 {
     // ex.addLocal(B.ex);
     // col2.addLocal(B.ey);
     Ex.X += b.Ex.X;
     Ex.Y += b.Ex.Y;
     Ey.X += b.Ey.X;
     Ey.Y += b.Ey.Y;
     return this;
 }
示例#3
0
 public void InvertToOut(Mat22 result)
 {
     float a = Ex.X;
     float b = Ey.X;
     float c = Ex.Y;
     float d = Ey.Y;
     float det = a * d - b * c;
     // b2Assert(det != 0.0f);
     det = 1.0f / det;
     result.Ex.X = det * d;
     result.Ey.X = (-det) * b;
     result.Ex.Y = (-det) * c;
     result.Ey.Y = det * a;
 }
示例#4
0
        public static void MulTransToOut(Mat22 a, Mat22 b, Mat22 result)
        {
            float x1 = a.Ex.X * b.Ex.X + a.Ex.Y * b.Ex.Y;
            float y1 = a.Ey.X * b.Ex.X + a.Ey.Y * b.Ex.Y;
            float x2 = a.Ex.X * b.Ey.X + a.Ex.Y * b.Ey.Y;
            float y2 = a.Ey.X * b.Ey.X + a.Ey.Y * b.Ey.Y;

            result.Ex.X = x1;
            result.Ex.Y = y1;
            result.Ey.X = x2;
            result.Ey.Y = y2;
        }
示例#5
0
 public static void MulTransToOutUnsafe(Mat22 a, Mat22 b, Mat22 result)
 {
     Debug.Assert(a != result);
     Debug.Assert(b != result);
     result.Ex.X = a.Ex.X * b.Ex.X + a.Ex.Y * b.Ex.Y;
     result.Ex.Y = a.Ey.X * b.Ex.X + a.Ey.Y * b.Ex.Y;
     result.Ey.X = a.Ex.X * b.Ey.X + a.Ex.Y * b.Ey.Y;
     result.Ey.Y = a.Ey.X * b.Ey.X + a.Ey.Y * b.Ey.Y;
 }
示例#6
0
 public void MulTransToOutUnsafe(Mat22 b, Mat22 result)
 {
     Debug.Assert(b != result);
     Debug.Assert(this != result);
     result.Ex.X = Ex.X * b.Ex.X + Ex.Y * b.Ex.Y;
     result.Ey.X = Ex.X * b.Ey.X + Ex.Y * b.Ey.Y;
     result.Ex.Y = Ey.X * b.Ex.X + Ey.Y * b.Ex.Y;
     result.Ey.Y = Ey.X * b.Ey.X + Ey.Y * b.Ey.Y;
 }
示例#7
0
 public static Mat22 MulTrans(Mat22 a, Mat22 b)
 {
     Mat22 C = new Mat22();
     C.Ex.X = a.Ex.X * b.Ex.X + a.Ex.Y * b.Ex.Y;
     C.Ex.Y = a.Ey.X * b.Ex.X + a.Ey.Y * b.Ex.Y;
     C.Ey.X = a.Ex.X * b.Ey.X + a.Ex.Y * b.Ey.Y;
     C.Ey.Y = a.Ey.X * b.Ey.X + a.Ey.Y * b.Ey.Y;
     return C;
 }
示例#8
0
 public static void CreateScaleTransform(float scale, Mat22 result)
 {
     result.Ex.X = scale;
     result.Ey.Y = scale;
 }
示例#9
0
 /* djm created */
 public static void AbsToOut(Mat22 r, Mat22 result)
 {
     result.Ex.X = MathUtils.Abs(r.Ex.X);
     result.Ex.Y = MathUtils.Abs(r.Ex.Y);
     result.Ey.X = MathUtils.Abs(r.Ey.X);
     result.Ey.Y = MathUtils.Abs(r.Ey.Y);
 }
示例#10
0
 public static Vec2 MulTrans(Mat22 r, Vec2 v)
 {
     return(new Vec2((v.X * r.Ex.X + v.Y * r.Ex.Y), (v.X * r.Ey.X + v.Y * r.Ey.Y)));
 }
示例#11
0
 public static void MulTransToOutUnsafe(Mat22 r, Vec2 v, Vec2 result)
 {
     Debug.Assert(result != v);
     result.Y = v.X * r.Ey.X + v.Y * r.Ey.Y;
     result.X = v.X * r.Ex.X + v.Y * r.Ex.Y;
 }
示例#12
0
 public static void MulToOutUnsafe(Mat22 r, Vec2 v, Vec2 result)
 {
     Debug.Assert(v != result);
     result.X = r.Ex.X * v.X + r.Ey.X * v.Y;
     result.Y = r.Ex.Y * v.X + r.Ey.Y * v.Y;
 }
示例#13
0
 public static Vec2 Mul(Mat22 r, Vec2 v)
 {
     // return R.mul(v);
     return(new Vec2(r.Ex.X * v.X + r.Ey.X * v.Y, r.Ex.Y * v.X + r.Ey.Y * v.Y));
 }
示例#14
0
 public Mat22 MulTransLocal(Mat22 b)
 {
     MulTransToOut(b, this);
     return(this);
 }
示例#15
0
 public void MulToOutUnsafe(Mat22 r, Mat22 result)
 {
     Debug.Assert(result != r);
     Debug.Assert(result != this);
     result.Ex.X = Ex.X * r.Ex.X + Ey.X * r.Ex.Y;
     result.Ex.Y = Ex.Y * r.Ex.X + Ey.Y * r.Ex.Y;
     result.Ey.X = Ex.X * r.Ey.X + Ey.X * r.Ey.Y;
     result.Ey.Y = Ex.Y * r.Ey.X + Ey.Y * r.Ey.Y;
 }
示例#16
0
 public static Mat22 CreateRotationalTransform(float angle)
 {
     Mat22 mat = new Mat22();
     float c = MathUtils.Cos(angle);
     float s = MathUtils.Sin(angle);
     mat.Ex.X = c;
     mat.Ey.X = -s;
     mat.Ex.Y = s;
     mat.Ey.Y = c;
     return mat;
 }
示例#17
0
 public Mat22 MulTransLocal(Mat22 b)
 {
     MulTransToOut(b, this);
     return this;
 }
示例#18
0
 public static void CreateRotationalTransform(float angle, Mat22 result)
 {
     float c = MathUtils.Cos(angle);
     float s = MathUtils.Sin(angle);
     result.Ex.X = c;
     result.Ey.X = -s;
     result.Ex.Y = s;
     result.Ey.Y = c;
 }
示例#19
0
 public Mat22 MulLocal(Mat22 R)
 {
     MulToOut(R, this);
     return(this);
 }
示例#20
0
 public static Mat22 CreateScaleTransform(float scale)
 {
     Mat22 mat = new Mat22();
     mat.Ex.X = scale;
     mat.Ey.Y = scale;
     return mat;
 }
示例#21
0
 public static void MulTransToOut(Mat22 r, Vec2 v, Vec2 result)
 {
     float outx = v.X * r.Ex.X + v.Y * r.Ex.Y;
     result.Y = v.X * r.Ey.X + v.Y * r.Ey.Y;
     result.X = outx;
 }
示例#22
0
 public static void CreateScaleTransform(float scale, Mat22 result)
 {
     result.Ex.X = scale;
     result.Ey.Y = scale;
 }
示例#23
0
 public static void MulTransToOutUnsafe(Mat22 r, Vec2 v, Vec2 result)
 {
     Debug.Assert(result != v);
     result.Y = v.X * r.Ey.X + v.Y * r.Ey.Y;
     result.X = v.X * r.Ex.X + v.Y * r.Ex.Y;
 }
示例#24
0
 public static Vec2 Mul(Mat22 r, Vec2 v)
 {
     // return R.mul(v);
     return new Vec2(r.Ex.X * v.X + r.Ey.X * v.Y, r.Ex.Y * v.X + r.Ey.Y * v.Y);
 }
示例#25
0
 /// <summary>
 /// Add this matrix to B, return the result.
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 public Mat22 Add(Mat22 b)
 {
     // return new Mat22(ex.add(B.ex), col2.add(B.ey));
     Mat22 m = new Mat22();
     m.Ex.X = Ex.X + b.Ex.X;
     m.Ex.Y = Ex.Y + b.Ex.Y;
     m.Ey.X = Ey.X + b.Ey.X;
     m.Ey.Y = Ey.Y + b.Ey.Y;
     return m;
 }
示例#26
0
 public static Mat22 Mul(Mat22 a, Mat22 b)
 {
     // return A.mul(B);
     Mat22 C = new Mat22();
     C.Ex.X = a.Ex.X * b.Ex.X + a.Ey.X * b.Ex.Y;
     C.Ex.Y = a.Ex.Y * b.Ex.X + a.Ey.Y * b.Ex.Y;
     C.Ey.X = a.Ex.X * b.Ey.X + a.Ey.X * b.Ey.Y;
     C.Ey.Y = a.Ex.Y * b.Ey.X + a.Ey.Y * b.Ey.Y;
     return C;
 }
示例#27
0
        /// <summary>
        /// Returns the inverted Mat22 - does NOT invert the matrix locally!
        /// </summary>
        public Mat22 Invert()
        {
            float a = Ex.X;
            float b = Ey.X;
            float c = Ex.Y;
            float d = Ey.Y;

            Mat22 B = new Mat22();
            float det = a * d - b * c;
            if (det != 0)
            {
                det = 1.0f / det;
            }
            B.Ex.X = det * d;
            B.Ey.X = (-det) * b;
            B.Ex.Y = (-det) * c;
            B.Ey.Y = det * a;
            return B;
        }
示例#28
0
 public static void MulToOut(Mat22 r, Vec2 v, Vec2 result)
 {
     float tempy = r.Ex.Y * v.X + r.Ey.Y * v.Y;
     result.X = r.Ex.X * v.X + r.Ey.X * v.Y;
     result.Y = tempy;
 }
示例#29
0
 /// <summary>
 /// Multiply another matrix by this one (this one on left). djm optimized
 /// </summary>
 /// <param name="r"></param>
 /// <returns></returns>
 public Mat22 Mul(Mat22 r)
 {
     /*
     * Mat22 C = new Mat22();C.set(this.mul(R.ex), this.mul(R.ey));return C;
     */
     Mat22 C = new Mat22();
     C.Ex.X = Ex.X * r.Ex.X + Ey.X * r.Ex.Y;
     C.Ex.Y = Ex.Y * r.Ex.X + Ey.Y * r.Ex.Y;
     C.Ey.X = Ex.X * r.Ey.X + Ey.X * r.Ey.Y;
     C.Ey.Y = Ex.Y * r.Ey.X + Ey.Y * r.Ey.Y;
     // C.set(ex,col2);
     return C;
 }
示例#30
0
 public static void MulToOut(Mat22 a, Mat22 b, Mat22 result)
 {
     float tempy1 = a.Ex.Y * b.Ex.X + a.Ey.Y * b.Ex.Y;
     float tempx1 = a.Ex.X * b.Ex.X + a.Ey.X * b.Ex.Y;
     float tempy2 = a.Ex.Y * b.Ey.X + a.Ey.Y * b.Ey.Y;
     float tempx2 = a.Ex.X * b.Ey.X + a.Ey.X * b.Ey.Y;
     result.Ex.X = tempx1;
     result.Ex.Y = tempy1;
     result.Ey.X = tempx2;
     result.Ey.Y = tempy2;
 }
示例#31
0
 public void MulToOut(Mat22 r, Mat22 result)
 {
     float tempy1 = Ex.Y * r.Ex.X + Ey.Y * r.Ex.Y;
     float tempx1 = Ex.X * r.Ex.X + Ey.X * r.Ex.Y;
     result.Ex.X = tempx1;
     result.Ex.Y = tempy1;
     float tempy2 = Ex.Y * r.Ey.X + Ey.Y * r.Ey.Y;
     float tempx2 = Ex.X * r.Ey.X + Ey.X * r.Ey.Y;
     result.Ey.X = tempx2;
     result.Ey.Y = tempy2;
 }
示例#32
0
 public static void MulToOutUnsafe(Mat22 r, Vec2 v, Vec2 result)
 {
     Debug.Assert(v != result);
     result.X = r.Ex.X * v.X + r.Ey.X * v.Y;
     result.Y = r.Ex.Y * v.X + r.Ey.Y * v.Y;
 }
示例#33
0
        /// <summary>
        /// Multiply another matrix by the transpose of this one (transpose of this one on left). djm:
        /// optimized
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public Mat22 MulTrans(Mat22 b)
        {
            /*
            * Vec2 c1 = new Vec2(Vec2.dot(this.ex, B.ex), Vec2.dot(this.ey, B.ex)); Vec2 c2 = new
            * Vec2(Vec2.dot(this.ex, B.ey), Vec2.dot(this.ey, B.ey)); Mat22 C = new Mat22(); C.set(c1, c2);
            * return C;
            */

            Mat22 C = new Mat22();

            C.Ex.X = Vec2.Dot(this.Ex, b.Ex);
            C.Ex.Y = Vec2.Dot(this.Ey, b.Ex);

            C.Ey.X = Vec2.Dot(this.Ex, b.Ey);
            C.Ey.Y = Vec2.Dot(this.Ey, b.Ey);
            return C;
        }
示例#34
0
 public static void MulToOutUnsafe(Mat22 a, Mat22 b, Mat22 result)
 {
     Debug.Assert(result != a);
     Debug.Assert(result != b);
     result.Ex.X = a.Ex.X * b.Ex.X + a.Ey.X * b.Ex.Y;
     result.Ex.Y = a.Ex.Y * b.Ex.X + a.Ey.Y * b.Ex.Y;
     result.Ey.X = a.Ex.X * b.Ey.X + a.Ey.X * b.Ey.Y;
     result.Ey.Y = a.Ex.Y * b.Ey.X + a.Ey.Y * b.Ey.Y;
 }
示例#35
0
        public void MulTransToOut(Mat22 b, Mat22 result)
        {
            /*
            * out.ex.x = Vec2.dot(this.ex, B.ex); out.ex.y = Vec2.dot(this.ey, B.ex); out.ey.x =
            * Vec2.dot(this.ex, B.ey); out.ey.y = Vec2.dot(this.ey, B.ey);
            */

            float x1 = Ex.X * b.Ex.X + Ex.Y * b.Ex.Y;
            float y1 = Ey.X * b.Ex.X + Ey.Y * b.Ex.Y;
            float x2 = Ex.X * b.Ey.X + Ex.Y * b.Ey.Y;
            float y2 = Ey.X * b.Ey.X + Ey.Y * b.Ey.Y;
            result.Ex.X = x1;
            result.Ey.X = x2;
            result.Ex.Y = y1;
            result.Ey.Y = y2;
        }
示例#36
0
 public static Vec2 MulTrans(Mat22 r, Vec2 v)
 {
     return new Vec2((v.X * r.Ex.X + v.Y * r.Ex.Y), (v.X * r.Ey.X + v.Y * r.Ey.Y));
 }
示例#37
0
 /// <summary>
 /// Set as a copy of another matrix.
 /// </summary>
 /// <param name="m">Matrix to copy</param>
 public Mat22 Set(Mat22 m)
 {
     Ex.X = m.Ex.X;
     Ex.Y = m.Ex.Y;
     Ey.X = m.Ey.X;
     Ey.Y = m.Ey.Y;
     return this;
 }
示例#38
0
 /// <summary>
 /// Return the matrix composed of the absolute values of all elements.
 /// </summary>
 /// <returns>Absolute value matrix</returns>
 public static Mat22 Abs(Mat22 r)
 {
     return(r.Abs());
 }