BRL-CAD
|
Matrix and vector functionality. More...
Macros | |
#define | bn_mat_zero(_m) |
#define | bn_mat_idn(_m) |
#define | bn_mat_copy(_d, _s) |
Functions | |
void | bn_mat_print (const char *title, const mat_t m) |
void | bn_mat_print_guts (const char *title, const mat_t m, char *buf, int buflen) |
void | bn_mat_print_vls (const char *title, const mat_t m, struct bu_vls *vls) |
double | bn_atan2 (double x, double y) |
void | bn_mat_mul (mat_t o, const mat_t a, const mat_t b) |
void | bn_mat_mul2 (const mat_t i, mat_t o) |
void | bn_mat_mul3 (mat_t o, const mat_t a, const mat_t b, const mat_t c) |
void | bn_mat_mul4 (mat_t o, const mat_t a, const mat_t b, const mat_t c, const mat_t d) |
void | bn_matXvec (hvect_t ov, const mat_t im, const hvect_t iv) |
void | bn_mat_inv (mat_t output, const mat_t input) |
int | bn_mat_inverse (mat_t output, const mat_t input) |
void | bn_vtoh_move (hvect_t h, const vect_t v) |
void | bn_htov_move (vect_t v, const hvect_t h) |
void | bn_mat_trn (mat_t om, const mat_t im) |
void | bn_mat_ae (mat_t m, double azimuth, double elev) |
void | bn_ae_vec (fastf_t *azp, fastf_t *elp, const vect_t v) |
void | bn_aet_vec (fastf_t *az, fastf_t *el, fastf_t *twist, vect_t vec_ae, vect_t vec_twist, fastf_t accuracy) |
void | bn_vec_ae (vect_t vec, fastf_t az, fastf_t el) |
void | bn_vec_aed (vect_t vec, fastf_t az, fastf_t el, fastf_t dist) |
void | bn_mat_angles (mat_t mat, double alpha, double beta, double ggamma) |
void | bn_mat_angles_rad (mat_t mat, double alpha, double beta, double ggamma) |
void | bn_eigen2x2 (fastf_t *val1, fastf_t *val2, vect_t vec1, vect_t vec2, fastf_t a, fastf_t b, fastf_t c) |
void | bn_vec_perp (vect_t new_vec, const vect_t old_vec) |
void | bn_mat_fromto (mat_t m, const fastf_t *from, const fastf_t *to, const struct bn_tol *tol) |
void | bn_mat_xrot (mat_t m, double sinx, double cosx) |
void | bn_mat_yrot (mat_t m, double siny, double cosy) |
void | bn_mat_zrot (mat_t m, double sinz, double cosz) |
void | bn_mat_lookat (mat_t rot, const vect_t dir, int yflip) |
void | bn_vec_ortho (vect_t out, const vect_t in) |
int | bn_mat_scale_about_pnt (mat_t mat, const point_t pnt, const double scale) |
void | bn_mat_xform_about_pnt (mat_t mat, const mat_t xform, const point_t pnt) |
int | bn_mat_is_equal (const mat_t a, const mat_t b, const struct bn_tol *tol) |
int | bn_mat_is_identity (const mat_t m) |
void | bn_mat_arb_rot (mat_t m, const point_t pt, const vect_t dir, const fastf_t ang) |
matp_t | bn_mat_dup (const mat_t in) |
int | bn_mat_ck (const char *title, const mat_t m) |
fastf_t | bn_mat_det3 (const mat_t m) |
fastf_t | bn_mat_determinant (const mat_t m) |
int | bn_mat_is_non_unif (const mat_t m) |
void | bn_wrt_point_direc (mat_t out, const mat_t change, const mat_t in, const point_t point, const vect_t direc, const struct bn_tol *tol) |
void | persp_mat (mat_t m, fastf_t fovy, fastf_t aspect, fastf_t near1, fastf_t far1, fastf_t backoff) |
void | mike_persp_mat (fastf_t *pmat, const fastf_t *eye) |
void | deering_persp_mat (fastf_t *m, const fastf_t *l, const fastf_t *h, const fastf_t *eye) |
int | bn_opt_mat (struct bu_vls *msg, size_t argc, const char **argv, void *set_var) |
Variables | |
const mat_t | bn_mat_identity |
Matrix and vector functionality.
#define bn_mat_zero | ( | _m | ) |
#define bn_mat_idn | ( | _m | ) |
#define bn_mat_copy | ( | _d, | |
_s | |||
) |
void bn_mat_print | ( | const char * | title, |
const mat_t | m | ||
) |
void bn_mat_print_guts | ( | const char * | title, |
const mat_t | m, | ||
char * | buf, | ||
int | buflen | ||
) |
double bn_atan2 | ( | double | x, |
double | y | ||
) |
A wrapper for the system atan2(). On the Silicon Graphics, and perhaps on others, x==0 incorrectly returns infinity.
Multiply matrix "a" by "b" and store the result in "o".
This is different from multiplying "b" by "a" (most of the time!) Also, "o" must not be the same as either of the inputs.
o = i * o
A convenience wrapper for bn_mat_mul() to update a matrix in place. The argument ordering is confusing either way.
o = a * b * c
The output matrix may be the same as 'b' or 'c', but may not be 'a'.
o = a * b * c * d
The output matrix may be the same as any input matrix.
Multiply the matrix "im" by the vector "iv" and store the result in the vector "ov". Note this is post-multiply, and operates on 4-tuples. Use MAT4X3VEC() to operate on 3-tuples.
The matrix pointed at by "input" is inverted and stored in the area pointed at by "output".
Calls bu_bomb if matrix is singular.
The matrix pointed at by "input" is inverted and stored in the area pointed at by "output".
Invert a 4-by-4 matrix using Algorithm 120 from ACM. This is a modified Gauss-Jordan algorithm. Note: Inversion is done in place, with 3 work vectors.
Takes a pointer to a [x, y, z] vector, and a pointer to space for a homogeneous vector [x, y, z, w], and builds [x, y, z, 1].
Takes a pointer to [x, y, z, w], and converts it to an ordinary vector [x/w, y/w, z/w]. Optimization for the case of w==1 is performed.
FIXME: make tolerance configurable
void bn_mat_ae | ( | mat_t | m, |
double | azimuth, | ||
double | elev | ||
) |
Compute a 4x4 rotation matrix given Azimuth and Elevation.
Azimuth is +X, Elevation is +Z, both in degrees.
Formula due to Doug Gwyn, BRL.
Find the azimuth and elevation angles that correspond to the direction (not including twist) given by a direction vector.
void bn_aet_vec | ( | fastf_t * | az, |
fastf_t * | el, | ||
fastf_t * | twist, | ||
vect_t | vec_ae, | ||
vect_t | vec_twist, | ||
fastf_t | accuracy | ||
) |
Find the azimuth, elevation, and twist from two vectors. Vec_ae is in the direction of view (+z in mged view) and vec_twist points to the viewers right (+x in mged view). Accuracy (degrees) is used to stabilize flutter between equivalent extremes of atan2(), and to snap twist to zero when elevation is near +/- 90
Find a unit vector from the origin given azimuth and elevation.
Find a vector from the origin given azimuth, elevation, and distance.
void bn_mat_angles | ( | mat_t | mat, |
double | alpha, | ||
double | beta, | ||
double | ggamma | ||
) |
This routine builds a Homogeneous rotation matrix, given alpha, beta, and gamma as angles of rotation, in degrees.
Alpha is angle of rotation about the X axis, and is done third. Beta is angle of rotation about the Y axis, and is done second. Gamma is angle of rotation about Z axis, and is done first.
FIXME: make tolerance configurable
void bn_mat_angles_rad | ( | mat_t | mat, |
double | alpha, | ||
double | beta, | ||
double | ggamma | ||
) |
This routine builds a Homogeneous rotation matrix, given alpha, beta, and gamma as angles of rotation, in radians.
Alpha is angle of rotation about the X axis, and is done third. Beta is angle of rotation about the Y axis, and is done second. Gamma is angle of rotation about Z axis, and is done first.
FIXME: make tolerance configurable
void bn_eigen2x2 | ( | fastf_t * | val1, |
fastf_t * | val2, | ||
vect_t | vec1, | ||
vect_t | vec2, | ||
fastf_t | a, | ||
fastf_t | b, | ||
fastf_t | c | ||
) |
Find the eigenvalues and eigenvectors of a symmetric 2x2 matrix. (a b) (b c)
The eigenvalue with the smallest absolute value is returned in val1, with its eigenvector in vec1.
Given a vector, create another vector which is perpendicular to it. The output vector will have unit length only if the input vector did.
FIXME: make tolerance configurable
Given two vectors, compute a rotation matrix that will transform space by the angle between the two. There are many candidate matrices.
The input 'from' and 'to' vectors need not be unit length. MAT4X3VEC(to, m, from) is the identity that is created.
void bn_mat_xrot | ( | mat_t | m, |
double | sinx, | ||
double | cosx | ||
) |
Given the sin and cos of an X rotation angle, produce the rotation matrix.
void bn_mat_yrot | ( | mat_t | m, |
double | siny, | ||
double | cosy | ||
) |
Given the sin and cos of a Y rotation angle, produce the rotation matrix.
void bn_mat_zrot | ( | mat_t | m, |
double | sinz, | ||
double | cosz | ||
) |
Given the sin and cos of a Z rotation angle, produce the rotation matrix.
Given a direction vector D of unit length, product a matrix which rotates that vector D onto the -Z axis. This matrix will be suitable for use as a "model2view" matrix.
XXX This routine will fail if the vector is already more or less aligned with the Z axis.
This is done in several steps.
Given a vector, create another vector which is perpendicular to it, and with unit length. This algorithm taken from Gift's arvec.f; a faster algorithm may be possible.
FIXME: make tolerance configurable
Build a matrix to scale uniformly around a given point.
FIXME: make tolerance configurable
Build a matrix to apply arbitrary 4x4 transformation around a given point.
int bn_mat_is_identity | ( | const mat_t | m | ) |
This routine is intended for detecting identity matrices read in from ascii or binary files, where the numbers are pure ones or zeros. This routine is not intended for tolerance-based "near-zero" comparisons; as such, it shouldn't be used on matrices which are the result of calculation.
Construct a transformation matrix for rotation about an arbitrary axis. The axis is defined by a point (pt) and a unit direction vector (dir). The angle of rotation is "ang"
FIXME: make tolerance configurable
Return a pointer to a copy of the matrix in dynamically allocated memory.
int bn_mat_ck | ( | const char * | title, |
const mat_t | m | ||
) |
Check to ensure that a rotation matrix preserves axis perpendicularity. Note that not all matrices are rotation matrices.
Calculates the determinant of the 3X3 "rotation" part of the passed matrix.
int bn_mat_is_non_unif | ( | const mat_t | m | ) |
FIXME: make tolerance configurable
void bn_wrt_point_direc | ( | mat_t | out, |
const mat_t | change, | ||
const mat_t | in, | ||
const point_t | point, | ||
const vect_t | direc, | ||
const struct bn_tol * | tol | ||
) |
Given a model-space transformation matrix "change", return a matrix which applies the change with-respect-to given "point" and "direc".
void persp_mat | ( | mat_t | m, |
fastf_t | fovy, | ||
fastf_t | aspect, | ||
fastf_t | near1, | ||
fastf_t | far1, | ||
fastf_t | backoff | ||
) |
int bn_opt_mat | ( | struct bu_vls * | msg, |
size_t | argc, | ||
const char ** | argv, | ||
void * | set_var | ||
) |
|
extern |