![]() |
Tesseroids 1.0: User Manual and API Documentation |
Set of misc utilities and data structures. More...
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "constants.h"
#include "logger.h"
#include "utils.h"
Functions | |
void | split_tess (TESSEROID tess, TESSEROID *split) |
Split a tesseroid into 8. | |
double | tess_total_mass (TESSEROID *model, int size) |
Calculate the total mass of a tesseroid model. | |
double | tess_range_mass (TESSEROID *model, int size, double low_dens, double high_dens) |
Calculate the mass of a tesseroid model within a density range. | |
void | tess2prism (TESSEROID tess, PRISM *prism) |
Convert a tesseroid into a rectangular prism of equal volume (Wild-Pfeiffer, 2008). | |
void | tess2sphere (TESSEROID tess, SPHERE *sphere) |
Convert a tesseroid into a sphere of equal volume. | |
void | prism2sphere (PRISM prism, double lonc, double latc, double rc, SPHERE *sphere) |
Convert a rectangular prism into a sphere of equal volume. | |
double | tess_volume (TESSEROID tess) |
Calculate the volume of a tesseroid. | |
double | sphere_volume (SPHERE sphere) |
Calculate the volume of a sphere. | |
double | prism_volume (PRISM prism) |
Calculate the volume of a prism. | |
void | strstrip (char *str) |
Strip trailing spaces and newlines from the end of a string. | |
int | gets_tess (const char *str, TESSEROID *tess) |
Read a single tesseroid from a string. | |
TESSEROID * | read_tess_model (FILE *modelfile, int *size) |
Read tesseroids from an open file and store them in an array. | |
int | gets_prism (const char *str, PRISM *prism) |
Read a single rectangular prism from a string. | |
PRISM * | read_prism_model (FILE *modelfile, int *size) |
Read rectangular prisms from an open file and store them in an array. |
Set of misc utilities and data structures.
Defines the TESSEROID, SPHERE and PRISM structures.
int gets_prism | ( | const char * | str, | |
PRISM * | prism | |||
) |
int gets_tess | ( | const char * | str, | |
TESSEROID * | tess | |||
) |
Read a single tesseroid from a string.
str | string with the tesseroid parameters | |
tess | used to return the read tesseroid |
Convert a rectangular prism into a sphere of equal volume.
Parameters:
prism | prism to convert | |
lonc | longitude of the desired center of the sphere, in degrees | |
latc | latitude of the desired center of the sphere, in degrees | |
rc | radial coordinate of the desired center of the sphere, in SI units | |
sphere | sphere with equal volume of the prism (used to return) |
double prism_volume | ( | PRISM | prism | ) |
Calculate the volume of a prism.
prism | the prism whose volume will be calculated |
PRISM* read_prism_model | ( | FILE * | modelfile, | |
int * | size | |||
) |
Read rectangular prisms from an open file and store them in an array.
Allocates memory. Don't forget to free 'model'!
modelfile | open FILE for reading with the model | |
size | used to return the size of the model read |
TESSEROID* read_tess_model | ( | FILE * | modelfile, | |
int * | size | |||
) |
Read tesseroids from an open file and store them in an array.
Allocates memory. Don't forget to free 'model'!
modelfile | open FILE for reading with the tesseroid model | |
size | used to return the size of the model read |
double sphere_volume | ( | SPHERE | sphere | ) |
Calculate the volume of a sphere.
sphere | the sphere whose volume will be calculated |
Split a tesseroid into 8.
tess | tesseroid that will be split | |
split | array of 8 tesseroids with memory allocated. Used to return. |
void strstrip | ( | char * | str | ) |
Strip trailing spaces and newlines from the end of a string.
Done IN PLACE!
str | string to strip |
Convert a tesseroid into a rectangular prism of equal volume (Wild-Pfeiffer, 2008).
References
tess | tesseroid to convert | |
prism | prism with equal volume of the tesseroid (used to return) |
Convert a tesseroid into a sphere of equal volume.
Parameters:
tess | tesseroid to convert | |
sphere | sphere with equal volume of the tesseroid (used to return) |
double tess_range_mass | ( | TESSEROID * | model, | |
int | size, | |||
double | low_dens, | |||
double | high_dens | |||
) |
Calculate the mass of a tesseroid model within a density range.
Give all in SI units and degrees!
model | array of tesseroids | |
size | size of the model | |
low_dens | lower bound of the density range | |
high_dens | upper bound of the density range |
double tess_total_mass | ( | TESSEROID * | model, | |
int | size | |||
) |
Calculate the total mass of a tesseroid model.
Give all in SI units and degrees!
model | array of tesseroids | |
size | size of the model |
double tess_volume | ( | TESSEROID | tess | ) |
Calculate the volume of a tesseroid.
tess | the tesseroid whose volume will be calculated |