FV3 Bundle
mosaic_util.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "mosaic_util.h"
#include "constant.h"
Include dependency graph for mosaic_util.c:

Go to the source code of this file.

Macros

#define HPI   (0.5*M_PI)
 
#define TPI   (2.0*M_PI)
 
#define TOLORENCE   (1.e-6)
 
#define EPSLN8   (1.e-8)
 
#define EPSLN10   (1.e-10)
 
#define EPSLN15   (1.e-15)
 
#define EPSLN30   (1.e-30)
 
#define SQRT_   sqrtl
 
#define ABS_   fabs
 
#define MAXNODELIST   100
 

Functions

void set_reproduce_siena_true (void)
 
void set_reproduce_siena_true_ (void)
 
void error_handler (const char *msg)
 
int nearest_index (double value, const double *array, int ia)
 
void tokenize (const char *const string, const char *tokens, unsigned int varlen, unsigned int maxvar, char *pstring, unsigned int *const nstr)
 
double maxval_double (int size, const double *data)
 
double minval_double (int size, const double *data)
 
double avgval_double (int size, const double *data)
 
void latlon2xyz (int size, const double *lon, const double *lat, double *x, double *y, double *z)
 
void xyz2latlon (int np, const double *x, const double *y, const double *z, double *lon, double *lat)
 
double box_area (double ll_lon, double ll_lat, double ur_lon, double ur_lat)
 
double poly_area_dimensionless (const double x[], const double y[], int n)
 
double poly_area (const double x[], const double y[], int n)
 
double poly_area_no_adjust (const double x[], const double y[], int n)
 
int delete_vtx (double x[], double y[], int n, int n_del)
 
int insert_vtx (double x[], double y[], int n, int n_ins, double lon_in, double lat_in)
 
void v_print (double x[], double y[], int n)
 
int fix_lon (double x[], double y[], int n, double tlon)
 
double great_circle_distance (double *p1, double *p2)
 
double great_circle_area (int n, const double *x, const double *y, const double *z)
 
double spherical_angle (const double *v1, const double *v2, const double *v3)
 
double spherical_excess_area (const double *p_ll, const double *p_ul, const double *p_lr, const double *p_ur, double radius)
 
void vect_cross (const double *p1, const double *p2, double *e)
 
double dot (const double *p1, const double *p2)
 
double metric (const double *p)
 
void normalize_vect (double *e)
 
void unit_vect_latlon (int size, const double *lon, const double *lat, double *vlon, double *vlat)
 
int intersect_tri_with_line (const double *plane, const double *l1, const double *l2, double *p, double *t)
 
void mult (long double m[], long double v[], long double out_v[])
 
int invert_matrix_3x3 (long double m[], long double m_inv[])
 
void rewindList (void)
 
struct NodegetNext ()
 
void initNode (struct Node *node)
 
void addEnd (struct Node *list, double x, double y, double z, int intersect, double u, int inbound, int inside)
 
int addIntersect (struct Node *list, double x, double y, double z, int intersect, double u1, double u2, int inbound, int is1, int ie1, int is2, int ie2)
 
int length (struct Node *list)
 
int samePoint (double x1, double y1, double z1, double x2, double y2, double z2)
 
int sameNode (struct Node node1, struct Node node2)
 
void addNode (struct Node *list, struct Node inNode)
 
struct NodegetNode (struct Node *list, struct Node inNode)
 
struct NodegetNextNode (struct Node *list)
 
void copyNode (struct Node *node_out, struct Node node_in)
 
void printNode (struct Node *list, char *str)
 
int intersectInList (struct Node *list, double x, double y, double z)
 
void insertIntersect (struct Node *list, double x, double y, double z, double u1, double u2, int inbound, double x2, double y2, double z2)
 
double gridArea (struct Node *grid)
 
int isIntersect (struct Node node)
 
int getInbound (struct Node node)
 
struct NodegetLast (struct Node *list)
 
int getFirstInbound (struct Node *list, struct Node *nodeOut)
 
void getCoordinate (struct Node node, double *x, double *y, double *z)
 
void getCoordinates (struct Node *node, double *p)
 
void setCoordinate (struct Node *node, double x, double y, double z)
 
void setInbound (struct Node *interList, struct Node *list)
 
int isInside (struct Node *node)
 
int insidePolygon (struct Node *node, struct Node *list)
 
int inside_a_polygon (double *lon1, double *lat1, int *npts, double *lon2, double *lat2)
 
int inside_a_polygon_ (double *lon1, double *lat1, int *npts, double *lon2, double *lat2)
 

Variables

int reproduce_siena = 0
 
struct NodenodeList =NULL
 
int curListPos =0
 

Macro Definition Documentation

◆ ABS_

#define ABS_   fabs

◆ EPSLN10

#define EPSLN10   (1.e-10)

Definition at line 33 of file mosaic_util.c.

◆ EPSLN15

#define EPSLN15   (1.e-15)

Definition at line 34 of file mosaic_util.c.

◆ EPSLN30

#define EPSLN30   (1.e-30)

Definition at line 35 of file mosaic_util.c.

◆ EPSLN8

#define EPSLN8   (1.e-8)

Definition at line 32 of file mosaic_util.c.

◆ HPI

#define HPI   (0.5*M_PI)

Definition at line 29 of file mosaic_util.c.

◆ MAXNODELIST

#define MAXNODELIST   100

Definition at line 807 of file mosaic_util.c.

◆ SQRT_

#define SQRT_   sqrtl

◆ TOLORENCE

#define TOLORENCE   (1.e-6)

Definition at line 31 of file mosaic_util.c.

◆ TPI

#define TPI   (2.0*M_PI)

Definition at line 30 of file mosaic_util.c.

Function Documentation

◆ addEnd()

void addEnd ( struct Node list,
double  x,
double  y,
double  z,
int  intersect,
double  u,
int  inbound,
int  inside 
)

Definition at line 855 of file mosaic_util.c.

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

◆ addIntersect()

int addIntersect ( struct Node list,
double  x,
double  y,
double  z,
int  intersect,
double  u1,
double  u2,
int  inbound,
int  is1,
int  ie1,
int  is2,
int  ie2 
)

Definition at line 894 of file mosaic_util.c.

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

◆ addNode()

void addNode ( struct Node list,
struct Node  inNode 
)

Definition at line 987 of file mosaic_util.c.

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

◆ avgval_double()

double avgval_double ( int  size,
const double *  data 
)

Definition at line 193 of file mosaic_util.c.

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

◆ box_area()

double box_area ( double  ll_lon,
double  ll_lat,
double  ur_lon,
double  ur_lat 
)

Definition at line 258 of file mosaic_util.c.

◆ copyNode()

void copyNode ( struct Node node_out,
struct Node  node_in 
)

Definition at line 1017 of file mosaic_util.c.

Here is the caller graph for this function:

◆ delete_vtx()

int delete_vtx ( double  x[],
double  y[],
int  n,
int  n_del 
)

Definition at line 376 of file mosaic_util.c.

Here is the caller graph for this function:

◆ dot()

double dot ( const double *  p1,
const double *  p2 
)

Definition at line 663 of file mosaic_util.c.

Here is the caller graph for this function:

◆ error_handler()

void error_handler ( const char *  msg)

Definition at line 55 of file mosaic_util.c.

Here is the caller graph for this function:

◆ fix_lon()

int fix_lon ( double  x[],
double  y[],
int  n,
double  tlon 
)

Definition at line 409 of file mosaic_util.c.

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

◆ getCoordinate()

void getCoordinate ( struct Node  node,
double *  x,
double *  y,
double *  z 
)

Definition at line 1222 of file mosaic_util.c.

Here is the caller graph for this function:

◆ getCoordinates()

void getCoordinates ( struct Node node,
double *  p 
)

Definition at line 1232 of file mosaic_util.c.

Here is the caller graph for this function:

◆ getFirstInbound()

int getFirstInbound ( struct Node list,
struct Node nodeOut 
)

Definition at line 1205 of file mosaic_util.c.

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

◆ getInbound()

int getInbound ( struct Node  node)

Definition at line 1185 of file mosaic_util.c.

◆ getLast()

struct Node* getLast ( struct Node list)

Definition at line 1190 of file mosaic_util.c.

Here is the caller graph for this function:

◆ getNext()

struct Node* getNext ( )

Definition at line 823 of file mosaic_util.c.

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

◆ getNextNode()

struct Node* getNextNode ( struct Node list)

Definition at line 1012 of file mosaic_util.c.

Here is the caller graph for this function:

◆ getNode()

struct Node* getNode ( struct Node list,
struct Node  inNode 
)

Definition at line 994 of file mosaic_util.c.

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

◆ great_circle_area()

double great_circle_area ( int  n,
const double *  x,
const double *  y,
const double *  z 
)

Definition at line 504 of file mosaic_util.c.

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

◆ great_circle_distance()

double great_circle_distance ( double *  p1,
double *  p2 
)

Definition at line 488 of file mosaic_util.c.

Here is the caller graph for this function:

◆ gridArea()

double gridArea ( struct Node grid)

Definition at line 1156 of file mosaic_util.c.

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

◆ initNode()

void initNode ( struct Node node)

Definition at line 841 of file mosaic_util.c.

Here is the caller graph for this function:

◆ insert_vtx()

int insert_vtx ( double  x[],
double  y[],
int  n,
int  n_ins,
double  lon_in,
double  lat_in 
)

Definition at line 386 of file mosaic_util.c.

Here is the caller graph for this function:

◆ insertIntersect()

void insertIntersect ( struct Node list,
double  x,
double  y,
double  z,
double  u1,
double  u2,
int  inbound,
double  x2,
double  y2,
double  z2 
)

Definition at line 1074 of file mosaic_util.c.

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

◆ inside_a_polygon()

int inside_a_polygon ( double *  lon1,
double *  lat1,
int *  npts,
double *  lon2,
double *  lat2 
)

Definition at line 1357 of file mosaic_util.c.

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

◆ inside_a_polygon_()

int inside_a_polygon_ ( double *  lon1,
double *  lat1,
int *  npts,
double *  lon2,
double *  lat2 
)

Definition at line 1402 of file mosaic_util.c.

Here is the call graph for this function:

◆ insidePolygon()

int insidePolygon ( struct Node node,
struct Node list 
)

Definition at line 1306 of file mosaic_util.c.

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

◆ intersect_tri_with_line()

int intersect_tri_with_line ( const double *  plane,
const double *  l1,
const double *  l2,
double *  p,
double *  t 
)

Definition at line 727 of file mosaic_util.c.

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

◆ intersectInList()

int intersectInList ( struct Node list,
double  x,
double  y,
double  z 
)

Definition at line 1047 of file mosaic_util.c.

Here is the call graph for this function:

◆ invert_matrix_3x3()

int invert_matrix_3x3 ( long double  m[],
long double  m_inv[] 
)

Definition at line 778 of file mosaic_util.c.

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

◆ isInside()

int isInside ( struct Node node)

Definition at line 1296 of file mosaic_util.c.

Here is the call graph for this function:

◆ isIntersect()

int isIntersect ( struct Node  node)

Definition at line 1178 of file mosaic_util.c.

Here is the caller graph for this function:

◆ latlon2xyz()

void latlon2xyz ( int  size,
const double *  lon,
const double *  lat,
double *  x,
double *  y,
double *  z 
)

Definition at line 211 of file mosaic_util.c.

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

◆ length()

int length ( struct Node list)

Definition at line 951 of file mosaic_util.c.

Here is the caller graph for this function:

◆ maxval_double()

double maxval_double ( int  size,
const double *  data 
)

Definition at line 156 of file mosaic_util.c.

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

◆ metric()

double metric ( const double *  p)

Definition at line 671 of file mosaic_util.c.

Here is the caller graph for this function:

◆ minval_double()

double minval_double ( int  size,
const double *  data 
)

Definition at line 175 of file mosaic_util.c.

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

◆ mult()

void mult ( long double  m[],
long double  v[],
long double  out_v[] 
)

Definition at line 768 of file mosaic_util.c.

Here is the caller graph for this function:

◆ nearest_index()

int nearest_index ( double  value,
const double *  array,
int  ia 
)

Definition at line 80 of file mosaic_util.c.

Here is the call graph for this function:

◆ normalize_vect()

void normalize_vect ( double *  e)

Definition at line 679 of file mosaic_util.c.

Here is the caller graph for this function:

◆ poly_area()

double poly_area ( const double  x[],
const double  y[],
int  n 
)

Definition at line 314 of file mosaic_util.c.

Here is the caller graph for this function:

◆ poly_area_dimensionless()

double poly_area_dimensionless ( const double  x[],
const double  y[],
int  n 
)

Definition at line 277 of file mosaic_util.c.

Here is the caller graph for this function:

◆ poly_area_no_adjust()

double poly_area_no_adjust ( const double  x[],
const double  y[],
int  n 
)

Definition at line 351 of file mosaic_util.c.

Here is the caller graph for this function:

◆ printNode()

void printNode ( struct Node list,
char *  str 
)

Definition at line 1031 of file mosaic_util.c.

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

◆ rewindList()

void rewindList ( void  )

Definition at line 813 of file mosaic_util.c.

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

◆ sameNode()

int sameNode ( struct Node  node1,
struct Node  node2 
)

Definition at line 978 of file mosaic_util.c.

Here is the caller graph for this function:

◆ samePoint()

int samePoint ( double  x1,
double  y1,
double  z1,
double  x2,
double  y2,
double  z2 
)

Definition at line 968 of file mosaic_util.c.

Here is the caller graph for this function:

◆ set_reproduce_siena_true()

void set_reproduce_siena_true ( void  )

Definition at line 42 of file mosaic_util.c.

◆ set_reproduce_siena_true_()

void set_reproduce_siena_true_ ( void  )

Definition at line 48 of file mosaic_util.c.

◆ setCoordinate()

void setCoordinate ( struct Node node,
double  x,
double  y,
double  z 
)

Definition at line 1242 of file mosaic_util.c.

◆ setInbound()

void setInbound ( struct Node interList,
struct Node list 
)

Definition at line 1256 of file mosaic_util.c.

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

◆ spherical_angle()

double spherical_angle ( const double *  v1,
const double *  v2,
const double *  v3 
)

Definition at line 541 of file mosaic_util.c.

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

◆ spherical_excess_area()

double spherical_excess_area ( const double *  p_ll,
const double *  p_ul,
const double *  p_lr,
const double *  p_ur,
double  radius 
)

Definition at line 606 of file mosaic_util.c.

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

◆ tokenize()

void tokenize ( const char *const  string,
const char *  tokens,
unsigned int  varlen,
unsigned int  maxvar,
char *  pstring,
unsigned int *const  nstr 
)

Definition at line 112 of file mosaic_util.c.

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

◆ unit_vect_latlon()

void unit_vect_latlon ( int  size,
const double *  lon,
const double *  lat,
double *  vlon,
double *  vlat 
)

Definition at line 697 of file mosaic_util.c.

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

◆ v_print()

void v_print ( double  x[],
double  y[],
int  n 
)

Definition at line 400 of file mosaic_util.c.

Here is the caller graph for this function:

◆ vect_cross()

void vect_cross ( const double *  p1,
const double *  p2,
double *  e 
)

Definition at line 648 of file mosaic_util.c.

Here is the caller graph for this function:

◆ xyz2latlon()

void xyz2latlon ( int  np,
const double *  x,
const double *  y,
const double *  z,
double *  lon,
double *  lat 
)

Definition at line 227 of file mosaic_util.c.

Here is the caller graph for this function:

Variable Documentation

◆ curListPos

int curListPos =0

Definition at line 811 of file mosaic_util.c.

◆ nodeList

struct Node* nodeList =NULL

Definition at line 810 of file mosaic_util.c.

◆ reproduce_siena

int reproduce_siena = 0

Definition at line 40 of file mosaic_util.c.