Exemplo n.º 1
0
 public static IPrimitive PrimitiveFromPointAndVertex(Point lastPoint, Vertex nextVertex)
 {
     if (nextVertex.IsLine)
     {
         return(new PrimitiveLine(lastPoint, nextVertex.Location));
     }
     else
     {
         return(PrimitiveEllipse.ArcFromPointsAndIncludedAngle(lastPoint, nextVertex.Location, nextVertex.IncludedAngle, nextVertex.Direction));
     }
 }
Exemplo n.º 2
0
 public static IPrimitive PrimitiveFromVertices(Vertex last, Vertex next)
 {
     if (last.IsLine)
     {
         return(new PrimitiveLine(last.Location, next.Location));
     }
     else
     {
         return(PrimitiveEllipse.ArcFromPointsAndIncludedAngle(last.Location, next.Location, last.IncludedAngle, last.Direction));
     }
 }
Exemplo n.º 3
0
        public void ArcsFromPointsAndRadiusTest1()
        {
            // given the points (0, 1) and (0, -1) and an included angle of 90 degrees, the possible centers for the arcs
            // here are (1, 0) and (-1, 0) and a radius of sqrt(2)
            var p1            = new Point(0, 1, 0);
            var p2            = new Point(0, -1, 0);
            var includedAngle = 90.0;

            var sqrt2 = Math.Sqrt(2.0);

            var arc1 = PrimitiveEllipse.ArcFromPointsAndIncludedAngle(p1, p2, includedAngle, VertexDirection.Clockwise);

            AssertClose(new Point(-1, 0, 0), arc1.Center);
            AssertClose(sqrt2, arc1.MajorAxis.Length);
            AssertClose(315.0, arc1.StartAngle);
            AssertClose(45.0, arc1.EndAngle);

            var arc2 = PrimitiveEllipse.ArcFromPointsAndIncludedAngle(p1, p2, includedAngle, VertexDirection.CounterClockwise);

            AssertClose(new Point(1, 0, 0), arc2.Center);
            AssertClose(sqrt2, arc2.MajorAxis.Length);
            AssertClose(135.0, arc2.StartAngle);
            AssertClose(225.0, arc2.EndAngle);
        }