summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/2geom/src/cython/_cy_primitives.pxd
blob: 87df1c6a27a0f55ca334fd6f621cfbd3f6c50cf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
from _common_decl cimport *


cdef extern from "2geom/affine.h" namespace "Geom":
    cdef cppclass Affine:
        pass
    cdef cppclass Translate
    cdef cppclass Scale
    cdef cppclass Rotate
    cdef cppclass VShear
    cdef cppclass HShear
    cdef cppclass Zoom

    
cdef extern from "2geom/angle.h" namespace "Geom":
    cdef cppclass Angle:
        Angle()
        Angle(Coord)
        Angle(Point)
        Coord radians()
        Coord radians0()
        Coord degrees()
        Coord degreesClock()

        Coord operator()
        Angle &operator+(Angle &)
        Angle &operator-(Angle &)
        bint operator==(Angle &)
        bint operator!=(Angle &)

    Coord rad_from_deg(Coord)
    Coord deg_from_rad(Coord)

cdef extern from "2geom/angle.h" namespace "Geom::Angle":
    Angle from_radians(Coord d)
    Angle from_degrees(Coord d)
    Angle from_degrees_clock(Coord d)

cdef class cy_Angle:
    cdef Angle* thisptr

cdef cy_Angle wrap_Angle(Angle)


cdef extern from "2geom/angle.h" namespace "Geom":
    cdef cppclass AngleInterval:
        AngleInterval(AngleInterval &)
        AngleInterval(Angle &, Angle &, bint)
        AngleInterval(double, double, bint)
        Angle & initialAngle()
        Angle & finalAngle()
        bint isDegenerate()
        Angle angleAt(Coord)
        Angle operator()(Coord)
        bint contains(Angle &)
        Coord extent()


cdef extern from "2geom/point.h" namespace "Geom":
    cdef cppclass Point:
        Point()
        Point(Coord, Coord)
        Coord length()
        Point ccw()
        Point cw()
        Coord x()
        Coord y()
        IntPoint round()
        IntPoint floor()
        IntPoint ceil()

        bint isFinite()
        bint isZero()
        bint isNormalized(Coord)

        bint operator==(Point &)
        bint operator!=(Point &)
        bint operator<(Point &)
        bint operator>(Point &)
        bint operator<=(Point &)
        bint operator>=(Point &)

        Coord &operator[](int)
        Point operator-()
        Point &operator+(Point &)
        Point &operator-(Point &)
        Point &operator*(Coord)
        Point &operator/(Coord)
        
        Point &operator*(Affine  &)
        Point &operator*(Translate  &)
        Point &operator*(Scale  &)
        Point &operator*(Rotate  &)
        Point &operator*(HShear  &)
        Point &operator*(VShear  &)
        Point &operator*(Zoom  &)
            
    Coord L2(Point &)
    Coord L2sq(Point &)

    bint are_near(Point &, Point &, double)

    Point middle_point(Point &, Point &)
    Point rot90(Point &)
    Point lerp(double, Point &, Point &)

    Coord dot(Point &, Point &)
    Coord cross(Point &, Point &)
    Coord distance (Point &, Point &)
    Coord distanceSq (Point &, Point &)

    Point unit_vector(Point &)
    Coord L1(Point &)
    Coord LInfty(Point &)
    bint is_zero(Point &)
    bint is_unit_vector(Point &)
    double atan2(Point &)
    double angle_between(Point &, Point &)
    Point abs(Point &)
    Point constrain_angle(Point &, Point &, unsigned int, Point &)

cdef extern from "2geom/point.h" namespace "Geom::Point":
    Point polar(Coord angle, Coord radius)

cdef class cy_Point:
    cdef Point* thisptr

cdef cy_Point wrap_Point(Point p)
cdef object wrap_vector_point(vector[Point] v)
cdef vector[Point] make_vector_point(object l)


cdef extern from "2geom/int-point.h" namespace "Geom":
    cdef cppclass IntPoint:
        IntPoint()
        IntPoint(IntCoord, IntCoord)
        IntPoint(IntPoint &)
        IntCoord operator[](unsigned int)
        IntCoord x()
        IntCoord y()
        #why doesn't IntPoint have unary -?
        IntPoint & operator+(IntPoint &)
        IntPoint & operator-(IntPoint &)
        bint operator==(IntPoint &)
        bint operator!=(IntPoint &)
        bint operator<=(IntPoint &)
        bint operator>=(IntPoint &)
        bint operator>(IntPoint &)
        bint operator<(IntPoint &)

cdef class cy_IntPoint:
    cdef IntPoint* thisptr

cdef cy_IntPoint wrap_IntPoint(IntPoint p)


cdef extern from "2geom/curve.h" namespace "Geom":
    cdef cppclass Curve

cdef extern from "2geom/bezier.h" namespace "Geom":
    cdef cppclass LineSegment

cdef extern from "2geom/line.h" namespace "Geom":
    cdef cppclass Line:
        Line()
        Line(Point &, Coord)
        Line(Point &, Point &)

        Line(LineSegment &)
        Line(Ray &)
        Line* duplicate()

        Point origin()
        Point versor()
        Coord angle()
        void setOrigin(Point &)
        void setVersor(Point &)
        void setAngle(Coord)
        void setPoints(Point &, Point &)
        void setCoefficients(double, double, double)
        bint isDegenerate()
        Point pointAt(Coord)
        Coord valueAt(Coord, Dim2)
        Coord timeAt(Point &)
        Coord timeAtProjection(Point &)
        Coord nearestTime(Point &)
        vector[Coord] roots(Coord, Dim2)
        Line reverse()
        Curve* portion(Coord, Coord)
        LineSegment segment(Coord, Coord)
        Ray ray(Coord)
        Line derivative()
        Line transformed(Affine &)
        Point normal()
        Point normalAndDist(double &)

    double distance(Point &, Line &)
    bint are_near(Point &, Line &, double)
    bint are_parallel(Line &, Line &, double)
    bint are_same(Line &, Line &, double)
    bint are_orthogonal(Line &, Line &, double)
    bint are_collinear(Point &, Point &, Point &, double)

    double angle_between(Line &, Line &)
    double distance(Point &, LineSegment &)

cdef extern from "2geom/line.h" namespace "Geom::Line":
    Line from_origin_and_versor(Point, Point)
    Line from_normal_distance(Point, double)


cdef extern from "2geom/ray.h" namespace "Geom":
    cdef cppclass Ray:
        Ray()
        Ray(Point &, Coord)
        Ray(Point&, Point &)
        Point origin()
        Point versor()
        void setOrigin(Point &)
        void setVersor(Point &)
        void setAngle(Coord)
        Coord angle()
        void setPoints(Point &, Point &)
        bint isDegenerate()
        Point pointAt(Coord)
        Coord valueAt(Coord, Dim2)
        vector[Coord] roots(Coord, Dim2)
        Coord nearestTime(Point &)
        Ray reverse()
        Curve *portion(Coord, Coord)
        LineSegment segment(Coord, Coord)
        Ray transformed(Affine &)
    double distance(Point &, Ray &)
    bint are_near(Point &, Ray &, double)
    bint are_same(Ray&, Ray &, double)
    double angle_between(Ray &, Ray &, bint)
    Ray make_angle_bisector_ray(Ray &, Ray&)