예제 #1
0
 public V3Buffer(V3Buffer other)
 {
     data    = new float[3];
     data[0] = other.data[0];
     data[1] = other.data[1];
     data[2] = other.data[2];
 }
예제 #2
0
 public void InitFromOuterProductOfV3(V3Buffer x)
 {
     for (int i = 0; i < 3; ++i)
     {
         for (int j = 0; j < 3; ++j)
         {
             data[i * 3 + j] = x.data[i] * x.data[j];
         }
     }
 }
예제 #3
0
    public static V3Buffer operator *(float k, V3Buffer a)
    {
        V3Buffer result = new V3Buffer();

        result.data[0] = a.data[0] * k;
        result.data[1] = a.data[1] * k;
        result.data[2] = a.data[2] * k;

        return(result);
    }
예제 #4
0
    public static V3Buffer operator -(V3Buffer a, V3Buffer b)
    {
        V3Buffer result = new V3Buffer();

        result.data[0] = a.data[0] - b.data[0];
        result.data[1] = a.data[1] - b.data[1];
        result.data[2] = a.data[2] - b.data[2];

        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();
    }
예제 #6
0
    public V3Buffer Multiply(V3Buffer input)
    {
        V3Buffer result = new V3Buffer();

        for (int i = 0; i < 3; ++i)
        {
            result.data[i] = 0;
            for (int j = 0; j < 3; ++j)
            {
                result.data[i] += data[i * 3 + j] * input.data[j];
            }
        }
        return(result);
    }
예제 #7
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);
    }
예제 #8
0
 public void Reduce(V3Buffer other)
 {
     data[0] -= other.data[0];
     data[1] -= other.data[1];
     data[2] -= other.data[2];
 }
예제 #9
0
 public void Add(V3Buffer other)
 {
     data[0] += other.data[0];
     data[1] += other.data[1];
     data[2] += other.data[2];
 }
예제 #10
0
 public void Copy(V3Buffer other)
 {
     data[0] = other.data[0];
     data[1] = other.data[1];
     data[2] = other.data[2];
 }