YetAnotherCoupler 3.4.0
Loading...
Searching...
No Matches
intersection.c File Reference
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include "utils_core.h"
#include "geometry.h"
Include dependency graph for intersection.c:

Go to the source code of this file.

Enumerations

enum  {
  p_on_a = 1 , q_on_a = 2 , p_on_b = 4 , q_on_b = 8 ,
  circles_are_identical = 16
}
 
enum  {
  no_intersection = 0 , a_between_cd = 1 , b_between_cd = 2 , c_between_ab = 4 ,
  d_between_ab = 8
}
 

Functions

static int gcxgc (double const norm_vector_a[3], double const norm_vector_b[3], double p[3], double q[3])
 
static int loncxlatc (double const gc_norm_vector[3], double const z, double p[3], double q[3])
 
static int gcxlatc (double const gc_norm_vector[3], double const z, double p[3], double q[3])
 
static int loncxlonc (double const norm_vector_a[3], double const norm_vector_b[3], double p[3], double q[3])
 
static int pxgc (double const vec[3], double const norm_vector[3], double p[3], double q[3])
 
static int pxlatc (double const vec[3], double z, double p[3], double q[3])
 
static int pxp (double const vec_a[3], double const vec_b[3], double p[3], double q[3])
 
int yac_circle_intersect (struct yac_circle a, struct yac_circle b, double p[3], double q[3])
 
static int vector_is_between (double const a[], double const b[], double const p[], double sq_len_diff_ab)
 
static int vector_is_between_lat (double const a[], double const b[], double const p[])
 
static void compute_edge_middle_point_vec (enum yac_edge_type edge_type, double const a[3], double const b[3], double middle[3])
 
static int yac_identical_circles_vec (enum yac_edge_type edge_type, double const a[3], double const b[3], double const c[3], double const d[3], double p[3], double q[3], int intersection_type)
 
static int yac_identical_gcxgc_vec (double const a[3], double const b[3], double const c[3], double const d[3], double p[3], double q[3])
 
static int yac_check_pq_gcxgc (double const a[3], double const b[3], double const c[3], double const d[3], double const p[3], double const q[3])
 
static void compute_norm_vector (double const a[3], double const b[3], double norm_vector[3])
 
static int yac_gcxgc_vec (double const a[3], double const b[3], double const c[3], double const d[3], double p[3], double q[3])
 
static int yac_latcxlatc_vec (double const a[3], double const b[3], double const c[3], double const d[3], double p[3], double q[3])
 compute the intersection point two circles of latitude
 
static void compute_lon_norm_vector (double const a[3], double const b[3], double norm_vector[3])
 
static int yac_loncxlonc_vec (double const a[3], double const b[3], double const c[3], double const d[3], double p[3], double q[3])
 compute the intersection point two circles of longitude
 
static int yac_check_pq_gcxlatc (double const a[3], double const b[3], double const c[3], double const d[3], double const p[3], double const q[3])
 
static int yac_loncxlatc_vec (double const a[3], double const b[3], double const c[3], double const d[3], double p[3], double q[3])
 compute the intersection point of a meridian and a parallel
 
static int yac_gcxlatc_vec (double const a[3], double const b[3], double const c[3], double const d[3], double p[3], double q[3])
 compute the intersection of a great circle with the parallel
 
static int yac_pxp_vec (double const a[3], double const b[3], double p[3], double q[3])
 
static int yac_pxgc_vec (double const point[3], double const a[3], double const b[3], double p[3], double q[3])
 
static int yac_pxlat_vec (double const point[3], double const a[3], double const b[3], double p[3], double q[3])
 
static int adjust_ret_value (int ret_value)
 
int yac_intersect_vec (enum yac_edge_type edge_type_a, double const a[3], double const b[3], enum yac_edge_type edge_type_b, double const c[3], double const d[3], double p[3], double q[3])
 
int yac_point_on_edge (double p[3], double const a[3], double const b[3], enum yac_circle_type circle_type)
 

Variables

static double const tol = 1.0e-12
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
p_on_a 
q_on_a 
p_on_b 
q_on_b 
circles_are_identical 

Definition at line 15 of file intersection.c.

◆ anonymous enum

anonymous enum
Enumerator
no_intersection 
a_between_cd 
b_between_cd 
c_between_ab 
d_between_ab 

Definition at line 23 of file intersection.c.

Function Documentation

◆ adjust_ret_value()

static int adjust_ret_value ( int ret_value)
inlinestatic

Definition at line 780 of file intersection.c.

Here is the caller graph for this function:

◆ compute_edge_middle_point_vec()

static void compute_edge_middle_point_vec ( enum yac_edge_type edge_type,
double const a[3],
double const b[3],
double middle[3] )
static

Definition at line 374 of file intersection.c.

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

◆ compute_lon_norm_vector()

static void compute_lon_norm_vector ( double const a[3],
double const b[3],
double norm_vector[3] )
static

Definition at line 586 of file intersection.c.

Here is the caller graph for this function:

◆ compute_norm_vector()

static void compute_norm_vector ( double const a[3],
double const b[3],
double norm_vector[3] )
static

Definition at line 499 of file intersection.c.

Here is the caller graph for this function:

◆ gcxgc()

static int gcxgc ( double const norm_vector_a[3],
double const norm_vector_b[3],
double p[3],
double q[3] )
static

computes the intersection of two great circles

Parameters
[in]norm_vector_anorm vector of circle a
[in]norm_vector_bnorm vector of circle b
[out]pfirst intersection point
[out]qsecond intersection point
Returns
-1 if the two circles are identical; 2 otherwise

Definition at line 39 of file intersection.c.

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

◆ gcxlatc()

static int gcxlatc ( double const gc_norm_vector[3],
double const z,
double p[3],
double q[3] )
static

Definition at line 94 of file intersection.c.

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

◆ loncxlatc()

static int loncxlatc ( double const gc_norm_vector[3],
double const z,
double p[3],
double q[3] )
static

Definition at line 71 of file intersection.c.

Here is the caller graph for this function:

◆ loncxlonc()

static int loncxlonc ( double const norm_vector_a[3],
double const norm_vector_b[3],
double p[3],
double q[3] )
static

Definition at line 194 of file intersection.c.

Here is the caller graph for this function:

◆ pxgc()

static int pxgc ( double const vec[3],
double const norm_vector[3],
double p[3],
double q[3] )
static

Definition at line 222 of file intersection.c.

Here is the caller graph for this function:

◆ pxlatc()

static int pxlatc ( double const vec[3],
double z,
double p[3],
double q[3] )
static

Definition at line 244 of file intersection.c.

Here is the caller graph for this function:

◆ pxp()

static int pxp ( double const vec_a[3],
double const vec_b[3],
double p[3],
double q[3] )
static

Definition at line 256 of file intersection.c.

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

◆ vector_is_between()

static int vector_is_between ( double const a[],
double const b[],
double const p[],
double sq_len_diff_ab )
inlinestatic

determines whether vector p is between vectors a and b (it is assumed, that a, b, and p are in the same plane)

Definition at line 319 of file intersection.c.

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

◆ vector_is_between_lat()

static int vector_is_between_lat ( double const a[],
double const b[],
double const p[] )
static

Definition at line 336 of file intersection.c.

Here is the caller graph for this function:

◆ yac_check_pq_gcxgc()

static int yac_check_pq_gcxgc ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double const p[3],
double const q[3] )
static

Definition at line 485 of file intersection.c.

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

◆ yac_check_pq_gcxlatc()

static int yac_check_pq_gcxlatc ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double const p[3],
double const q[3] )
static

Definition at line 635 of file intersection.c.

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

◆ yac_circle_intersect()

int yac_circle_intersect ( struct yac_circle a,
struct yac_circle b,
double p[3],
double q[3] )

Definition at line 270 of file intersection.c.

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

◆ yac_gcxgc_vec()

static int yac_gcxgc_vec ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double p[3],
double q[3] )
static

computes the intersection points of two great circles
based on http://www.geoclub.de/viewtopic.php?f=54&t=29689

Parameters
[in]afirst point of edge a the is on a great circle
[in]bsecond point of edge a the is on a great circle
[in]cfirst point of edge b the is on a great circle
[in]dsecond point of edge b the is on a great circle
[out]pintersection point
[out]qintersection point
Returns
0 if the intersection points are neither on edge a or b
-1 if an error occurred
1st bit will be set if p is on edge a
2nd bit will be set if q is on edge a
3rd bit will be set if p is on edge b
4th bit will be set if q is on edge b 5th bit will be set if both great circles are identically
Remarks
both edges need to have length of at least yac_angle_tol

Definition at line 535 of file intersection.c.

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

◆ yac_gcxlatc_vec()

static int yac_gcxlatc_vec ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double p[3],
double q[3] )
static

compute the intersection of a great circle with the parallel

compute the intersection points of a great circle (defined by a and b) and a circle of latitude (defined by c and d) (both circles need to have a length of at least yac_angle_tol) if p and q are != NULL they contain the intersection points the return value is:

  • 0 if the intersection points are neither between (a and b) or (c and d)
  • -1 if the two circles do not intersect or an error occurred
  • 1st bit will be set if p is between a and b
  • 2nd bit will be set if q is between a and b
  • 3rd bit will be set if p is between c and d
  • 4th bit will be set if q is between c and d
  • 5th bit will be set if both circles are identically
    Remarks
    if -1 is returned neither p or q is set
    if the two circles only have one intersection point, p and q will be identically, but only the p bits will be set
    both edges need to have length of at least yac_angle_tol

Definition at line 708 of file intersection.c.

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

◆ yac_identical_circles_vec()

static int yac_identical_circles_vec ( enum yac_edge_type edge_type,
double const a[3],
double const b[3],
double const c[3],
double const d[3],
double p[3],
double q[3],
int intersection_type )
static

Definition at line 396 of file intersection.c.

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

◆ yac_identical_gcxgc_vec()

static int yac_identical_gcxgc_vec ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double p[3],
double q[3] )
static

Definition at line 468 of file intersection.c.

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

◆ yac_intersect_vec()

int yac_intersect_vec ( enum yac_edge_type edge_type_a,
double const a[3],
double const b[3],
enum yac_edge_type edge_type_b,
double const c[3],
double const d[3],
double p[3],
double q[3] )

computes the intersection points of two edges

Parameters
[in]edge_type_atype of edge a
[in]afirst point of edge a
[in]bsecond point of edge a
[in]edge_type_btype of edge b
[in]cfirst point of edge b
[in]dsecond point of edge b
[out]pfirst intersection point
[out]qsecond intersection point
Returns
0 if the intersection points are neither on edge a or b
-1 if the two circles do not intersect
1st bit will be set if p is on edge a
2nd bit will be set if q is on edge a
3rd bit will be set if p is on edge b
4th bit will be set if q is on edge b
5th bit will be set if both circles are identically
Remarks
if -1 is returned neither p or q is set
if the two circles only have one intersection point, p and q will be identically, but only the p bits will be set

Definition at line 786 of file intersection.c.

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

◆ yac_latcxlatc_vec()

static int yac_latcxlatc_vec ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double p[3],
double q[3] )
static

compute the intersection point two circles of latitude

compute the intersection points of two circle of latitude if p and q are != NULL they contain the intersection points the return value is:

  • 0 if the intersection points are neither between (a and b) or (c and d)
  • -1 if an error occurred
  • 1st bit will be set if p is between a and b
  • 2nd bit will be set if q is between a and b
  • 3rd bit will be set if p is between c and d
  • 4th bit will be set if q is between c and d
  • 5th bit will be set if both edges are on the same circle of latitude
    Remarks
    both edges need to have length of at least yac_angle_tol

Definition at line 570 of file intersection.c.

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

◆ yac_loncxlatc_vec()

static int yac_loncxlatc_vec ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double p[3],
double q[3] )
static

compute the intersection point of a meridian and a parallel

compute the intersection points of a circle of longitude (defined by a and b) and a circle of latitude (defined by c and d) if p and q are != NULL they contain the intersection points the return value is:

  • 0 if the intersection points are neither between (a and b) or (c and d)
  • -1 if an error occurred
  • 1st bit will be set if p is between a and b
  • 2nd bit will be set if q is between a and b
  • 3rd bit will be set if p is between c and d
  • 4th bit will be set if q is between c and d
    Remarks
    both edges need to have length of at least yac_angle_tol

Definition at line 666 of file intersection.c.

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

◆ yac_loncxlonc_vec()

static int yac_loncxlonc_vec ( double const a[3],
double const b[3],
double const c[3],
double const d[3],
double p[3],
double q[3] )
static

compute the intersection point two circles of longitude

compute the intersection points of two circle of longitude if p and q are != NULL they contain the intersection points the return value is:

  • 0 if the intersection points are neither between (a and b) or (c and d)
  • -1 if an error occurred
  • 1st bit will be set if p is between a and b
  • 2nd bit will be set if q is between a and b
  • 3rd bit will be set if p is between c and d
  • 4th bit will be set if q is between c and d
  • 5th bit will be set if both edges are on the same circle of longitude
    Remarks
    both edges need to have length of at least yac_angle_tol

Definition at line 616 of file intersection.c.

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

◆ yac_point_on_edge()

int yac_point_on_edge ( double p[3],
double const a[3],
double const b[3],
enum yac_circle_type circle_type )

Definition at line 883 of file intersection.c.

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

◆ yac_pxgc_vec()

static int yac_pxgc_vec ( double const point[3],
double const a[3],
double const b[3],
double p[3],
double q[3] )
static

Definition at line 739 of file intersection.c.

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

◆ yac_pxlat_vec()

static int yac_pxlat_vec ( double const point[3],
double const a[3],
double const b[3],
double p[3],
double q[3] )
static

Definition at line 763 of file intersection.c.

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

◆ yac_pxp_vec()

static int yac_pxp_vec ( double const a[3],
double const b[3],
double p[3],
double q[3] )
static

Definition at line 733 of file intersection.c.

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

Variable Documentation

◆ tol

double const tol = 1.0e-12
static

Definition at line 13 of file intersection.c.