示例#1
0
    [Fact] public void HandToJoints()
    {
        Data_Generator  dg     = new Data_Generator();
        Hand_Generator  hg     = new Hand_Generator(dg);
        List <Vector[]> dat_vL = new List <Vector[]>()
        {
            dg.newVectors(5),
            dg.newVectors(5),
            dg.newVectors(5),
            dg.newVectors(5),
            dg.newVectors(5),
        };
        List <Finger> dat_fL   = hg.newFingerList(dat_vL);
        Hand          dat_hand = hg.newHand(dat_fL);

        Joints exp_joints = new Joints {
            pinky  = dat_vL[0],
            ring   = dat_vL[1],
            middle = dat_vL[2],
            index  = dat_vL[3],
            thumb  = dat_vL[4],
            palm   = dat_hand.PalmPosition
        };

        VectorHelper vh         = new VectorHelper();
        JointsHelper jh         = new JointsHelper(vh);
        Joints       act_joints = jh.handToJoints(dat_hand);

        test.jointsEqual(exp_joints, act_joints);
    }
示例#2
0
 public List <Finger> newFingerList() => new List <Finger>
 {
     newFinger(dg.newVectors(5)),
     newFinger(dg.newVectors(5)),
     newFinger(dg.newVectors(5)),
     newFinger(dg.newVectors(5)),
     newFinger(dg.newVectors(5)),
 };
    [Fact] public void greaterEqualListOneToOne()
    {
        Data_Generator dg     = new Data_Generator();
        int            length = dg.newInt(100);

        Vector[] v1 = dg.newVectors(length);
        Vector[] v2 = dg.newVectors(length);

        var exp_tupleList = new (bool exp_x, bool exp_y, bool exp_z)[length];
    [Fact] public void AddList()
    {
        Data_Generator dg     = new Data_Generator();
        int            length = dg.newInt(100);

        Vector[] v1  = dg.newVectors(length);
        Vector[] v2  = dg.newVectors(length);
        Vector[] exp = dg.newZeroVectors(length);

        for (int i = 0; i < length; i++)
        {
            exp[i].x = v1[i].x + v2[i].x;
            exp[i].y = v1[i].y + v2[i].y;
            exp[i].z = v1[i].z + v2[i].z;
        }
        VectorHelper v = new VectorHelper();

        Vector[] act = v.addList(v1, v2);
        test.vectorsEqual(exp, act);
    }
    [Fact] public void Lowest()
    {
        Data_Generator dg  = new Data_Generator();
        int            len = dg.newInt(100);

        Vector[] input = dg.newVectors(len);
        input[0] = new Vector(-1, -1, -1);

        Vector exp = input[0];

        VectorHelper vh  = new VectorHelper();
        Vector       act = vh.lowest(input);

        test.vectorEqual(exp, act);
    }
    [Fact] public void PowList()
    {
        Data_Generator dg     = new Data_Generator();
        int            length = dg.newInt(100);
        float          f      = dg.newFloat(100);

        Vector[] v1  = dg.newVectors(length);
        Vector[] exp = dg.newZeroVectors(length);
        for (int i = 0; i < length; i++)
        {
            exp[i].x = (float)Math.Pow(v1[i].x, f);
            exp[i].y = (float)Math.Pow(v1[i].y, f);
            exp[i].z = (float)Math.Pow(v1[i].z, f);
        }
        VectorHelper v = new VectorHelper();

        Vector[] act = v.powList(v1, f);
        test.vectorsEqual(act, exp);
    }
示例#7
0
    [Fact] public void FingerToVectors()
    {
        Data_Generator dg         = new Data_Generator();
        Hand_Generator hg         = new Hand_Generator(dg);
        Finger         inp_finger = hg.newFinger(dg.newVectors(5));

        Vector[] exp_vL = new Vector[] {
            inp_finger.bones[0].PrevJoint,
            inp_finger.bones[1].PrevJoint,
            inp_finger.bones[2].PrevJoint,
            inp_finger.bones[3].PrevJoint,
            inp_finger.bones[3].NextJoint,
        };

        VectorHelper vh = new VectorHelper();
        JointsHelper jh = new JointsHelper(vh);

        Vector[] act_vL = jh.fingerToVectors(inp_finger);

        test.vectorsEqual(exp_vL, act_vL);
    }
    [Fact] public void MinMaxList()
    {
        var dg = new Data_Generator();
        //var dat_i = 0;
        var dat_len = dg.newInt(100);

        var dat_vA  = dg.newVectors(dat_len);
        var dat_min = dg.newMinVectors(dat_len);
        var dat_max = dg.newZeroVectors(dat_len);

        (Vector[] min, Vector[] max)exp = (new Vector[dat_len], new Vector[dat_len]);
        exp.min = dat_min;
        exp.max = dat_vA;

        var vh = new VectorHelper();

        (Vector[] min, Vector[] max)act = vh.minMaxList(dat_min, dat_max, dat_vA);

        test.vectorsEqual(exp.min, act.min);
        test.vectorsEqual(exp.max, act.max);
    }
    [Fact] public void DivList()
    {
        Data_Generator dg     = new Data_Generator();
        int            length = dg.newInt(100);

        Vector[] v1 = dg.newVectors(length);
        float    v2 = dg.newFloat(100);

        Vector[] exp = dg.newZeroVectors(length);

        for (int i = 0; i < length; i++)
        {
            exp[i].x = v1[i].x / v2;
            exp[i].y = v1[i].y / v2;
            exp[i].z = v1[i].z / v2;
        }
        VectorHelper v = new VectorHelper();

        Vector[] act = v.divList(v1, v2);
        test.vectorsEqual(exp, act);
    }
    [Fact] public void Average()
    {
        Data_Generator dg  = new Data_Generator();
        int            len = dg.newInt(100);

        Vector[] vL = dg.newVectors(len);

        Vector exp = new Vector(0, 0, 0);

        for (int i = 0; i < len; i++)
        {
            exp.x += vL[i].x;
            exp.y += vL[i].y;
            exp.z += vL[i].z;
        }
        exp.x /= (float)len;
        exp.y /= (float)len;
        exp.z /= (float)len;

        VectorHelper vh  = new VectorHelper();
        Vector       act = vh.average(vL);

        test.vectorEqual(exp, act);
    }