YetAnotherCoupler 3.4.0
|
#include "config.h"
#include <math.h>
#include <float.h>
#include "basic_grid.h"
#include "grid_cell.h"
#include "utils_core.h"
Go to the source code of this file.
Data Structures | |
struct | sin_cos_angle |
struct | bounding_circle |
struct | yac_circle |
Macros | |
#define | YAC_RAD (0.01745329251994329576923690768489) |
#define | yac_angle_tol (1e-9) |
#define | yac_sq_angle_tol (1e-9 * 1e-9) |
#define | yac_cos_angle_tol (0.9999999999999999995) |
#define | yac_angle_low_tol (1e-11) |
#define | yac_cos_angle_low_tol (1.0) |
Enumerations | |
enum | yac_circle_type { GREAT_CIRCLE = YAC_GREAT_CIRCLE_EDGE , LAT_CIRCLE = YAC_LAT_CIRCLE_EDGE , LON_CIRCLE = YAC_LON_CIRCLE_EDGE , POINT } |
Functions | |
int | yac_point_in_cell (double point_coords[3], struct yac_grid_cell cell) |
int | yac_point_in_cell2 (double point_coords[3], struct yac_grid_cell cell, struct bounding_circle bnd_circle) |
static double | get_angle (double a_lon, double b_lon) |
static double | get_angle_deg (double a_lon, double b_lon) |
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]) |
void | yac_get_cell_bounding_circle (struct yac_grid_cell cell, struct bounding_circle *bnd_circle) |
void | yac_get_cell_circumscribe_circle_unstruct_triangle (double a[3], double b[3], double c[3], struct bounding_circle *bnd_circle) |
void | yac_get_cell_bounding_circle_unstruct_triangle (double a[3], double b[3], double c[3], struct bounding_circle *bnd_circle) |
void | yac_get_cell_circumscribe_circle_reg_quad (double a[3], double b[3], double c[3], struct bounding_circle *bnd_circle) |
void | yac_get_cell_bounding_circle_reg_quad (double a[3], double b[3], double c[3], struct bounding_circle *bnd_circle) |
int | yac_extents_overlap (struct bounding_circle *extent_a, struct bounding_circle *extent_b) |
static double | sq_len_diff_vec (double const a[3], double const b[3]) |
computes square of the lenght of the vector ab | |
static double | compute_sq_crd (struct sin_cos_angle angle) |
static int | yac_point_in_bounding_circle_vec (double point_vector[3], struct bounding_circle *bnd_circle) |
static void | LLtoXYZ (double lon, double lat, double p_out[]) |
static void | LLtoXYZ_deg (double lon, double lat, double p_out[]) |
static void | XYZtoLL (double const p_in[], double *lon, double *lat) |
static double | det2_kahan (double a, double b, double c, double d) |
static void | crossproduct_kahan (double const a[], double const b[], double cross[]) |
static void | crossproduct_d (const double a[], const double b[], double cross[]) |
static double | get_vector_angle (double const a[3], double const b[3]) |
static double | clamp_abs_one (double val) |
static struct sin_cos_angle | sin_cos_angle_new (double sin, double cos) |
static struct sin_cos_angle | get_vector_angle_2 (double const a[3], double const b[3]) |
static int | compare_angles (struct sin_cos_angle a, struct sin_cos_angle b) |
static double | sin_cos_angle_to_dble (struct sin_cos_angle angle) |
static struct sin_cos_angle | sum_angles_no_check (struct sin_cos_angle a, struct sin_cos_angle b) |
static int | sum_angles (struct sin_cos_angle a, struct sin_cos_angle b, struct sin_cos_angle *restrict sum) |
static struct sin_cos_angle | sub_angles_no_check (struct sin_cos_angle a, struct sin_cos_angle b) |
static int | sub_angles (struct sin_cos_angle a, struct sin_cos_angle b, struct sin_cos_angle *restrict sub) |
static double | compute_angle (struct sin_cos_angle angle) |
return angles in the range of [0;2PI[ | |
static struct sin_cos_angle | half_angle (struct sin_cos_angle angle) |
static struct sin_cos_angle | quarter_angle (struct sin_cos_angle angle) |
static int | points_are_identically (double const *a, double const *b) |
static int | compare_coords (double const *a, double const *b) |
static void | normalise_vector (double v[]) |
static void | rotate_vector2 (double axis[], struct sin_cos_angle angle, double v_in[], double v_out[]) |
static void | rotate_vector (double axis[], double angle, double v_in[], double v_out[]) |
void | yac_triangulate_cell (struct yac_grid_cell cell, size_t start_corner, struct yac_grid_cell *triangles) |
void | yac_triangulate_cell_indices (size_t const *corner_indices, size_t num_corners, size_t start_corner, size_t(*triangle_indices)[3]) |
void | yac_compute_bnd_triangle (double *vertices, size_t num_vertices, double triangle[][3], size_t num_tests) |
int | yac_circle_intersect (struct yac_circle a, struct yac_circle b, 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 const struct sin_cos_angle | SIN_COS_ZERO = {0.0, 1.0} |
static const struct sin_cos_angle | SIN_COS_TOL = {yac_angle_tol, yac_cos_angle_tol} |
static const struct sin_cos_angle | SIN_COS_LOW_TOL = {yac_angle_low_tol, yac_cos_angle_low_tol} |
static const struct sin_cos_angle | SIN_COS_M_PI_2 = {1.0, 0.0} |
static const struct sin_cos_angle | SIN_COS_M_PI = {0.0, -1.0} |
static const struct sin_cos_angle | SIN_COS_7_M_PI_4 = {-0.707106781186547524401, +0.707106781186547524401} |
#define yac_angle_low_tol (1e-11) |
Definition at line 37 of file geometry.h.
#define yac_angle_tol (1e-9) |
Definition at line 34 of file geometry.h.
#define yac_cos_angle_low_tol (1.0) |
Definition at line 38 of file geometry.h.
#define yac_cos_angle_tol (0.9999999999999999995) |
Definition at line 36 of file geometry.h.
#define YAC_RAD (0.01745329251994329576923690768489) |
Definition at line 30 of file geometry.h.
#define yac_sq_angle_tol (1e-9 * 1e-9) |
Definition at line 35 of file geometry.h.
enum yac_circle_type |
Enumerator | |
---|---|
GREAT_CIRCLE | |
LAT_CIRCLE | |
LON_CIRCLE | |
POINT |
Definition at line 72 of file geometry.h.
|
inlinestatic |
|
inlinestatic |
Definition at line 428 of file geometry.h.
|
inlinestatic |
compares two 3d coordinates (vectors need to have a length of 1.0)
[in] | a | coordinates of point a |
[in] | b | coordinates of point b |
Definition at line 662 of file geometry.h.
|
inlinestatic |
return angles in the range of [0;2PI[
Definition at line 572 of file geometry.h.
|
inlinestatic |
|
inlinestatic |
for small angles <= 1e-?8? the crossproduct is inaccurate
use crossproduct_kahan for these cases
Definition at line 347 of file geometry.h.
|
inlinestatic |
Definition at line 332 of file geometry.h.
|
inlinestatic |
|
inlinestatic |
computes the angle between two longitude coordinates (in rad)
takes into account that longitude have a period of 2 pi
[in] | a_lon | |
[in] | b_lon |
Definition at line 127 of file geometry.h.
|
inlinestatic |
computes the angle between two longitude coordinates (in deg)
takes into account that longitude have a period of 360
[in] | a_lon | |
[in] | b_lon |
Definition at line 143 of file geometry.h.
|
inlinestatic |
computes the great circle distance in rad for two points given in xyz coordinates taken from http://johnblackburne.blogspot.de/2012/05/angle-between-two-3d-vectors.html
[in] | a | point coordinates of point a |
[in] | b | point coordinates of point b |
Definition at line 364 of file geometry.h.
|
inlinestatic |
Definition at line 415 of file geometry.h.
|
inlinestatic |
computes angle / 2 The basic idea is to imagin angle being a vector v with (cos(x); sin(x)) and w being a vector with (1.0; 0.0). The normalised sum of v and w gives us v_h with (cos(x/2); sin(x/2)). For quadrants 2, 3, and 4 we have to apply some little tricks for higher accuracy.
Definition at line 600 of file geometry.h.
|
inlinestatic |
converts lon-lat coordinates into xyz ones
Further information: http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations
[in] | lon | longitude coordinates in radian |
[in] | lat | latitude coordinates in radian |
[out] | p_out | xyz coordinates |
Definition at line 287 of file geometry.h.
|
inlinestatic |
converts lon-lat coordinates into xyz ones
[in] | lon | longitude coordinates in deg |
[in] | lat | latitude coordinates in deg |
[out] | p_out | xyz coordinates |
Definition at line 304 of file geometry.h.
|
inlinestatic |
normalises a vector
Definition at line 689 of file geometry.h.
|
inlinestatic |
determines whether two given points are (nearly) identically
[in] | a | point coordinates of point a |
[in] | b | point coordinates of point b |
Definition at line 648 of file geometry.h.
|
inlinestatic |
computes angle / 4 I derived it based on half_angle
Definition at line 617 of file geometry.h.
|
inlinestatic |
rotate vector v_in around the given axis by a given angle
[in] | axis | axis around which v_in is to rotated |
[in] | angle | rotation angle |
[in] | v_in | vector to be rotated |
[out] | v_out | rotated vector |
Definition at line 732 of file geometry.h.
|
inlinestatic |
rotate vector v_in around the given axis by a given angle
[in] | axis | axis around which v_in is to rotated |
[in] | angle | rotation angle |
[in] | v_in | vector to be rotated |
[out] | v_out | rotated vector |
Definition at line 704 of file geometry.h.
|
inlinestatic |
Definition at line 405 of file geometry.h.
|
inlinestatic |
this routine converts a struct sin_cos_angle into a double, which allows to easily compare angles 0: 0 <= angle < PI/4 => ret = 0 * M_SQRT1_2 + sin(angle) 1: PI/4 <= angle < 3*PI/4 => ret = 2 * M_SQRT1_2 - cos(angle) 2: 3*PI/4 <= angle < 5*PI/4 => ret = 4 * M_SQRT1_2 - sin(angle) 3: 5*PI/4 <= angle < 7*PI/4 => ret = 6 * M_SQRT1_2 + cos(angle) 4: 7*PI/4 <= angle < 2*PI => ret = 8 * M_SQRT1_2 + sin(angle)
Definition at line 505 of file geometry.h.
|
inlinestatic |
computes square of the lenght of the vector ab
Definition at line 249 of file geometry.h.
|
inlinestatic |
computes (a-b), if (a-b) <= 0, the result is (a-b+2*PI) a and be have to be in the range [0;2*PI[
Definition at line 558 of file geometry.h.
|
inlinestatic |
computes (a-b), if (a-b) < 0, the result is (a-b+2*PI) a and be have to be in the range [0;2*PI[
Definition at line 548 of file geometry.h.
|
inlinestatic |
computes (a+b), if (a+b) >= 2*PI, the result is (a+b-2*PI) a and be have to be in the range [0;2*PI[
Definition at line 534 of file geometry.h.
|
inlinestatic |
computes (a+b), if (a+b) >= 2*PI, the result is (a+b-2*PI) a and be have to be in the range [0;2*PI[
Definition at line 524 of file geometry.h.
|
inlinestatic |
converts lon-lat coordinates into xyz ones
Further information: http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations
[in] | p_in | xyz coordinates |
[out] | lon | longitude coordinate in radian |
[out] | lat | latitude coordinate in radian |
Definition at line 318 of file geometry.h.
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.
void yac_compute_bnd_triangle | ( | double * | vertices, |
size_t | num_vertices, | ||
double | triangle[][3], | ||
size_t | num_tests ) |
computes a spherical triangle that contains all given vertices, the algorithm tries to minimise the size of the triangle
[in] | vertices | vertices that are supposed to be within the triangle |
[in] | num_vertices | number of vertices in vertices |
[out] | triangle | bounding triangle |
[in] | num_tests | with increasing number of tests computation time and chance of smaller bounding triangle increases |
Definition at line 99 of file bnd_triangle.c.
int yac_extents_overlap | ( | struct bounding_circle * | extent_a, |
struct bounding_circle * | extent_b ) |
checks whether two extents overlap
[in] | extent_a | bounding circle |
[in] | extent_b | bounding circle |
Definition at line 204 of file bnd_circle.c.
void yac_get_cell_bounding_circle | ( | struct yac_grid_cell | cell, |
struct bounding_circle * | bnd_circle ) |
gets the bounding circle for a grid cell
[in] | cell | grid cell (coordinates have to be in radian) |
[out] | bnd_circle | bounding circle of the grid cell |
Definition at line 160 of file bnd_circle.c.
void yac_get_cell_bounding_circle_reg_quad | ( | double | a[3], |
double | b[3], | ||
double | c[3], | ||
struct bounding_circle * | bnd_circle ) |
computes the smallest bounding circle for a triangle on the sphere
[in] | a | coordinates of first point (xyz) |
[in] | b | coordinates of second point (xyz) |
[in] | c | coordinates of thrid point (xyz) |
[out] | bnd_circle | bounding circle |
Definition at line 36 of file bnd_circle.c.
void yac_get_cell_bounding_circle_unstruct_triangle | ( | double | a[3], |
double | b[3], | ||
double | c[3], | ||
struct bounding_circle * | bnd_circle ) |
computes the smallest bounding circle for a triangle on the sphere
[in] | a | coordinates of first point (xyz) |
[in] | b | coordinates of second point (xyz) |
[in] | c | coordinates of thrid point (xyz) |
[out] | bnd_circle | bounding circle |
Definition at line 93 of file bnd_circle.c.
void yac_get_cell_circumscribe_circle_reg_quad | ( | double | a[3], |
double | b[3], | ||
double | c[3], | ||
struct bounding_circle * | bnd_circle ) |
computes the circumscribe circle for a quad on the sphere
[in] | a | coordinates of first point (xyz) |
[in] | b | coordinates of second point (xyz) |
[in] | c | coordinates of thrid point (xyz) |
[out] | bnd_circle | circumscribe circle |
Definition at line 27 of file bnd_circle.c.
void yac_get_cell_circumscribe_circle_unstruct_triangle | ( | double | a[3], |
double | b[3], | ||
double | c[3], | ||
struct bounding_circle * | bnd_circle ) |
computes the circumscribe circle for a triangle on the sphere
[in] | a | coordinates of first point (xyz) |
[in] | b | coordinates of second point (xyz) |
[in] | c | coordinates of thrid point (xyz) |
[out] | bnd_circle | circumscribe circle |
Definition at line 45 of file bnd_circle.c.
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
[in] | edge_type_a | type of edge a |
[in] | a | first point of edge a |
[in] | b | second point of edge a |
[in] | edge_type_b | type of edge b |
[in] | c | first point of edge b |
[in] | d | second point of edge b |
[out] | p | first intersection point |
[out] | q | second intersection point |
Definition at line 786 of file intersection.c.
|
inlinestatic |
checks whether a point is within a bounding circle
[in] | point_vector | point to be checked |
[in] | bnd_circle | bounding circle |
Definition at line 266 of file geometry.h.
int yac_point_in_cell | ( | double | point_coords[3], |
struct yac_grid_cell | cell ) |
checks whether a given point is within a given cell
[in] | point_coords | |
[in] | cell |
Definition at line 465 of file check_overlap.c.
int yac_point_in_cell2 | ( | double | point_coords[3], |
struct yac_grid_cell | cell, | ||
struct bounding_circle | bnd_circle ) |
checks whether a given point is within a given cell
[in] | point_coords | |
[in] | cell | |
[in] | bnd_circle |
Definition at line 474 of file check_overlap.c.
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.
void yac_triangulate_cell | ( | struct yac_grid_cell | cell, |
size_t | start_corner, | ||
struct yac_grid_cell * | triangles ) |
splits given cell into triangles
[in] | cell | cell to be triangulated |
[in] | start_corner | start algorithm at corner with this index (0 <= start_corner < n; with n being number of cell corners) |
[out] | triangles | triangles that are the result of the triangulation |
Definition at line 66 of file grid_cell.c.
void yac_triangulate_cell_indices | ( | size_t const * | corner_indices, |
size_t | num_corners, | ||
size_t | start_corner, | ||
size_t(*) | triangle_indices[3] ) |
splits given indices of a cell into triangles
[in] | corner_indices | cell corner indices to be triangulated |
[in] | num_corners | number of corners of the cell |
[in] | start_corner | start algorithm at corner with this index (0 <= start_corner < n; with n being number of cell corners) |
[out] | triangle_indices | triangle indices that are the result of the triangulation |
Definition at line 144 of file grid_cell.c.
|
static |
Definition at line 50 of file geometry.h.
|
static |
Definition at line 46 of file geometry.h.
|
static |
Definition at line 49 of file geometry.h.
|
static |
Definition at line 48 of file geometry.h.
|
static |
Definition at line 45 of file geometry.h.
|
static |
Definition at line 44 of file geometry.h.