PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lw_arc_side()

int lw_arc_side ( const POINT2D A1,
const POINT2D A2,
const POINT2D A3,
const POINT2D Q 
)

Definition at line 194 of file lwalgorithm.c.

195{
196 POINT2D C;
197 double radius_A;
198 double side_Q, side_A2;
199 double d;
200
201 side_Q = lw_segment_side(A1, A3, Q);
202 radius_A = lw_arc_center(A1, A2, A3, &C);
203 side_A2 = lw_segment_side(A1, A3, A2);
204
205 /* Linear case */
206 if ( radius_A < 0 )
207 return side_Q;
208
209 d = distance2d_pt_pt(Q, &C);
210
211 /* Q is on the arc boundary */
212 if ( d == radius_A && side_Q == side_A2 )
213 {
214 return 0;
215 }
216
217 /* Q on A1-A3 line, so its on opposite side to A2 */
218 if ( side_Q == 0 )
219 {
220 return -1 * side_A2;
221 }
222
223 /*
224 * Q is inside the arc boundary, so it's not on the side we
225 * might think from examining only the end points
226 */
227 if ( d < radius_A && side_Q == side_A2 )
228 {
229 side_Q *= -1;
230 }
231
232 return side_Q;
233}
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
Definition measures.c:2344
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
Definition lwalgorithm.c:70

References distance2d_pt_pt(), lw_arc_center(), and lw_segment_side().

Referenced by rect_leaf_node_segment_side().

Here is the call graph for this function:
Here is the caller graph for this function: