Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
transforms.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2006, 2007 Aaron Spike <aaron@ekips.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
31#include "py2geom.h"
32
33#include "2geom/transforms.h"
34
35using namespace boost::python;
36
37//TODO: properly wrap other transforms
38
40 class_<Geom::Affine>("Affine", init<double, double, double, double, double, double>())
41 .def(init<>())
42 .def(init<Geom::Rotate>())
43 .def(init<Geom::Scale>())
44 .def(init<Geom::Translate>())
45 .def(self_ns::str(self))
46 .add_property("xAxis",&Geom::Affine::xAxis,&Geom::Affine::setXAxis)
47 .add_property("yAxis",&Geom::Affine::yAxis,&Geom::Affine::setYAxis)
48 .add_property("translation",&Geom::Affine::translation,&Geom::Affine::setTranslation)
49 .def("isTranslation", &Geom::Affine::isTranslation)
50 .def("isRotation", &Geom::Affine::isRotation)
51 .def("isScale", &Geom::Affine::isScale)
52 .def("isUniformScale", &Geom::Affine::isUniformScale)
53 .def("setIdentity", &Geom::Affine::setIdentity)
54 .def("inverse", &Geom::Affine::inverse)
55 .def("det", &Geom::Affine::det)
56 .def("descrim2", &Geom::Affine::descrim2)
57 .def("descrim", &Geom::Affine::descrim)
58 .def("expansionX", &Geom::Affine::expansionX)
59 .def("expansionY", &Geom::Affine::expansionY)
60 .def(self * self)
61 .def(self * other<Geom::Translate>())
62 .def(self * other<Geom::Scale>())
63 .def(self * other<Geom::Rotate>())
64 ;
65
66 class_<Geom::Scale>("Scale", init<double, double>())
67 .def(self == self)
68 .def(self != self)
69 .def("inverse", &Geom::Scale::inverse)
70 .def(Geom::Point() * self)
71 .def(self * self)
72 .def(self * Geom::Affine())
73 ;
74
75 class_<Geom::Translate>("Translate", init<double, double>())
76 .def(init<Geom::Point>())
77 .def(self == self)
78 .def(self != self)
79 .def("inverse", &Geom::Translate::inverse)
80 .def(Geom::Point() * self)
81 .def(self * self)
82 .def(self * other<Geom::Rotate>())
83 .def(self * other<Geom::Scale>())
84 ;
85
86 class_<Geom::Rotate>("Rotate", init<double>())
87 .def(self == self)
88 .def(self != self)
89 .def("inverse", &Geom::Rotate::inverse)
90 .def("from_degrees", &Geom::Rotate::from_degrees)
91 .staticmethod("from_degrees")
92 .def(Geom::Point() * self)
93 .def(self * self)
94 .def(Geom::Affine() * self)
95 ;
96};
97
98/*
99 Local Variables:
100 mode:c++
101 c-file-style:"stroustrup"
102 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103 indent-tabs-mode:nil
104 fill-column:99
105 End:
106*/
107// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
3x3 matrix representing an affine transformation.
Definition affine.h:70
void setYAxis(Point const &vec)
Definition affine.cpp:50
Coord det() const
Calculate the determinant.
Definition affine.cpp:416
void setTranslation(Point const &loc)
Sets the translation imparted by the Affine.
Definition affine.cpp:56
Point yAxis() const
Definition affine.cpp:36
Point translation() const
Gets the translation imparted by the Affine.
Definition affine.cpp:41
Coord descrim() const
Calculate the descriminant.
Definition affine.cpp:434
bool isScale(Coord eps=EPSILON) const
Check whether this matrix represents pure scaling.
Definition affine.cpp:147
bool isUniformScale(Coord eps=EPSILON) const
Check whether this matrix represents pure uniform scaling.
Definition affine.cpp:174
void setXAxis(Point const &vec)
Definition affine.cpp:45
Coord expansionX() const
Calculates the amount of x-scaling imparted by the Affine.
Definition affine.cpp:64
Coord descrim2() const
Calculate the square of the descriminant.
Definition affine.cpp:424
Point xAxis() const
Definition affine.cpp:32
void setIdentity()
Sets this matrix to be the Identity Affine.
Definition affine.cpp:96
bool isTranslation(Coord eps=EPSILON) const
Check whether this matrix represents a pure translation.
Definition affine.cpp:123
Affine inverse() const
Compute the inverse matrix.
Definition affine.cpp:388
bool isRotation(Coord eps=EPSILON) const
Check whether this matrix represents a pure rotation.
Definition affine.cpp:206
Coord expansionY() const
Calculates the amount of y-scaling imparted by the Affine.
Definition affine.cpp:71
Two-dimensional point that doubles as a vector.
Definition point.h:66
static Rotate from_degrees(Coord deg)
Construct a rotation from its angle in degrees.
Definition transforms.h:218
Rotate inverse() const
Definition transforms.h:209
Scale inverse() const
Definition transforms.h:172
Translate inverse() const
Get the inverse translation.
Definition transforms.h:133
void wrap_transforms()
Affine transformation classes.