Example #1
0
 public void Reduce(Matrix3x3Buffer other)
 {
     for (int i = 0; i < 9; ++i)
     {
         data[i] -= other.data[i];
     }
 }
Example #2
0
    public void GetInverse(Matrix3x3Buffer other)
    {
        var m = new UnityEngine.Matrix4x4();

        m.m00 = other.data[0];
        m.m01 = other.data[1];
        m.m02 = other.data[2];
        m.m10 = other.data[3];
        m.m11 = other.data[4];
        m.m12 = other.data[5];
        m.m20 = other.data[6];
        m.m21 = other.data[7];
        m.m22 = other.data[8];
        m.m33 = 1f;

        m = m.inverse;

        data[0] = m.m00;
        data[1] = m.m01;
        data[2] = m.m02;
        data[3] = m.m10;
        data[4] = m.m11;
        data[5] = m.m12;
        data[6] = m.m20;
        data[7] = m.m21;
        data[8] = m.m22;
    }
Example #3
0
 public void Add(Matrix3x3Buffer other)
 {
     for (int i = 0; i < 9; ++i)
     {
         data[i] += other.data[i];
     }
 }
Example #4
0
    static public Matrix3x3Buffer CreateI()
    {
        var result = new Matrix3x3Buffer();

        result.data[0] = 1;
        result.data[4] = 1;
        result.data[8] = 1;

        return(result);
    }
Example #5
0
    public static Matrix3x3Buffer operator /(Matrix3x3Buffer a, float b)
    {
        Matrix3x3Buffer result = new Matrix3x3Buffer();

        for (int i = 0; i < 9; ++i)
        {
            result.data[i] = a.data[i] / b;
        }

        return(result);
    }
Example #6
0
    public static Matrix3x3Buffer operator -(Matrix3x3Buffer a, Matrix3x3Buffer b)
    {
        Matrix3x3Buffer result = new Matrix3x3Buffer();

        for (int i = 0; i < 9; ++i)
        {
            result.data[i] = a.data[i] - b.data[i];
        }

        return(result);
    }
    public void InitSim()
    {
        temN = N;

        P    = new V3Buffer[N];
        V    = new V3Buffer[N];
        temV = new V3Buffer[N];

        for (int i = 0; i < N; ++i)
        {
            var body = bodyList[i];
            P[i]    = new V3Buffer(body.transform.position);
            V[i]    = new V3Buffer(body.velocity);
            temV[i] = new V3Buffer(body.velocity);
        }

        InitConnectionData();

        J = new Matrix3x3Buffer[N * N];
        // init J
        for (int i = 0; i < J.Length; ++i)
        {
            J[i] = new Matrix3x3Buffer();
        }

        A = new Matrix3x3Buffer[N * N];
        // init A
        for (int i = 0; i < A.Length; ++i)
        {
            A[i] = new Matrix3x3Buffer();
        }

        B = new V3Buffer[N];
        // init B
        for (int i = 0; i < B.Length; ++i)
        {
            B[i] = new V3Buffer();
        }

        temInvA = new Matrix3x3Buffer[N];
        for (int i = 0; i < temInvA.Length; ++i)
        {
            temInvA[i] = new Matrix3x3Buffer();
        }

        temX  = new V3Buffer();
        temR  = new V3Buffer();
        temVV = new V3Buffer();
        temF  = new V3Buffer();

        temDiff = new Matrix3x3Buffer();
        temXij  = new Matrix3x3Buffer();
    }
Example #8
0
 public void Copy(Matrix3x3Buffer other)
 {
     data[0] = other.data[0];
     data[1] = other.data[1];
     data[2] = other.data[2];
     data[3] = other.data[3];
     data[4] = other.data[4];
     data[5] = other.data[5];
     data[6] = other.data[6];
     data[7] = other.data[7];
     data[8] = other.data[8];
 }
Example #9
0
    static public Matrix3x3Buffer CreateFromOuterProductOfV3(V3Buffer x)
    {
        var result = new Matrix3x3Buffer();

        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                result.data[i * 3 + j] = x.data[i] * x.data[j];
            }
        }

        return(result);
    }
Example #10
0
    static public Matrix3x3Buffer CreateFromOuterProductOfV3(float[] input)
    {
        if (input.Length != 3)
        {
            return(new Matrix3x3Buffer());
        }

        var result = new Matrix3x3Buffer();

        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                result.data[i * 3 + j] = input[i] * input[j];
            }
        }

        return(result);
    }