libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
|
Go to the source code of this file.
Data Structures | |
struct | geo_pos3_t |
struct | geo_pos2_t |
struct | geo_pos3_32_t |
struct | geo_pos2_32_t |
struct | vect3_t |
struct | vect3l_t |
struct | vect2_t |
struct | ellip_t |
struct | bezier_t |
struct | sph_xlate_t |
struct | fpp_t |
struct | lcc_t |
struct | mat4_t |
struct | mat3_t |
Macros | |
#define | RAD2DEG_RATIO (M_PI / 180.0) |
#define | DEG2RAD_RATIO (180.0 / M_PI) |
#define | DEG2RAD(d) ((d) * RAD2DEG_RATIO) |
#define | RAD2DEG(r) ((r) * DEG2RAD_RATIO) |
#define | GEO_POS2(lat, lon) ((geo_pos2_t){(lat), (lon)}) |
#define | GEO_POS3(lat, lon, elev) ((geo_pos3_t){(lat), (lon), (elev)}) |
#define | GEO_POS3_F32(lat, lon, elev) ((geo_pos3_f32_t){(lat), (lon), (elev)}) |
#define | GEO_POS2_F32(lat, lon) ((geo_pos2_f32_t){(lat), (lon)}) |
#define | TO_GEO3(geo3) ((geo_pos3_t){(geo3).lat, (geo3).lon, (geo3).elev}) |
#define | TO_GEO2(geo2) ((geo_pos2_t){(geo2).lat, (geo2).lon}) |
#define | TO_GEO3_32(geo3) ((geo_pos3_32_t){(geo3).lat, (geo3).lon, (geo3).elev}) |
#define | TO_GEO2_32(geo2) ((geo_pos3_32_t){(geo3).lat, (geo3).lon}) |
#define | VECT2(x, y) ((vect2_t){(x), (y)}) |
#define | VECT3(x, y, z) ((vect3_t){(x), (y), (z)}) |
#define | VECT3L(x, y, z) ((vect3l_t){(x), (y), (z)}) |
#define | VECT2_EQ(a, b) ((a).x == (b).x && (a).y == (b).y) |
#define | VECT3_EQ(a, b) ((a).x == (b).x && (a).y == (b).y && (a).z == (b).z) |
#define | VECT2_PARALLEL(a, b) (((a).y == 0 && (b).y == 0) || (((a).x / (a).y) == ((b).x / (b).y))) |
#define | ZERO_VECT2 ((vect2_t){0.0, 0.0}) |
#define | ZERO_VECT3 ((vect3_t){0.0, 0.0, 0.0}) |
#define | ZERO_VECT3L ((vect3l_t){0.0, 0.0, 0.0}) |
#define | NULL_VECT2 ((vect2_t){NAN, NAN}) |
#define | NULL_VECT3 ((vect3_t){NAN, NAN, NAN}) |
#define | NULL_VECT3L ((vect3l_t){NAN, NAN, NAN}) |
#define | NULL_GEO_POS3 ((geo_pos3_t){NAN, NAN, NAN}) |
#define | NULL_GEO_POS3_32 ((geo_pos3_32_t){NAN, NAN, NAN}) |
#define | NULL_GEO_POS2 ((geo_pos2_t){NAN, NAN}) |
#define | NULL_GEO_POS2_32 ((geo_pos2_32_t){NAN, NAN}) |
#define | IS_NULL_VECT(a) (isnan((a).x)) |
#define | IS_NULL_VECT2(a) (isnan((a).x) || isnan((a).y)) |
#define | IS_NULL_VECT3(a) (isnan((a).x) || isnan((a).y) || isnan((a).z)) |
#define | IS_FINITE_VECT2(a) (isfinite((a).x) && isfinite((a).y)) |
#define | IS_FINITE_VECT3(a) (isfinite((a).x) && isfinite((a).y) && isfinite((a).z)) |
#define | IS_NULL_GEO_POS(a) (isnan((a).lat)) |
#define | IS_NULL_GEO_POS2(a) (isnan((a).lat) || isnan((a).lon)) |
#define | IS_NULL_GEO_POS3(a) (isnan((a).lat) || isnan((a).lon) || isnan((a).elev)) |
#define | IS_ZERO_VECT2(a) ((a).x == 0.0 && (a).y == 0.0) |
#define | IS_ZERO_VECT3(a) ((a).x == 0.0 && (a).y == 0.0 && (a).z == 0.0) |
#define | VECT2_TO_VECT3(v, z) ((vect3_t){(v).x, (v).y, (z)}) |
#define | VECT3_TO_VECT2(v) ((vect2_t){(v).x, (v).y}) |
#define | VECT3L_TO_VECT3(v) ((vect3_t){(v).x, (v).y, (v).z}) |
#define | VECT3_TO_VECT3L(v) ((vect3l_t){(v).x, (v).y, (v).z}) |
#define | GEO2_TO_GEO3(v, a) ((geo_pos3_t){(v).lat, (v).lon, (a)}) |
#define | GEO3_TO_GEO2(v) ((geo_pos2_t){(v).lat, (v).lon}) |
#define | GEO3_FT2M(g) GEO_POS3((g).lat, (g).lon, FEET2MET((g).elev)) |
#define | GEO3_M2FT(g) GEO_POS3((g).lat, (g).lon, MET2FEET((g).elev)) |
#define | GEO3_EQ(p1, p2) |
#define | GEO2_EQ(p1, p2) ((p1).lat == (p2).lat && (p1).lon == (p2).lon) |
#define | EARTH_MSL 6371200 |
#define | PRINT_VECT2(v) printf(#v "(%f, %f)\n", v.x, v.y) |
#define | PRINT_VECT3(v) printf(#v "(%f, %f, %f)\n", v.x, v.y, v.z) |
#define | PRINT_VECT3L(v) printf(#v "(%Lf, %Lf, %Lf)\n", v.x, v.y, v.z) |
#define | PRINT_GEO2(p) printf(#p "(%f, %f)\n", p.lat, p.lon) |
#define | PRINT_GEO3(p) printf(#p "(%f, %f, %f)\n", p.lat, p.lon, p.elev) |
#define | MAT4(mat, col, row) ((mat)->_mat4_data[(col) * 4 + (row)]) |
#define | MAT3(mat, col, row) ((mat)->_mat3_data[(col) * 3 + (row)]) |
#define | MAT4_DATA(mat) ((mat)->_mat4_data) |
#define | MAT3_DATA(mat) ((mat)->_mat3_data) |
Variables | |
const ellip_t | wgs84 |
This file contains LOTS of utility functions and types to handle various geometric operations.
Definition in file geom.h.
#define DEG2RAD | ( | d | ) | ((d) * RAD2DEG_RATIO) |
#define DEG2RAD_RATIO (180.0 / M_PI) |
#define EARTH_MSL 6371200 |
#define GEO2_EQ | ( | p1, | |
p2 | |||
) | ((p1).lat == (p2).lat && (p1).lon == (p2).lon) |
#define GEO2_TO_GEO3 | ( | v, | |
a | |||
) | ((geo_pos3_t){(v).lat, (v).lon, (a)}) |
Extends a 2-space geo_pos2_t v
into a geo_pos3_t by appending the elevation coordinate a
.
#define GEO3_EQ | ( | p1, | |
p2 | |||
) |
#define GEO3_FT2M | ( | g | ) | GEO_POS3((g).lat, (g).lon, FEET2MET((g).elev)) |
Converts a geo_pos3_t using feet for elevation into meters.
#define GEO3_M2FT | ( | g | ) | GEO_POS3((g).lat, (g).lon, MET2FEET((g).elev)) |
Converts a geo_pos3_t using meters for elevation into feet.
#define GEO3_TO_GEO2 | ( | v | ) | ((geo_pos2_t){(v).lat, (v).lon}) |
#define GEO_POS2 | ( | lat, | |
lon | |||
) | ((geo_pos2_t){(lat), (lon)}) |
lat
and lon
. #define GEO_POS2_F32 | ( | lat, | |
lon | |||
) | ((geo_pos2_f32_t){(lat), (lon)}) |
lat
and lon
. #define GEO_POS3 | ( | lat, | |
lon, | |||
elev | |||
) | ((geo_pos3_t){(lat), (lon), (elev)}) |
lat
, lon
and elev
. #define GEO_POS3_F32 | ( | lat, | |
lon, | |||
elev | |||
) | ((geo_pos3_f32_t){(lat), (lon), (elev)}) |
lat
, lon
and elev
. #define IS_FINITE_VECT2 | ( | a | ) | (isfinite((a).x) && isfinite((a).y)) |
#define IS_FINITE_VECT3 | ( | a | ) | (isfinite((a).x) && isfinite((a).y) && isfinite((a).z)) |
#define IS_NULL_GEO_POS | ( | a | ) | (isnan((a).lat)) |
#define IS_NULL_GEO_POS2 | ( | a | ) | (isnan((a).lat) || isnan((a).lon)) |
#define IS_NULL_GEO_POS3 | ( | a | ) | (isnan((a).lat) || isnan((a).lon) || isnan((a).elev)) |
#define IS_NULL_VECT | ( | a | ) | (isnan((a).x)) |
#define IS_NULL_VECT2 | ( | a | ) | (isnan((a).x) || isnan((a).y)) |
#define IS_NULL_VECT3 | ( | a | ) | (isnan((a).x) || isnan((a).y) || isnan((a).z)) |
#define IS_ZERO_VECT2 | ( | a | ) | ((a).x == 0.0 && (a).y == 0.0) |
#define IS_ZERO_VECT3 | ( | a | ) | ((a).x == 0.0 && (a).y == 0.0 && (a).z == 0.0) |
#define MAT3 | ( | mat, | |
col, | |||
row | |||
) | ((mat)->_mat3_data[(col) * 3 + (row)]) |
#define MAT4 | ( | mat, | |
col, | |||
row | |||
) | ((mat)->_mat4_data[(col) * 4 + (row)]) |
#define NULL_GEO_POS2 ((geo_pos2_t){NAN, NAN}) |
NAN
. #define NULL_GEO_POS2_32 ((geo_pos2_32_t){NAN, NAN}) |
NAN
. #define NULL_GEO_POS3 ((geo_pos3_t){NAN, NAN, NAN}) |
NAN
. #define NULL_GEO_POS3_32 ((geo_pos3_32_t){NAN, NAN, NAN}) |
NAN
. #define NULL_VECT2 ((vect2_t){NAN, NAN}) |
#define NULL_VECT3 ((vect3_t){NAN, NAN, NAN}) |
#define NULL_VECT3L ((vect3l_t){NAN, NAN, NAN}) |
#define PRINT_GEO2 | ( | p | ) | printf(#p "(%f, %f)\n", p.lat, p.lon) |
#define PRINT_GEO3 | ( | p | ) | printf(#p "(%f, %f, %f)\n", p.lat, p.lon, p.elev) |
#define PRINT_VECT3 | ( | v | ) | printf(#v "(%f, %f, %f)\n", v.x, v.y, v.z) |
#define PRINT_VECT3L | ( | v | ) | printf(#v "(%Lf, %Lf, %Lf)\n", v.x, v.y, v.z) |
#define RAD2DEG | ( | r | ) | ((r) * DEG2RAD_RATIO) |
#define RAD2DEG_RATIO (M_PI / 180.0) |
#define TO_GEO2 | ( | geo2 | ) | ((geo_pos2_t){(geo2).lat, (geo2).lon}) |
Converts any object in geo2
with the fields lat
and lon
into a geo_pos2_t.
#define TO_GEO2_32 | ( | geo2 | ) | ((geo_pos3_32_t){(geo3).lat, (geo3).lon}) |
Same as TO_GEO2() but returns a geo_pos2_32_t instead.
#define TO_GEO3 | ( | geo3 | ) | ((geo_pos3_t){(geo3).lat, (geo3).lon, (geo3).elev}) |
Converts any object in geo3
with the fields lat
, lon
and elev
into a geo_pos3_t.
#define TO_GEO3_32 | ( | geo3 | ) | ((geo_pos3_32_t){(geo3).lat, (geo3).lon, (geo3).elev}) |
Same as TO_GEO3() but returns a geo_pos3_32_t instead.
#define VECT2 | ( | x, | |
y | |||
) | ((vect2_t){(x), (y)}) |
#define VECT2_EQ | ( | a, | |
b | |||
) | ((a).x == (b).x && (a).y == (b).y) |
#define VECT2_PARALLEL | ( | a, | |
b | |||
) | (((a).y == 0 && (b).y == 0) || (((a).x / (a).y) == ((b).x / (b).y))) |
#define VECT2_TO_VECT3 | ( | v, | |
z | |||
) | ((vect3_t){(v).x, (v).y, (z)}) |
#define VECT3 | ( | x, | |
y, | |||
z | |||
) | ((vect3_t){(x), (y), (z)}) |
#define VECT3_EQ | ( | a, | |
b | |||
) | ((a).x == (b).x && (a).y == (b).y && (a).z == (b).z) |
#define VECT3_TO_VECT2 | ( | v | ) | ((vect2_t){(v).x, (v).y}) |
#define VECT3_TO_VECT3L | ( | v | ) | ((vect3l_t){(v).x, (v).y, (v).z}) |
#define VECT3L | ( | x, | |
y, | |||
z | |||
) | ((vect3l_t){(x), (y), (z)}) |
#define VECT3L_TO_VECT3 | ( | v | ) | ((vect3_t){(v).x, (v).y, (v).z}) |
#define ZERO_VECT2 ((vect2_t){0.0, 0.0}) |
#define ZERO_VECT3 ((vect3_t){0.0, 0.0, 0.0}) |
#define ZERO_VECT3L ((vect3l_t){0.0, 0.0, 0.0}) |
bezier_t * bezier_alloc | ( | size_t | n_pts | ) |
void bezier_free | ( | bezier_t * | curve | ) |
Computes the intersection of two circles. The circles are centered at ‘ca’ and ‘cb’ and have radii ‘ra’ and ‘rb’ respectively. The ‘i’ argument must point to an array capable of holding at least two points, which will be filled with the intersection points. The function returns the number of intersections (and appropriate slots filled in ‘i’). Possible values are:
double dir2hdg | ( | vect2_t | dir | ) |
geo_pos3_t ecef2geo | ( | vect3_t | pos, |
const ellip_t * | ellip | ||
) |
Does the reverse transform of geo2ecef_mtr(), by translating ECEF coordinates into geographic coordinates on an ellipsoid.
pos | Input ECEF coordinates to be translated. |
ellip | Definition of the ellipsoid to which pos is to be translated. |
ellip
matching the position of ECEF coordinates pos
. Elevation is encoded as meters. geo_pos3_t ecef2sph | ( | vect3_t | v | ) |
geo_pos3_t ecmi2geo | ( | vect3_t | pos, |
double | delta_t, | ||
const ellip_t * | ellip | ||
) |
Converts ECmI coordinates into geographic coordinates.
pos | Input ECmI coordinates. |
delta_t | Delta-time (in seconds) from the ECmI reference time. |
ellip | Earth ellipsoid to use. You'll probably want &wgs84 in here. |
geo_pos3_t ecmi2sph | ( | vect3_t | pos, |
double | delta_t | ||
) |
ellip_t ellip_init | ( | double | semi_major, |
double | semi_minor, | ||
double | flattening | ||
) |
geo_pos2_t fpp2geo | ( | vect2_t | pos, |
const fpp_t * | fpp | ||
) |
Back-projects a point from a projection surface into spherical coordinate space. N.B. since projection loses some information about the original input point, back-projection is incomplete for projections where either:
This means back-projection is only uniquely possible possible for gnomonic, stereographic and other projections where the projection origin lies "inside" the projected sphere. In case back-projection is not unique, the point closer to the projection origin is returned.
VECT2(1, 1)
. fpp_t fpp_init | ( | geo_pos2_t | center, |
double | rot, | ||
double | dist, | ||
const ellip_t * | ellip, | ||
bool_t | allow_inv | ||
) |
Prepares a set of projection parameters for projections from a fixed origin along the projection axis onto a flat projection plane. The plane is centered at ‘center’ and is rotated ‘rot’ degrees relative to the sphere's native coordinate system. The projection plane touches the sphere at the center point and is parallel to its surface there. Points on the sphere are projected from a fixed origin along a projection axis that is perpendicular to the projection plane and passes through its center. The distance of this point along the projection axis from the projection plane is ‘dist’ with positive offsets increasing away from the sphere's center.
You can pass INFINITY for ‘dist’, in which case the projection origin will be centered at +INFINITY, constructing an orthographic projection. N.B. ATM there is no way to position the projection point at -INFINITY. If you wish to construct an inverted orthographic projection, simply flip the ‘x’ coordinate of the projected points. Also, it is illegal to pass dist == 0.0.
Sets a final output scaling vector for a flat plane projection previously created using one of the *fpp_init
functions. This scaling vector is used to simply multiply the X and Y coordinates of the project's output. In essence, it is no different than doing:
double gc_distance | ( | geo_pos2_t | start, |
geo_pos2_t | end | ||
) |
double gc_point_hdg | ( | geo_pos2_t | start, |
geo_pos2_t | end | ||
) |
Computes the great-circle point heading from start
to end
. The heading is calculated at the position of the first argument. In essence, it asks the question "what heading to I need to be facing
at `start` to move towards `end` along a great circle path." The underlying projection assumes a WGS-84 ellipsoid.
vect3_t geo2ecef_ft | ( | geo_pos3_t | pos, |
const ellip_t * | ellip | ||
) |
vect3_t geo2ecef_mtr | ( | geo_pos3_t | pos, |
const ellip_t * | ellip | ||
) |
Converts a series of geographic coordinates on an ellipsoid into Euclidian coordinates in the ECEF coordinate system.
pos | Geographic coordinates on the ellipsoid described in ellip . The elevation component of the coordinates is assumed to be in meters. |
ellip | Definition of the ellipsoid on which pos exists. |
pos
in the ECEF coordinate system. vect3_t geo2ecmi | ( | geo_pos3_t | pos, |
double | delta_t, | ||
const ellip_t * | ellip | ||
) |
Converts geographic coordinates into ECmI coordinates.
pos | Input geographic coordinates. |
delta_t | Delta-time (in seconds) from the ECmI reference time. |
ellip | Earth ellipsoid to use. You'll probably want &wgs84 in here. |
vect2_t geo2fpp | ( | geo_pos2_t | pos, |
const fpp_t * | fpp | ||
) |
Projects a point at ‘pos’ according to the projection ‘proj’ and returns a 2D vector to the projected point's location on the projection plane. If the specified point cannot be projected (because its projection falls outside of the projection plane), NULL_VECT2 is returned instead.
vect2_t geo2lcc | ( | geo_pos2_t | pos, |
const lcc_t * | lcc | ||
) |
geo_pos3_t geo2sph | ( | geo_pos3_t | pos, |
const ellip_t * | ellip | ||
) |
Converts between geographic coordinates on an ellipsoid into equivalent geographic coordinates on a perfect sphere.
pos | Geographic coordinates on the ellipsoid described in ellip . |
ellip | Definition of the ellipsoid on which pos exists. |
pos
expressed on a perfect sphere, as-if it was co-located with the ellipsoid. geo_pos2_t geo_displace | ( | const ellip_t * | ellip, |
geo_pos2_t | pos, | ||
double | truehdg, | ||
double | dist | ||
) |
Given a starting coordinate and displacement direction + distance, displaces the starting coordinates in the desired direction and distance along a great circle.
ellip | An optional ellipsoid pointer, describing the Earth ellipsoid to use. If NULL , then the projection uses a spherical Earth model. |
pos | The starting position of the displacement. |
truehdg | The direction of the displacement in degrees from true north. |
dist | The distance of the displacement in meters. |
truehdg
and for dist
meters. geo_pos2_t geo_displace_dir | ( | const ellip_t * | ellip, |
geo_pos2_t | pos, | ||
vect2_t | dir, | ||
double | dist | ||
) |
bool_t geo_pos2_from_str | ( | const char * | lat, |
const char * | lon, | ||
geo_pos2_t * | pos | ||
) |
Parses a series of strings for latitude and longitude and uses them to construct a geo_pos2_t, with checking for correctness.
lat | The latitude in fractional degrees (positive north). |
lon | The longitude in fractional degrees (positive east). |
pos | A mandatory return argument that will be filled the resulting geographic coordinates. |
B_TRUE
if the input coordinates were a valid latitude & longitude. If the input contained invalid data, returns B_FALSE
instead and you shouldn't use the returned pos
. bool_t geo_pos3_from_str | ( | const char * | lat, |
const char * | lon, | ||
const char * | elev, | ||
geo_pos3_t * | pos | ||
) |
Same as geo_pos2_from_str(), but includes an elevation argument and returns a geo_pos3_t.
fpp_t gnomo_fpp_init | ( | geo_pos2_t | center, |
double | rot, | ||
const ellip_t * | ellip, | ||
bool_t | allow_inv | ||
) |
vect2_t hdg2dir | ( | double | truehdg | ) |
bool_t is_on_arc | ( | double | angle_x, |
double | angle1, | ||
double | angle2, | ||
bool_t | cw | ||
) |
Determines whether an angle is part of an arc.
angle_x | Angle who's membership of the arc to examine (in degrees). |
angle1 | Start angle of the arc (in degrees). |
angle2 | End angle of the arc (in degrees). |
cw | Flag indicating whether the arc progresses clockwise or counter clockwise from angle1 to angle2. |
B_TRUE
if angle_x is on the arc, B_FALSE
if it is not. lcc_t lcc_init | ( | double | reflat, |
double | reflon, | ||
double | stdpar1, | ||
double | stdpar2 | ||
) |
Prepares a set of Lambert conformal conic projection parameters.
reflat | Reference latitude in degrees. |
reflon | Reference longitude in degrees. |
stdpar1 | First standard parallel in degrees. |
stdpar2 | Second standard parallel in degrees. |
void mat3_ident | ( | mat3_t * | mat | ) |
void mat4_ident | ( | mat4_t * | mat | ) |
fpp_t ortho_fpp_init | ( | geo_pos2_t | center, |
double | rot, | ||
const ellip_t * | ellip, | ||
bool_t | allow_inv | ||
) |
Checks if a point lies inside of a polygon.
pt | A vector pointing to the position of the point to examine. |
poly | An array of 2-space vectors specifying the points of the polygon. Must contain at least 3 points and must be terminated by a final NULL_VECT2 point. |
B_TRUE
if the point lies inside of poly
, B_FALSE
otherwise. double quad_bezier_func | ( | double | x, |
const bezier_t * | func | ||
) |
Calculates the value of a function defined by a set of quadratic bezier curve segments.
x | Function input value. |
func | The set of quadratic bezier curves defining the function. Please note that since this is a function, curve segments may not overlap. This is to guarantee that at any point x the function resolves to one value. |
x
. If the point is beyond the edges of the bezier curve segments describing the function, the y
value of the first or last curve point is returned, i.e. beyond the curve boundaries, the function is assumed to be flat. double * quad_bezier_func_inv | ( | double | y, |
const bezier_t * | func, | ||
size_t * | n_xs | ||
) |
Calculates the value of a function ‘g’ defined as the inverse of a function ‘f’ which is defined by a set of quadratic bezier curve segments:
IOW, this function is the inverse of quad_bezier_func(), i.e. it looks for an unknown ‘x’ input to quad_bezier_func() that produces a known ‘y’ output. Please note that the ‘func’ argument of quad_bezier_func need not be a bijective function definition, so quad_bezier_func_inv() can return multiple ‘x’ values that all map to the given ‘y’ value. As a special case, if the ‘func’ definition includes a constant portion (i.e. a potentially infinite number of ‘x’ values corresponds to a given ‘y’ value), quad_bezier_func_inv() returns NULL and sets n_xs
to SIZE_MAX. You should treat this case as "infinite solutions."
y | Output value of the function func for which to look for a suitable ‘x’ input value. |
func | The set of quadratic bezier curve defining the function with the same constraints as in quad_bezier_func. |
n_xs | Output parameter which will be filled with the number of ‘x’ input points returned. |
double rel_angle | ( | double | a1, |
double | a2 | ||
) |
vect3_t sph2ecef | ( | geo_pos3_t | pos | ) |
Converts surface coordinates on an Earth-sized sphere into 3-space coordinate vector in ECEF space. Please note that this considers the Earth to be a perfect sphere and hence cannot be used for very precise calculations. For more accurate conversions, use geo2ecef_mtr().
pos | The input position to convert. |
In 3-space, axes have their origins at the globe center point, are perpendicular to each other and are designated as follows:
vect3_t sph2ecmi | ( | geo_pos3_t | pos, |
double | delta_t | ||
) |
geo_pos2_t sph_xlate | ( | geo_pos2_t | pos, |
const sph_xlate_t * | xlate | ||
) |
sph_xlate_t sph_xlate_init | ( | geo_pos2_t | displac, |
double | rot, | ||
bool_t | inv | ||
) |
Prepares a set of geographical coordinate translation parameters.
displac | The relative latitude & longitude (in degrees) between the origins of the two respective coordinate systems. For example, a displacement of +10 degrees of latitude (north) and +20 degrees of longitude (east) will result in an input coordinate of +5,+5 translating into -5,-15 in the target system (assuming ‘rotation’ below is zero). Please note that these coordinates as well as all transformations are assumed to be in geocentric coordinates on the an EARTH_MSL radius spheroid. |
rot | The relative rotation of the axes of the target coordinate system to the source coordinate system in degrees counter-clockwise. For example, a rotation of +90 degrees and no translation applied to an input coordinate of +5 degrees of latitude (north) and +5 degrees of longitude (east) will translate into -5,+5. |
vect3_t sph_xlate_vect | ( | vect3_t | p, |
const sph_xlate_t * | xlate | ||
) |
fpp_t stereo_fpp_init | ( | geo_pos2_t | center, |
double | rot, | ||
const ellip_t * | ellip, | ||
bool_t | allow_inv | ||
) |
double vect2_abs | ( | vect2_t | a | ) |
unsigned vect2poly_isect_get | ( | vect2_t | a, |
vect2_t | oa, | ||
const vect2_t * | poly, | ||
vect2_t * | isects, | ||
unsigned | cap | ||
) |
Checks if a vector and a polygon intersect.
a | Direction & magnitude of first vector. |
oa | Vector pointing to the origin of the first vector. |
poly | An array of 2-space vectors specifying the points of the polygon. Must contain at least 3 points and must be terminated by a final NULL_VECT2 point. |
isects | An optional return array that will be populated with the intersection points. At most ‘cap’ elements will be written to the array. The return value is the total number of intersections. Can be NULL if you do not wish to receive the intersections. |
cap | Number of elements in ‘isects’ that can be populated with intersections. No more than ‘cap’ elements will be written to isects . |
unsigned vect2sph_isect | ( | vect3_t | v, |
vect3_t | o, | ||
vect3_t | c, | ||
double | r, | ||
bool_t | confined, | ||
vect3_t | i[2] | ||
) |
Determines whether and where a vector intersects the surface of a sphere. Returns the number of intersection points (zero, one or two).
v | Vector for which to determine the intersection. |
o | Vector pointing from the coordinate origin to the origin of vector v (i.e. displacement of ‘v’ from the origin). |
c | Displacement of sphere center point from the coordinate origin. |
r | Radius of sphere. |
confined | If B_TRUE, only intersects which lie between the vector's start & ending point (inclusive) are returned. Otherwise any intersect along an infinite linear extension of the vector is returned. |
i | If not NULL, this function stores vectors pointing to the intersection points from the coordinate origin in this array:
|
Calculates a 2D vector-to-vector intersection point and returns it.
a | First vector. |
oa | Vector to origin of first vector from the coordinate origin. |
b | Second vector. |
oa | Vector to origin of second vector from the coordinate origin. |
confined | If B_TRUE, only intersects which lie between the vectors' start & ending points (inclusive) are considered. Otherwise any intersect along an infinite linear extension of the vectors is returned. |
double vect3_abs | ( | vect3_t | a | ) |
Converts a vector from X-Plane local OpenGL coordinates to aircraft coordinates, given aircraft local roll, pitch and heading. This can also be used to convert from aircraft coordinates to the true reference frame, by using true_phi, true_theta and true_psi intead of their local equivalents.
Performs a simple per-component multiplication of two vectors.
long double vect3l_abs | ( | vect3l_t | a | ) |