Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
ellipse.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2009 Ricardo Lafuente <r@sollec.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it either under the terms of the GNU Lesser General Public
6 * License version 2.1 as published by the Free Software Foundation
7 * (the "LGPL") or, at your option, under the terms of the Mozilla
8 * Public License Version 1.1 (the "MPL"). If you do not alter this
9 * notice, a recipient may use your version of this file under either
10 * the MPL or the LGPL.
11 *
12 * You should have received a copy of the LGPL along with this library
13 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 * You should have received a copy of the MPL along with this library
16 * in the file COPYING-MPL-1.1
17 *
18 * The contents of this file are subject to the Mozilla Public License
19 * Version 1.1 (the "License"); you may not use this file except in
20 * compliance with the License. You may obtain a copy of the License at
21 * http://www.mozilla.org/MPL/
22 *
23 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
24 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
25 * the specific language governing rights and limitations.
26 *
27 */
28
29#include <boost/python.hpp>
30#include <boost/python/implicit.hpp>
31#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
32
33#include "py2geom.h"
34#include "helpers.h"
35
36#include "2geom/point.h"
37#include "2geom/ellipse.h"
38#include "2geom/circle.h"
39#include "2geom/exception.h"
40#include "2geom/d2.h"
41
42
43void (Geom::Ellipse::*ellipse_set1)(Geom::Point const &, Geom::Point const &, double) = &Geom::Ellipse::set;
44void (Geom::Ellipse::*ellipse_set2)(double, double, double, double, double) = &Geom::Ellipse::set;
45std::vector<Geom::Coord> (Geom::Ellipse::*ellipse_coefficients)() const = &Geom::Ellipse::coefficients;
46
47// i can't get these to work
48//Geom::Point (Geom::Ellipse::*center_point)() = (Geom::Point (*)() const)&Geom::Ellipse::center;
49// Geom::Coord (Geom::Ellipse::*center_coord)(Geom::Dim2 const& d) = &Geom::Ellipse::center;
50
51using namespace boost::python;
52
54 class_<Geom::Ellipse>("Ellipse", init<double, double, double, double, double>())
55 .def(init<double, double, double, double, double, double>())
56 // needs to be mapped to PointVec, but i can't figure out how
57 .def(init<Geom::Circle>())
58
59 .def("set", ellipse_set1)
60 .def("set", ellipse_set2)
61 .def("setCoefficients", &Geom::Ellipse::setCoefficients)
62 .def("fit", &Geom::Ellipse::fit)
63
64 .def("center", (Geom::Point (Geom::Ellipse::*)() const) &Geom::Ellipse::center)
65 // .def("center", center_coord)
66
67 .def("ray", &Geom::Ellipse::ray)
68 .def("rotationAngle", &Geom::Ellipse::rotationAngle)
69 .def("coefficients", ellipse_coefficients)
70 .def(self * Geom::Affine())
71 .def(self *= Geom::Affine())
72 // requires EllipticalArc
73 //.def("arc", &Geom::Ellipse::arc)
74
75 ;
76
77};
78
79/*
80 Local Variables:
81 mode:c++
82 c-file-style:"stroustrup"
83 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
84 indent-tabs-mode:nil
85 fill-column:99
86 End:
87*/
88// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Defines the different types of exceptions that 2geom can throw.
Cartesian point / 2D vector and related operations.
pair< double, double > Point
Definition parser.cpp:7
Circle shape.
3x3 matrix representing an affine transformation.
Definition affine.h:70
Set of points with a constant sum of distances from two foci.
Definition ellipse.h:68
Angle rotationAngle() const
Get the angle the X ray makes with the +X axis.
Definition ellipse.h:126
void fit(std::vector< Point > const &points)
Create an ellipse passing through the specified points At least five points have to be specified.
Definition ellipse.cpp:206
Coord ray(Dim2 d) const
Get one ray of the ellipse.
Definition ellipse.h:124
Point center() const
Definition ellipse.h:119
void setCoefficients(double A, double B, double C, double D, double E, double F)
Set an ellipse by solving its implicit equation.
Definition ellipse.cpp:48
Two-dimensional point that doubles as a vector.
Definition point.h:66
Lifts one dimensional objects into 2D.
Ellipse shape.
Various utility functions.
Definition affine.h:22
void(Geom::Ellipse::* ellipse_set2)(double, double, double, double, double)
Definition ellipse.cpp:44
void wrap_ellipse()
Definition ellipse.cpp:53
std::vector< Geom::Coord >(Geom::Ellipse::* ellipse_coefficients)() const
Definition ellipse.cpp:45
void(Geom::Ellipse::* ellipse_set1)(Geom::Point const &, Geom::Point const &, double)
Definition ellipse.cpp:43