PostGIS  2.2.8dev-r@@SVN_REVISION@@

## ◆ lw_arc_side()

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

Definition at line 164 of file lwalgorithm.c.

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

Referenced by ptarrayarc_contains_point_partial().

165 {
166  POINT2D C;
168  double side_Q, side_A2;
169  double d;
170
171  side_Q = lw_segment_side(A1, A3, Q);
172  radius_A = lw_arc_center(A1, A2, A3, &C);
173  side_A2 = lw_segment_side(A1, A3, A2);
174
175  /* Linear case */
176  if ( radius_A < 0 )
177  return side_Q;
178
179  d = distance2d_pt_pt(Q, &C);
180
181  /* Q is on the arc boundary */
182  if ( d == radius_A && side_Q == side_A2 )
183  {
184  return 0;
185  }
186
187  /* Q on A1-A3 line, so its on opposite side to A2 */
188  if ( side_Q == 0 )
189  {
190  return -1 * side_A2;
191  }
192
193  /*
194  * Q is inside the arc boundary, so it's not on the side we
195  * might think from examining only the end points
196  */
197  if ( d < radius_A && side_Q == side_A2 )
198  {
199  side_Q *= -1;
200  }
201
202  return side_Q;
203 }
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
Definition: measures.c:2302
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.
Definition: lwalgorithm.c:213
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
Definition: lwalgorithm.c:50
Here is the call graph for this function:
Here is the caller graph for this function: