コード例 #1
0
        public void Can_calculate_perpendicular_line_to_a_point()
        {
            GeometricVector vectorOfLine = new GeometricVector(2, 2, 0);
            CartesianPoint  pointOnLine  = new CartesianPoint(3, 4, 5);
            UnboundedLine   SUT          = new UnboundedLine(vectorOfLine, pointOnLine);

            CartesianPoint perpendicularPoint = new CartesianPoint(3, 6, 5);
            BoundedLine    result             = SUT.PerpendicularLineTo(perpendicularPoint);

            Assert.AreEqual(-1, result.X);
            Assert.AreEqual(1, result.Y);
            Assert.AreEqual(0, result.Z);
            Assert.AreEqual(4, result.Start.X);
            Assert.AreEqual(5, result.Start.Y);
            Assert.AreEqual(5, result.Start.Z);
        }
コード例 #2
0
        public void Can_determine_if_point_is_on_the_line()
        {
            vectorOfLine = new GeometricVector(2, 2, 2);
            startPoint   = new CartesianPoint(3, 4, 5);
            SUT          = new BoundedLine(startPoint, vectorOfLine);

            CartesianPoint pointOnTheLine     = new CartesianPoint(4, 5, 6);
            CartesianPoint pointAtEndOfLine   = new CartesianPoint(5, 6, 7);
            CartesianPoint pointAtStartOfLine = new CartesianPoint(3, 4, 5);

            CartesianPoint pointBeyondEndOfLine   = new CartesianPoint(6, 7, 8);
            CartesianPoint pointBeyondStartOfLine = new CartesianPoint(2, 3, 4);

            Assert.IsTrue(SUT.IsOnLine(pointOnTheLine));
            Assert.IsTrue(SUT.IsOnLine(pointAtEndOfLine));
            Assert.IsTrue(SUT.IsOnLine(pointAtStartOfLine));
            Assert.IsFalse(SUT.IsOnLine(pointBeyondEndOfLine));
            Assert.IsFalse(SUT.IsOnLine(pointBeyondStartOfLine));
        }
コード例 #3
0
        public void Can_be_constructed_from_start_and_end_points()
        {
            SUT = new BoundedLine(startPoint, vectorOfLine);

            Assert.AreEqual(2, SUT.X);
            Assert.AreEqual(3, SUT.Y);
            Assert.AreEqual(4, SUT.Z);

            Assert.AreEqual(2, SUT.Vector.X);
            Assert.AreEqual(3, SUT.Vector.Y);
            Assert.AreEqual(4, SUT.Vector.Z);

            Assert.AreEqual(3, SUT.Start.X);
            Assert.AreEqual(4, SUT.Start.Y);
            Assert.AreEqual(5, SUT.Start.Z);

            Assert.AreEqual(5, SUT.End.X);
            Assert.AreEqual(7, SUT.End.Y);
            Assert.AreEqual(9, SUT.End.Z);
        }
コード例 #4
0
 public void SetUp()
 {
     vectorOfLine = new GeometricVector(2, 3, 4);
     startPoint   = new CartesianPoint(3, 4, 5);
     SUT          = new BoundedLine(startPoint, vectorOfLine);
 }