public static VisualArc Create(Arc arc, Pen pen = null)
 {
     return new VisualArc(arc)
     {
         Pen = pen
     };
 }
Пример #2
0
 public void ArcAngleToX(double radius, string arcAngle, string baseVector,  string expected)
 {
     var arc = new Arc(radius, Angle.Parse(arcAngle), Vector2.Parse(baseVector))
     {
         Location = new Vector2(140, 140),
     };
     var expectedAngle = Angle.Parse(expected);
     Assert.AreEqual(expectedAngle, arc.Angle2X);
 }
        private bool InterceptArcWith(Arc arc, double tolerance = GeometrySettings.DEFAULT_TOLERANCE)
        {
            var c1 = this.ToCircle();
            var c2 = arc.ToCircle();
            var possibles = c1.Intersect(c2, tolerance);

            foreach (var p in possibles)
            {
                if (this.Contains(p, tolerance) && arc.Contains(p, tolerance))
                    return true;
            }

            return false;
        }
        private IEnumerable<Vector2> InterceptArc(Arc arc, double tolerance = GeometrySettings.DEFAULT_TOLERANCE)
        {
            var intersections = new List<Vector2>();
            var c1 = this.ToCircle();
            var c2 = arc.ToCircle();

            var possibles = c1.Intersect(c2, tolerance);

            foreach (var p in possibles)
            {
                if (this.Contains(p, tolerance) && arc.Contains(p, tolerance))
                    intersections.Add(p);
            }


            return intersections;
        }
Пример #5
0
 public VisualArc(Arc arc)
 {
     _arc = arc;
 }
Пример #6
0
        /// <summary>
        /// Returns a point on this arc, with a delta angle from the arc start point.
        /// </summary>
        /// <param name="deltaAngle"></param>
        /// <returns></returns>
        public Vector2 GetPointOnArc(Angle deltaAngle)
        {
            var helperArc = new Arc(Radius, deltaAngle, _base);
            helperArc.Direction = this.Direction;
            helperArc.Location = this.Location;

            var relAngle = CalcRelAngle(
                helperArc.Angle,
                _base.AngleSignedTo(Vector2.UnitX, true),
                helperArc.Direction);

            var pointOnArc = CalcEndpointDelta2M(helperArc.Radius, relAngle);

            var helperMP = helperArc.MiddlePoint;
            pointOnArc = new Vector2(pointOnArc.X + helperMP.X, pointOnArc.Y + helperMP.Y);

            return pointOnArc;
        }
Пример #7
0
 /// <summary>
 /// Creates a new Arc with the same values as the given prototype
 /// </summary>
 /// <param name="prototype"></param>
 public Arc(Arc prototype)
 {
     Prototype(prototype);
 }
Пример #8
0
        /// <summary>
        /// Split a given Rotation-Amount from this Arc
        /// </summary>
        /// <param name="splitAngle"></param>
        /// <returns></returns>
        public IEnumerable<Arc> Split(Angle splitAngle)
        {
            var arcs = new List<Arc>();

            splitAngle = Angle.Abs(splitAngle);
            if ((splitAngle > this.Angle))
            {
                arcs.Add(this); // can't split...
            }
            else
            { /* split the arc */

                //segment uno
                var split = new Arc(this.Radius, splitAngle, _base);
                split.Location = this.Location;
                split.Direction = this.Direction;
                //split.AngleDiff = this.AngleDiff;
                arcs.Add(split);

                //segment due
                Vector2 newBase;
                if (this.Direction == Direction.LEFT)
                {
                    newBase = _base.GetRotated(splitAngle);
                }
                else
                {
                    newBase = _base.GetRotated(-splitAngle);
                }
                split = new Arc(this.Radius, this.Angle - splitAngle, newBase);
                split.Location = this.GetPointOnArc(splitAngle);
                split.Direction = this.Direction;
                //split.AngleDiff = this.AngleDiff;
                arcs.Add(split);
            }
            return arcs;
        }