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));
 }
        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 void txMatrix2ConstructorTest()
 {
     double m00_ = 0F; // TODO: Initialize to an appropriate value
     double m01_ = 0F; // TODO: Initialize to an appropriate value
     double m10_ = 0F; // TODO: Initialize to an appropriate value
     double m11_ = 0F; // TODO: Initialize to an appropriate value
     txMatrix2 target = new txMatrix2(m00_, m01_, m10_, m11_);
     Assert.AreEqual(target.m00, m00_);
     Assert.AreEqual(target.m01, m01_);
     Assert.AreEqual(target.m10, m10_);
     Assert.AreEqual(target.m11, m11_);
     //Assert.Inconclusive("TODO: Implement code to verify target");
 }
 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 ScaleTest()
 {
     txMatrix2 target = new txMatrix2(); // TODO: Initialize to an appropriate value
     target.m00 = 1.0;
     target.m01 = 4.0;
     target.m10 = 5.0;
     target.m11 = 6.0;
     double s = 0F; // TODO: Initialize to an appropriate value
     s = 3.0;
     txMatrix2 expected = new txMatrix2(); // TODO: Initialize to an appropriate value
     expected.m00 = 3.0;
     expected.m01 = 4.0;
     expected.m10 = 5.0;
     expected.m11 = 18.0;
     txMatrix2 actual;
     actual = target.Scale(s);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
 private void Rotate(double t)
 {
     met = new txMatrix2(t * omega);
     leftBottomV = met * constleftBottomV;
     rightBottomV = met * constrightBottomV;
     rightTopV = met * constrightTopV;
     leftTopV = met * constleftTopV;
     AssemblyLineSegmentList();
 }
        public void txMatrix2ConstructorTest1()
        {
            double theta = 0F; // TODO: Initialize to an appropriate value
            theta = Math.PI;
            txMatrix2 target = new txMatrix2(theta);
            Assert.AreEqual(target.m00, -1.0);
            Assert.IsTrue(Math.Abs(target.m01) < txVector2.VECTOR_PRECISION);
            Assert.IsTrue(Math.Abs(target.m01)<txVector2.VECTOR_PRECISION);
            Assert.IsTrue(Math.Abs(target.m10) < txVector2.VECTOR_PRECISION);
            Assert.IsTrue(Math.Abs(target.m10)<txVector2.VECTOR_PRECISION);
            Assert.IsTrue(Math.Abs(target.m11+1.0)<txVector2.VECTOR_PRECISION);

            double theata2 = Math.PI / 3.0;
            double cos2 = Math.Cos(theata2);
            double sin2 = Math.Sin(theata2);
            txMatrix2 target2 = new txMatrix2(theata2);
            Assert.IsTrue(Math.Abs(cos2 - target2.m00) < txVector2.VECTOR_PRECISION);
            Assert.IsTrue(Math.Abs(sin2 + target2.m01) < txVector2.VECTOR_PRECISION);
            Assert.IsTrue(Math.Abs(sin2 - target2.m10) < txVector2.VECTOR_PRECISION);
            Assert.IsTrue(Math.Abs(cos2 - target2.m11) < txVector2.VECTOR_PRECISION);
            //Assert.IsTrue(false);
            // Assert.Inconclusive("TODO: Implement code to verify target");
        }
 public void YImageOperationTest()
 {
     txMatrix2 expected = new txMatrix2(); // TODO: Initialize to an appropriate value
     expected.m00 = 1.0;
     expected.m01 = 0.0;
     expected.m10 = 0.0;
     expected.m11 = -1.0;
     txMatrix2 actual;
     actual = txMatrix2.YImageOperation();
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }