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);
        }
 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 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.");
        }
示例#4
0
 private void SetUpBoundary()
 {
     // set up container
     txVector2 leftbottom, rightbottom, righttop, lefttop;
     double halfline = 264.0;
     double omega = Math.PI / 60.0;
     leftbottom.x = -halfline; leftbottom.y = -halfline;
     rightbottom.x = halfline; rightbottom.y = -halfline;
     righttop.x = halfline; righttop.y = halfline;
     lefttop.x = -halfline; lefttop.y = halfline;
     rectboundary = new txRectangle(leftbottom, rightbottom, righttop, lefttop, omega);
 }