1from _common_decl cimport * 2 3from _cy_rectangle cimport Rect, cy_Rect, wrap_Rect 4from _cy_primitives cimport Point, cy_Point, wrap_Point 5 6 7cdef extern from "2geom/affine.h" namespace "Geom": 8 cdef cppclass Affine: 9 10 Affine(Affine &) 11 Affine() 12 Affine(Coord, Coord, Coord, Coord, Coord, Coord) 13 14 Coord operator[](unsigned int) 15 16 Affine & operator*(Affine &) 17 Affine & operator*(Translate &) 18 Affine & operator*(Scale &) 19 Affine & operator*(Rotate &) 20 Affine & operator*(HShear &) 21 Affine & operator*(VShear &) 22 Affine & operator*(Zoom &) 23 24 bint operator==(Affine &) 25 bint operator!=(Affine &) 26 27 Point xAxis() 28 Point yAxis() 29 Point translation() 30 Coord expansionX() 31 Coord expansionY() 32 Point expansion() 33 34 void setXAxis(Point &) 35 void setYAxis(Point &) 36 void setTranslation(Point &) 37 void setExpansionX(Coord) 38 void setExpansionY(Coord) 39 void setIdentity() 40 41 bint isIdentity(Coord) 42 bint isTranslation(Coord) 43 bint isScale(Coord) 44 bint isUniformScale(Coord) 45 bint isRotation(Coord) 46 bint isHShear(Coord) 47 bint isVShear(Coord) 48 bint isNonzeroTranslation(Coord) 49 bint isNonzeroScale(Coord) 50 bint isNonzeroUniformScale(Coord) 51 bint isNonzeroRotation(Coord) 52 bint isNonzeroHShear(Coord) 53 bint isNonzeroVShear(Coord) 54 bint isZoom(Coord) 55 bint preservesArea(Coord) 56 bint preservesAngles(Coord) 57 bint preservesDistances(Coord) 58 bint flips() 59 bint isSingular(Coord) 60 61 Affine withoutTranslation() 62 Affine inverse() 63 64 Coord det() 65 Coord descrim2() 66 Coord descrim() 67 68 bint are_near(Affine &, Affine &, Coord) 69 Affine a_identity "Geom::Affine::identity" () 70 71cdef extern from "2geom/transforms.h" namespace "Geom": 72 Affine reflection(Point &, Point &) 73 #TODO find out how cython __pow__ works 74 Affine pow(Affine &, int) 75 Translate pow(Translate &, int) 76 Scale pow(Scale &, int) 77 Rotate pow(Rotate &, int) 78 HShear pow(HShear &, int) 79 VShear pow(VShear &, int) 80 Zoom pow(Zoom &, int) 81 82cdef class cy_Affine: 83 cdef Affine* thisptr 84 85cdef cy_Affine wrap_Affine(Affine) 86 87#helper functions 88cdef Affine get_Affine(t) 89cdef bint is_transform(t) 90 91 92cdef extern from "2geom/transforms.h" namespace "Geom": 93 cdef cppclass Translate: 94 Translate(Translate &) 95 Translate() 96 Translate(Point &) 97 Translate(Coord, Coord) 98 Coord operator[](Dim2) 99 Coord operator[](unsigned int) 100 Translate & operator*(Translate &) 101 Affine & operator*(Affine &) 102 bint operator==(Translate &) 103 bint operator!=(Translate &) 104 105 Affine operator() 106 107 Point vector() 108 Translate inverse() 109 110 Translate t_identity "Geom::Translate::identity" () 111 112cdef class cy_Translate: 113 cdef Translate* thisptr 114 115 116cdef extern from "2geom/transforms.h" namespace "Geom": 117 cdef cppclass Scale: 118 Scale(Scale &) 119 Scale() 120 Scale(Point &) 121 Scale(Coord, Coord) 122 Scale(Coord) 123 Coord operator[](Dim2) 124 Scale & operator*(Scale &) 125 Affine & operator*(Affine &) 126 bint operator==(Scale &) 127 bint operator!=(Scale &) 128 129 Affine operator() 130 131 Point vector() 132 Scale inverse() 133 Scale identity() 134 135 Scale s_identity "Geom::Scale::identity" () 136 137cdef class cy_Scale: 138 cdef Scale* thisptr 139 140 141cdef extern from "2geom/transforms.h" namespace "Geom": 142 cdef cppclass Rotate: 143 Rotate(Rotate &) 144 Rotate() 145 Rotate(Coord) 146 Rotate(Point &) 147 Rotate(Coord, Coord) 148 Point vector() 149 150 Coord operator[](Dim2) 151 Coord operator[](unsigned int) 152 Rotate & operator*(Rotate &) 153 Affine & operator*(Affine &) 154 bint operator==(Rotate &) 155 bint operator!=(Rotate &) 156 157 Affine operator() 158 Rotate inverse() 159 160 Rotate r_identity "Geom::Rotate::identity" () 161 162cdef extern from "2geom/transforms.h" namespace "Geom::Rotate": 163 Rotate from_degrees(Coord) 164 165 166cdef class cy_Rotate: 167 cdef Rotate* thisptr 168 169cdef extern from "2geom/transforms.h" namespace "Geom": 170 cdef cppclass VShear: 171 VShear(VShear &) 172 VShear(Coord) 173 Coord factor() 174 void setFactor(Coord) 175 176 VShear &operator*(VShear) 177 Affine & operator*(Affine &) 178 bint operator==(VShear &) 179 bint operator!=(VShear &) 180 Affine operator() 181 182 VShear inverse() 183 184 VShear vs_identity "Geom::VShear::identity"() 185 186cdef class cy_VShear: 187 cdef VShear* thisptr 188 189 190cdef extern from "2geom/transforms.h" namespace "Geom": 191 cdef cppclass HShear: 192 HShear(HShear &) 193 HShear(Coord) 194 Coord factor() 195 void setFactor(Coord) 196 HShear &operator*(HShear) 197 Affine & operator*(Affine &) 198 bint operator==(HShear &) 199 bint operator!=(HShear &) 200 Affine operator() 201 202 HShear inverse() 203 204 HShear hs_identity "Geom::HShear::identity"() 205 206cdef class cy_HShear: 207 cdef HShear* thisptr 208 209 210cdef extern from "2geom/transforms.h" namespace "Geom": 211 cdef cppclass Zoom: 212 Zoom(Zoom &) 213 Zoom(Coord) 214 Zoom(Translate &) 215 Zoom(Coord, Translate &) 216 217 Zoom & operator*(Zoom &) 218 Affine & operator*(Affine &) 219 bint operator==(Zoom &) 220 bint operator!=(Zoom &) 221 222 Affine operator() 223 224 Coord scale() 225 void setScale(Coord) 226 Point translation() 227 void setTranslation(Point &) 228 229 Zoom inverse() 230 231 Zoom() 232 233 Zoom z_identity "Geom::Zoom::identity" () 234 235cdef extern from "2geom/transforms.h" namespace "Geom::Zoom": 236 Zoom map_rect(Rect &, Rect &) 237 238cdef class cy_Zoom: 239 cdef Zoom* thisptr 240 241 242cdef extern from "2geom/affine.h" namespace "Geom": 243 cdef cppclass Eigen: 244 Point *vectors 245 double *values 246 Eigen(Affine &) 247 Eigen(double[2][2]) 248