~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to agg/src/agg_bezier_arc.cpp

  • Committer: corsixth.bot at gmail
  • Date: 2014-03-31 23:30:23 UTC
  • Revision ID: svn-v4:c39591fa-788f-11de-a72b-d90af8dea425:trunk:2687
Remove trailing whitespaces in .h, .cpp, .c and .lua files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Anti-Grain Geometry - Version 2.4
3
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
4
//
5
 
// Permission to copy, use, modify, sell and distribute this software 
6
 
// is granted provided this copyright notice appears in all copies. 
 
5
// Permission to copy, use, modify, sell and distribute this software
 
6
// is granted provided this copyright notice appears in all copies.
7
7
// This software is provided "as is" without express or implied
8
8
// warranty, and with no claim as to its suitability for any purpose.
9
9
//
13
13
//          http://www.antigrain.com
14
14
//----------------------------------------------------------------------------
15
15
//
16
 
// Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e., 
 
16
// Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e.,
17
17
// 4, 7, 10, or 13 vertices.
18
18
//
19
19
//----------------------------------------------------------------------------
26
26
namespace agg
27
27
{
28
28
 
29
 
    // This epsilon is used to prevent us from adding degenerate curves 
 
29
    // This epsilon is used to prevent us from adding degenerate curves
30
30
    // (converging to a single point).
31
 
    // The value isn't very critical. Function arc_to_bezier() has a limit 
32
 
    // of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve 
 
31
    // The value isn't very critical. Function arc_to_bezier() has a limit
 
32
    // of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve
33
33
    // becomes inaccurate. But slight exceeding is quite appropriate.
34
34
    //-------------------------------------------------bezier_arc_angle_epsilon
35
35
    const double bezier_arc_angle_epsilon = 0.01;
36
36
 
37
37
    //------------------------------------------------------------arc_to_bezier
38
 
    void arc_to_bezier(double cx, double cy, double rx, double ry, 
 
38
    void arc_to_bezier(double cx, double cy, double rx, double ry,
39
39
                       double start_angle, double sweep_angle,
40
40
                       double* curve)
41
41
    {
68
68
 
69
69
 
70
70
    //------------------------------------------------------------------------
71
 
    void bezier_arc::init(double x,  double y, 
72
 
                          double rx, double ry, 
73
 
                          double start_angle, 
 
71
    void bezier_arc::init(double x,  double y,
 
72
                          double rx, double ry,
 
73
                          double start_angle,
74
74
                          double sweep_angle)
75
75
    {
76
76
        start_angle = fmod(start_angle, 2.0 * pi);
119
119
                }
120
120
            }
121
121
 
122
 
            arc_to_bezier(x, y, rx, ry, 
123
 
                          start_angle, 
124
 
                          local_sweep, 
 
122
            arc_to_bezier(x, y, rx, ry,
 
123
                          start_angle,
 
124
                          local_sweep,
125
125
                          m_vertices + m_num_vertices - 2);
126
126
 
127
127
            m_num_vertices += 6;
134
134
 
135
135
 
136
136
    //--------------------------------------------------------------------
137
 
    void bezier_arc_svg::init(double x0, double y0, 
138
 
                              double rx, double ry, 
 
137
    void bezier_arc_svg::init(double x0, double y0,
 
138
                              double rx, double ry,
139
139
                              double angle,
140
140
                              bool large_arc_flag,
141
141
                              bool sweep_flag,
146
146
        if(rx < 0.0) rx = -rx;
147
147
        if(ry < 0.0) ry = -rx;
148
148
 
149
 
        // Calculate the middle point between 
 
149
        // Calculate the middle point between
150
150
        // the current and the final points
151
151
        //------------------------
152
152
        double dx2 = (x0 - x2) / 2.0;
170
170
        // Check that radii are large enough
171
171
        //------------------------
172
172
        double radii_check = px1/prx + py1/pry;
173
 
        if(radii_check > 1.0) 
 
173
        if(radii_check > 1.0)
174
174
        {
175
175
            rx = sqrt(radii_check) * rx;
176
176
            ry = sqrt(radii_check) * ry;
222
222
        if(v < -1.0) v = -1.0;
223
223
        if(v >  1.0) v =  1.0;
224
224
        double sweep_angle = sign * acos(v);
225
 
        if(!sweep_flag && sweep_angle > 0) 
 
225
        if(!sweep_flag && sweep_angle > 0)
226
226
        {
227
227
            sweep_angle -= pi * 2.0;
228
 
        } 
229
 
        else 
230
 
        if (sweep_flag && sweep_angle < 0) 
 
228
        }
 
229
        else
 
230
        if (sweep_flag && sweep_angle < 0)
231
231
        {
232
232
            sweep_angle += pi * 2.0;
233
233
        }
237
237
        m_arc.init(0.0, 0.0, rx, ry, start_angle, sweep_angle);
238
238
        trans_affine mtx = trans_affine_rotation(angle);
239
239
        mtx *= trans_affine_translation(cx, cy);
240
 
        
 
240
 
241
241
        for(unsigned i = 2; i < m_arc.num_vertices()-2; i += 2)
242
242
        {
243
243
            mtx.transform(m_arc.vertices() + i, m_arc.vertices() + i + 1);