Exemple #1
0
        void Normalize(double angle1, double angle2, ArcDirection direction)
        {
            double ra = (Math.Abs(radiusX) + Math.Abs(radiusY)) / 2;

            flatenDeltaAngle = Math.Acos(ra / (ra + 0.125 / m_Scale)) * 2;
            if (direction == ArcDirection.CounterClockWise)
            {
                while (angle2 < angle1)
                {
                    angle2 += Math.PI * 2.0;
                }
            }
            else
            {
                while (angle1 < angle2)
                {
                    angle1 += Math.PI * 2.0;
                }
                flatenDeltaAngle = -flatenDeltaAngle;
            }
            m_Direction     = direction;
            startAngle      = angle1;
            endAngle        = angle2;
            m_IsInitialized = true;
            calculateNSteps = (int)Math.Floor(((endAngle - startAngle) / flatenDeltaAngle));
        }
Exemple #2
0
 public Arc(Vector3 start, Vector3 end, Vector3 center, ArcDirection direction)
     : base(start, end)
 {
     Center = center;
     Center.Z = 0;
     Direction = direction;
 }
Exemple #3
0
        /// <summary>
        /// Crea un arco de circunferencia indicando dos puntos y un radio. El arco creado es siempre el que
        /// no contiene el extremo positivo del eje X.
        /// Cuidado con los radios negativos!!!
        /// </summary>
        public static CircleArc2 TwoPointsRadius(Point2d pt0, Point2d pt1, double radius, bool leftRule)
        {
            Point2d      center = EvaluateCenter(pt0, pt1, radius, leftRule);
            ArcDirection dir    = !leftRule ? (radius > 0.0 ? ArcDirection.Clockwise : ArcDirection.CounterClockwise) : (radius < 0.0 ? ArcDirection.Clockwise : ArcDirection.CounterClockwise);

            return(NewArc(pt0, pt1, center, System.Math.Abs(radius), dir));
        }
Exemple #4
0
        public override int GetHashCode()
        {
            const int hashIndex = 307;
            var       result    = (Center != null) ? Center.GetHashCode() : 0;

            result = (result * hashIndex) ^ ((BeginPoint != null) ? BeginPoint.GetHashCode() : 0);
            result = (result * hashIndex) ^ ((EndPoint != null) ? EndPoint.GetHashCode() : 0);
            result = (result * hashIndex) ^ ArcDirection.GetHashCode();

            return(result);
        }
Exemple #5
0
 public void Init(double ox, double oy,
                  double rx, double ry,
                  double angle1, double angle2,
                  ArcDirection direction)
 {
     this.originX = ox;
     this.originY = oy;
     this.radiusX = rx;
     this.radiusY = ry;
     Normalize(angle1, angle2, direction);
 }
Exemple #6
0
 public Arc(double ox, double oy,
      double rx, double ry,
      double angle1, double angle2,
      ArcDirection direction)
 {
     this.originX = ox;
     this.originY = oy;
     this.radiusX = rx;
     this.radiusY = ry;
     this.m_Scale = 1.0;
     Normalize(angle1, angle2, direction);
 }
Exemple #7
0
 public Arc(double ox, double oy,
            double rx, double ry,
            double angle1, double angle2,
            ArcDirection direction)
 {
     _originX = ox;
     _originY = oy;
     _radiusX = rx;
     _radiusY = ry;
     _scale   = 1.0;
     Normalize(angle1, angle2, direction);
 }
Exemple #8
0
 public Arc(double ox, double oy,
            double rx, double ry,
            double angle1, double angle2,
            ArcDirection direction)
 {
     this.originX = ox;
     this.originY = oy;
     this.radiusX = rx;
     this.radiusY = ry;
     this.m_Scale = 1.0;
     Normalize(angle1, angle2, direction);
 }
 public void ArcTo(double x,
     double y,
     double width,
     double height,
     double start,
     double stop,
     ArcDirection direction = ArcDirection.Clockwise)
 {
     var r = Import.Rectangle(new Rectangle(x, y, width, height));
     var startPoint = ArcGeometry.pointOn(r, start);
     _sink.AddLine(startPoint);
     ArcGeometry.add(r, start, stop, _sink, direction.import());
 }
Exemple #10
0
        public static SweepDirection import(this ArcDirection arcDirection)
        {
            switch (arcDirection)
            {
            case ArcDirection.Clockwise:
                return(SweepDirection.Clockwise);

            case ArcDirection.CounterClockwise:
                return(SweepDirection.CounterClockwise);
            }

            return(SweepDirection.Clockwise);
        }
Exemple #11
0
        public void ArcTo(double x,
            double y,
            double width,
            double height,
            double start,
            double stop,
            ArcDirection direction)
        {
            if (_figure_ == null)
                throw new Exception("ArcTo() requires an open figure");

            _figure_.ArcTo(x, y, width, height, start, stop, direction);
        }
        public void ArcTo(double x,
                          double y,
                          double width,
                          double height,
                          double start,
                          double stop,
                          ArcDirection direction = ArcDirection.Clockwise)
        {
            var r          = Import.Rectangle(new Rectangle(x, y, width, height));
            var startPoint = ArcGeometry.pointOn(r, start);

            _sink.AddLine(startPoint);
            ArcGeometry.add(r, start, stop, _sink, direction.import());
        }
Exemple #13
0
        public void ArcTo(double x,
                          double y,
                          double width,
                          double height,
                          double start,
                          double stop,
                          ArcDirection direction)
        {
            if (_figure_ == null)
            {
                throw new Exception("ArcTo() requires an open figure");
            }

            _figure_.ArcTo(x, y, width, height, start, stop, direction);
        }
Exemple #14
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj == null || !GetType().IsEquivalentTo(obj.GetType()))
            {
                return(false);
            }

            ArcSegment other = (ArcSegment)obj;

            return(BeginPoint.Equals(other.BeginPoint) &&
                   EndPoint.Equals(other.EndPoint) &&
                   Center.Equals(other.Center) &&
                   ArcDirection.Equals(other.ArcDirection));
        }
Exemple #15
0
        /// <summary>
        /// Crea un arco de circunferencia indicando puntoInicial, puntoFinal, centro, radio y sentido de giro (cw).
        /// </summary>
        public static CircleArc2 NewArc(Point2d pt1, Point2d pt2, Point2d center, double radius, ArcDirection dir)
        {
            double angle1 = AngleUtils.Ensure0To2Pi(pt1.Sub(center).Angle, false);
            double angle2 = AngleUtils.Ensure0To2Pi(pt2.Sub(center).Angle, false);

            if (dir == ArcDirection.Clockwise)
            {
                if (angle2 > angle1)
                {
                    angle2 -= 2.0 * System.Math.PI;
                }
            }
            else if (angle2 < angle1)
            {
                angle2 += 2.0 * System.Math.PI;
            }
            if (angle2 > 2.0 * System.Math.PI)
            {
                angle1 -= 2.0 * System.Math.PI;
                angle2 -= 2.0 * System.Math.PI;
            }
            else if (angle2 < -2.0 * System.Math.PI)
            {
                angle1 += 2.0 * System.Math.PI;
                angle2 += 2.0 * System.Math.PI;
            }
            return(new CircleArc2(center, radius, angle1, angle2));
        }
Exemple #16
0
 public Arc(Vector3 start, Vector3 end, Vector3 center, ArcDirection direction) : base(start, end)
 {
     Center    = center;
     Center.Z  = 0;
     Direction = direction;
 }
 public void ArcTo(double x, double y, double width, double height, double start, double stop, ArcDirection direction = ArcDirection.Clockwise)
 {
     record(t => t.ArcTo(x, y, width, height, start, stop, direction));
 }
 public static void ArcTo(this IFigureTarget _, Rectangle r, double start, double stop, ArcDirection direction = ArcDirection.Clockwise)
 {
     _.ArcTo(r.X, r.Y, r.Width, r.Height, start, stop, direction);
 }
Exemple #19
0
 public void Init(double ox, double oy,
            double rx, double ry,
            double angle1, double angle2,
            ArcDirection direction)
 {
     this.originX = ox;
     this.originY = oy;
     this.radiusX = rx;
     this.radiusY = ry;
     Normalize(angle1, angle2, direction);
 }
Exemple #20
0
 public static extern void Arc(IntPtr handle, Vector2 center, float radius, float startAngleRads, float endAngleRads, ArcDirection direction);
Exemple #21
0
 void Normalize(double angle1, double angle2, ArcDirection direction)
 {
     double ra = (Math.Abs(radiusX) + Math.Abs(radiusY)) / 2;
     flatenDeltaAngle = Math.Acos(ra / (ra + 0.125 / m_Scale)) * 2;
     if (direction == ArcDirection.CounterClockWise)
     {
         while (angle2 < angle1)
         {
             angle2 += Math.PI * 2.0;
         }
     }
     else
     {
         while (angle1 < angle2)
         {
             angle1 += Math.PI * 2.0;
         }
         flatenDeltaAngle = -flatenDeltaAngle;
     }
     m_Direction = direction;
     startAngle = angle1;
     endAngle = angle2;
     m_IsInitialized = true;
     calculateNSteps = (int)Math.Floor(((endAngle - startAngle) / flatenDeltaAngle));
 }
Exemple #22
0
 public override string ToString()
 {
     return(string.Format("{0};{1};{2};{3}", Center.ToString(), BeginPoint.ToString(), EndPoint.ToString(), ArcDirection.ToString()));
 }
Exemple #23
0
 public void ArcTo(double x, double y, double width, double height, double start, double stop, ArcDirection direction = ArcDirection.Clockwise)
 {
     _records.Add(ft => ft.ArcTo(x, y, width, height, start, stop, direction));
 }
Exemple #24
0
 public static extern ArcDirection SetArcDirection(HDC hdc, ArcDirection dir);
 public static extern ArcDirection SetArcDirection(
     DeviceContext hdc,
     ArcDirection ArcDirection);