public static txVector2 CalculateForceFromPenetrationDepth(double stiffness_, double penetrationDepth, txVector2 normal_)
 {
     // using Lottery;
     txVector2 rtnvec2;
     rtnvec2 = stiffness_ * penetrationDepth * (-1.0) * normal_;
     return rtnvec2;
 }
        public void TickTest()
        {
            const double Length = 10.0;
            txVector2 v0_ = new txVector2(); // TODO: Initialize to an appropriate value
            v0_.x = -Length;
            v0_.y = -Length;
            txVector2 v1_ = new txVector2(); // TODO: Initialize to an appropriate value
            v1_.x = Length;
            v1_.y = -Length;
            txVector2 v2_ = new txVector2(); // TODO: Initialize to an appropriate value
            v2_.x = Length;
            v2_.y = Length;
            txVector2 v3_ = new txVector2(); // TODO: Initialize to an appropriate value
            v3_.x = -Length;
            v3_.y = Length;

            double omega = Math.PI / 60.0;
            txRectangle target = new txRectangle(v0_, v1_, v2_, v3_, omega); // TODO: Initialize to an appropriate value
            double t = 0F; // TODO: Initialize to an appropriate value
            t = 60.0;
            target.Tick(t);

            Assert.IsTrue(target.LeftBottomV == v2_);
            Assert.IsTrue(target.RightBottomV == v3_);
            Assert.IsTrue(target.RightTopV == v0_);
            Assert.IsTrue(target.LeftTopV == v1_);

            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
        private void RenderRectangle(txRectangle rect, Graphics dc, txMatrix2 rotation, txVector2 translation)
        {
            // Draw Rectangle
            Pen redPen = new Pen(Color.Red,5);
            txVector2 lb = translation + rotation * rect.LeftBottomV;
            txVector2 rb = translation + rotation * rect.RightBottomV;
            txVector2 rt = translation + rotation * rect.RightTopV;
            txVector2 lt = translation + rotation * rect.LeftTopV;
            //int width = (int)(rect.RightTopV.x - rect.LeftBottomV.x);
            //int height = (int)(rect.RightTopV.y - rect.LeftBottomV.y);
            //Trace.Assert(width > 0);
            //Trace.Assert(height > 0);
            //double xlb = lb.x;
            //double ylb = lb.y;
            //dc.DrawRectangle(redPen,(int)xlb,(int)ylb,width,height);
            //dc.DrawRectangle(redPen, 100, 200, 800, 600);
            Point[] points = 
            {
                new Point((int)lb.x,(int)lb.y),
                new Point((int)rb.x,(int)rb.y),
                new Point((int)rt.x,(int)rt.y),
                new Point((int)lt.x,(int)lt.y),
                new Point((int)lb.x,(int)lb.y)
            };

            dc.DrawLines(redPen, points);
        }
 private void RenderCoordinateFrame(Graphics dc, txMatrix2 rotation, txVector2 translation)
 {
     Pen yellopen = new Pen(Color.Yellow, 1);
     txVector2 origin = txVector2.Zero();
     origin = translation + rotation * origin;
     int X = (int) origin.x;
     int Y = (int) origin.y;
     dc.DrawLine(yellopen,new Point(-10000, Y),new Point(10000, Y));
     dc.DrawLine(yellopen, new Point(X, 10000), new Point(X, -10000));
 }
 public void LengthTest()
 {
     txVector2 target = new txVector2(); // TODO: Initialize to an appropriate value
     target.x = 3.0;
     target.y = 4.0;
     double expected = 0F; // TODO: Initialize to an appropriate value
     expected = 5.0;
     double actual;
     actual = target.Length();
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
        private void RenderDisk(List<txPhysicalShpere> disklist, Graphics dc, txMatrix2 rotation, txVector2 translation)
        {
            // Draw disklist
            Pen grayPen = new Pen(Color.Gray,2);
            foreach ( txPhysicalShpere disk in disklist)
            {
                txVector2 ob = translation + rotation * disk.Position;
                double xlb = ob.x-txPhysicalShpere.RADIUS;
                double ylb = ob.y-txPhysicalShpere.RADIUS;

                dc.DrawEllipse(grayPen,(int)xlb,(int)ylb,(int)txPhysicalShpere.DIAMETER,(int)txPhysicalShpere.DIAMETER);
            }
        }
 public txRectangle(txVector2 v0_, txVector2 v1_, txVector2 v2_, txVector2 v3_, double omega_)
 {
     leftBottomV = v0_;
     rightBottomV = v1_;
     rightTopV = v2_;
     leftTopV = v3_;
     omega = omega_;
     met = new txMatrix2(1.0,0.0,0.0,1.0);
     constleftBottomV = leftBottomV;
     constrightBottomV = rightBottomV;
     constrightTopV = rightTopV;
     constleftTopV = leftTopV;
     AssemblyLineSegmentList();
 }
 public void op_MultiplyTest()
 {
     txMatrix2 m = new txMatrix2(); // TODO: Initialize to an appropriate value
     m.m00 = 1.0;
     m.m01 = 2.0;
     m.m10 = 3.0;
     m.m11 = 4.0;
     txVector2 v = new txVector2(); // TODO: Initialize to an appropriate value
     v.x = 1.0;
     v.y = 2.0;
     txVector2 expected = new txVector2(); // TODO: Initialize to an appropriate value
     expected.x = 5.0;
     expected.y = 11.0;
     txVector2 actual;
     actual = (m * v);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void txRectangleConstructorTest()
 {
     const double Length = 10.0;
     txVector2 v0_ = new txVector2(); // TODO: Initialize to an appropriate value
     v0_.x = -Length;
     v0_.y = -Length;
     txVector2 v1_ = new txVector2(); // TODO: Initialize to an appropriate value
     v1_.x = Length;
     v1_.y = -Length;
     txVector2 v2_ = new txVector2(); // TODO: Initialize to an appropriate value
     v2_.x = Length;
     v2_.y = Length;
     txVector2 v3_ = new txVector2(); // TODO: Initialize to an appropriate value
     v3_.x = -Length;
     v3_.y = Length;
     double omega_ = 0F; // TODO: Initialize to an appropriate value
     omega_ = Math.PI;
     txRectangle target = new txRectangle(v0_, v1_, v2_, v3_, omega_);
     Assert.AreEqual(target.LeftBottomV, v0_);
     Assert.AreEqual(target.RightBottomV, v1_);
     Assert.AreEqual(target.RightTopV, v2_);
     Assert.AreEqual(target.LeftTopV, v3_);
     //Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void AddForcToDisk(txVector2 f)
 {
     force = force + f;
 }
Exemple #11
0
 public double Distance(txVector2 v_)
 {
     return Math.Sqrt(SquareDistance(v_));
 }
        public void NormalizeTest()
        {
            txVector2 target = new txVector2(); // TODO: Initialize to an appropriate value
            //target.x = 5;
            //target.y = 12;
            target.x = 3;
            target.y = 4;
            txVector2 expected = new txVector2(); // TODO: Initialize to an appropriate value
            expected.x = .6;
            expected.y = .8;
            txVector2 actual;
            actual = target.Normalize();
            double deltax = Math.Abs(expected.x - actual.x);
            double deltay = Math.Abs(expected.y - actual.y);

            Assert.IsTrue(deltax < txVector2.VECTOR_PRECISION);
            Assert.IsTrue(deltay < txVector2.VECTOR_PRECISION);
            ///??????
            /// Why here the expected and actual don't equal???
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
 private void TestOrientationCaseRight()
 {
     txVector2 pa = new txVector2(); // TODO: Initialize to an appropriate value
     pa.x = 0.0;
     pa.y = 0.0;
     txVector2 pb = new txVector2(); // TODO: Initialize to an appropriate value
     pb.x = 2.0;
     pb.y = 2.0;
     txVector2 pc = new txVector2(); // TODO: Initialize to an appropriate value
     pc.x = 1.0;
     pc.y = 1.0;
     txOrientationState expected = new txOrientationState(); // TODO: Initialize to an appropriate value
     expected = txOrientationState.COLLINEAR;
     txOrientationState actual;
     actual = txVector2.PointOrientationTest(pa, pb, pc);
     Assert.AreEqual(expected, actual);
 }
 public void op_MultiplyTest5()
 {
     double a = 0F; // TODO: Initialize to an appropriate value
     txVector2 v = new txVector2(); // TODO: Initialize to an appropriate value
     v.x = 4.0;
     v.y = 5.0;
     txVector2 expected = new txVector2(); // TODO: Initialize to an appropriate value
     expected.x = 0.0;
     expected.y = 0.0;
     txVector2 actual;
     actual = (a * v);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void op_SubtractionTest1()
 {
     txVector2 l = new txVector2(); // TODO: Initialize to an appropriate value
     l.x = 0.0;
     l.y = .0;
     txVector2 r = new txVector2(); // TODO: Initialize to an appropriate value
     r.x = 10.0;
     r.y = 11.0;
     txVector2 expected = new txVector2(); // TODO: Initialize to an appropriate value
     expected.x = -10.0;
     expected.y = -11.0;
     txVector2 actual;
     actual = (l - r);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void op_MultiplyTest3()
 {
     txVector2 l = new txVector2(); // TODO: Initialize to an appropriate value
     l.x = 0.0;
     l.y = 3.0;
     txVector2 r = new txVector2(); // TODO: Initialize to an appropriate value
     r.x = 0.0;
     r.y = 4.0;
     double expected = 0F; // TODO: Initialize to an appropriate value
     expected = 12.0;
     double actual;
     actual = (l * r);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void op_InequalityTest()
 {
     txVector2 l = new txVector2(); // TODO: Initialize to an appropriate value
     l.x = 0.0;
     l.y = 1.0;
     txVector2 r = new txVector2(); // TODO: Initialize to an appropriate value
     l.x = 0.0;
     l.y = 1.0000000000000000000009;
     bool expected = false; // TODO: Initialize to an appropriate value
     expected = false;
     bool actual;
     actual = (l != r);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void op_AdditionTest()
 {
     txVector2 l = new txVector2(); // TODO: Initialize to an appropriate value
     l.x = 10;
     l.y = 5;
     txVector2 r = new txVector2(); // TODO: Initialize to an appropriate value
     r.x = 20;
     r.y = 20;
     txVector2 expected = new txVector2(); // TODO: Initialize to an appropriate value
     expected.x = 30;
     expected.y = 25;
     txVector2 actual;
     actual = (l + r);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
Exemple #19
0
        // See http://www.cs.cmu.edu/~quake/robust.html
        public static txOrientationState PointOrientationTest(txVector2 pa, txVector2 pb, txVector2 pc)
        {
            double det = (pa.x - pc.x) * (pb.y - pc.y) - (pa.y - pc.y) * (pb.x - pc.x);
            if (det > 0.0)
            {
                return txOrientationState.LEFT;
            }
            if (det < 0.0)
            {
                return txOrientationState.RIGHT;
            }

            return txOrientationState.COLLINEAR;
        }
 public void ZeroTest()
 {
     txVector2 expected = new txVector2(); // TODO: Initialize to an appropriate value
     expected.x = 0.0;
     expected.y = 0.0;
     txVector2 actual;
     actual = txVector2.Zero();
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void SquareDistanceTest()
 {
     txVector2 target = new txVector2(); // TODO: Initialize to an appropriate value
     target.x = 3.0;
     target.y = 4.0;
     txVector2 v_ = new txVector2(); // TODO: Initialize to an appropriate value
     v_.x = 6.0;
     v_.y = 8.0;
     double expected = 0F; // TODO: Initialize to an appropriate value
     expected = 25.0;
     double actual;
     actual = target.SquareDistance(v_);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
Exemple #22
0
 //public static void operator += (txVector2 r) {
 //    this = this + r;
 //}
 public double SquareDistance(txVector2 v_)
 {
     double xl = x-v_.x;
     double yl = y-v_.y;
     return xl * xl + yl * yl;
 }
 public void txVector2ConstructorTest()
 {
     double x_ = 0F; // TODO: Initialize to an appropriate value
     double y_ = 0F; // TODO: Initialize to an appropriate value
     txVector2 target = new txVector2(x_, y_);
     txVector2 expected;
     expected.x = 0.0;
     expected.y = 0.0;
     Assert.AreEqual(target, expected);
     //Assert.Inconclusive("TODO: Implement code to verify target");
 }
 private void Rotate(double t)
 {
     met = new txMatrix2(t * omega);
     leftBottomV = met * constleftBottomV;
     rightBottomV = met * constrightBottomV;
     rightTopV = met * constrightTopV;
     leftTopV = met * constleftTopV;
     AssemblyLineSegmentList();
 }