1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 // Arc vertex generator
18 //----------------------------------------------------------------------------
26 //------------------------------------------------------------------------
27 arc::arc(double x
, double y
,
31 m_x(x
), m_y(y
), m_rx(rx
), m_ry(ry
), m_scale(1.0)
33 normalize(a1
, a2
, ccw
);
36 //------------------------------------------------------------------------
37 void arc::init(double x
, double y
,
44 normalize(a1
, a2
, ccw
);
47 //------------------------------------------------------------------------
48 void arc::approximation_scale(double s
)
53 normalize(m_start
, m_end
, m_ccw
);
57 //------------------------------------------------------------------------
58 void arc::rewind(unsigned)
60 m_path_cmd
= path_cmd_move_to
;
64 //------------------------------------------------------------------------
65 unsigned arc::vertex(double* x
, double* y
)
67 if(is_stop(m_path_cmd
)) return path_cmd_stop
;
68 if((m_angle
< m_end
) != m_ccw
)
70 *x
= m_x
+ cos(m_end
) * m_rx
;
71 *y
= m_y
+ sin(m_end
) * m_ry
;
72 m_path_cmd
= path_cmd_stop
;
73 return path_cmd_line_to
;
76 *x
= m_x
+ cos(m_angle
) * m_rx
;
77 *y
= m_y
+ sin(m_angle
) * m_ry
;
81 unsigned pf
= m_path_cmd
;
82 m_path_cmd
= path_cmd_line_to
;
86 //------------------------------------------------------------------------
87 void arc::normalize(double a1
, double a2
, bool ccw
)
89 m_da
= fabs(1.0 / ((m_rx
+ m_ry
) * 0.5 * m_scale
));
92 while(a2
< a1
) a2
+= pi
* 2.0;
96 while(a1
< a2
) a1
+= pi
* 2.0;
102 m_initialized
= true;