Code

Correct path separators and missed variable assignment due to indention
[inkscape.git] / src / 2geom / ellipse.h
1 /*\r
2  * Ellipse Curve\r
3  *\r
4  * Authors:\r
5  *      Marco Cecchetti <mrcekets at gmail.com>\r
6  *\r
7  * Copyright 2008  authors\r
8  *\r
9  * This library is free software; you can redistribute it and/or\r
10  * modify it either under the terms of the GNU Lesser General Public\r
11  * License version 2.1 as published by the Free Software Foundation\r
12  * (the "LGPL") or, at your option, under the terms of the Mozilla\r
13  * Public License Version 1.1 (the "MPL"). If you do not alter this\r
14  * notice, a recipient may use your version of this file under either\r
15  * the MPL or the LGPL.\r
16  *\r
17  * You should have received a copy of the LGPL along with this library\r
18  * in the file COPYING-LGPL-2.1; if not, write to the Free Software\r
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
20  * You should have received a copy of the MPL along with this library\r
21  * in the file COPYING-MPL-1.1\r
22  *\r
23  * The contents of this file are subject to the Mozilla Public License\r
24  * Version 1.1 (the "License"); you may not use this file except in\r
25  * compliance with the License. You may obtain a copy of the License at\r
26  * http://www.mozilla.org/MPL/\r
27  *\r
28  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY\r
29  * OF ANY KIND, either express or implied. See the LGPL or the MPL for\r
30  * the specific language governing rights and limitations.\r
31  */\r
32 \r
33 \r
34 #ifndef _2GEOM_ELLIPSE_H_\r
35 #define _2GEOM_ELLIPSE_H_\r
36 \r
37 \r
38 #include <2geom/point.h>\r
39 #include <2geom/exception.h>\r
40 \r
41 \r
42 namespace Geom\r
43 {\r
44 \r
45 class SVGEllipticalArc;\r
46 \r
47 class Ellipse\r
48 {\r
49   public:\r
50     Ellipse()\r
51     {}\r
52 \r
53     Ellipse(double cx, double cy, double rx, double ry, double a)\r
54         : m_centre(cx, cy), m_ray(rx, ry), m_angle(a)\r
55     {\r
56     }\r
57 \r
58     // build an ellipse by its implicit equation:\r
59     // Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0\r
60     Ellipse(double A, double B, double C, double D, double E, double F)\r
61     {\r
62         set(A, B, C, D, E, F);\r
63     }\r
64 \r
65     Ellipse(std::vector<Point> const& points)\r
66     {\r
67         set(points);\r
68     }\r
69 \r
70     void set(double cx, double cy, double rx, double ry, double a)\r
71     {\r
72         m_centre[X] = cx;\r
73         m_centre[Y] = cy;\r
74         m_ray[X] = rx;\r
75         m_ray[Y] = ry;\r
76         m_angle = a;\r
77     }\r
78 \r
79     // build an ellipse by its implicit equation:\r
80     // Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0\r
81     void set(double A, double B, double C, double D, double E, double F);\r
82 \r
83     // biuld up the best fitting ellipse wrt the passed points\r
84     // prerequisite: at least 5 points must be passed\r
85     void set(std::vector<Point> const& points);\r
86 \r
87     SVGEllipticalArc\r
88     arc(Point const& initial, Point const& inner, Point const& final,\r
89         bool _svg_compliant = true);\r
90 \r
91     Point center() const\r
92     {\r
93         return m_centre;\r
94     }\r
95 \r
96     Coord center(Dim2 d) const\r
97     {\r
98         return m_centre[d];\r
99     }\r
100 \r
101     Coord ray(Dim2 d) const\r
102     {\r
103         return m_ray[d];\r
104     }\r
105 \r
106     Coord rot_angle() const\r
107     {\r
108         return m_angle;\r
109     }\r
110 \r
111   private:\r
112     Point m_centre, m_ray;\r
113     double m_angle;\r
114 };\r
115 \r
116 \r
117 } // end namespace Geom\r
118 \r
119 \r
120 \r
121 #endif // _2GEOM_ELLIPSE_H_\r
122 \r
123 \r
124 /*\r
125   Local Variables:\r
126   mode:c++\r
127   c-file-style:"stroustrup"\r
128   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
129   indent-tabs-mode:nil\r
130   fill-column:99\r
131   End:\r
132 */\r
133 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :\r