4 x 4 Matrix manipulation functions... More...
#include "common.h"
#include <math.h>
#include <string.h>
#include "bio.h"
#include "bu.h"
#include "vmath.h"
#include "bn.h"
Go to the source code of this file.
Functions | |
void | bn_mat_print_guts (const char *title, const mat_t m, char *obuf, int len) |
void | bn_mat_print (const char *title, const mat_t m) |
void | bn_mat_print_vls (const char *title, const mat_t m, struct bu_vls *vls) |
double | bn_atan2 (double y, double x) |
void | bn_mat_mul (register mat_t o, register const mat_t a, register const mat_t b) |
void | bn_mat_mul2 (register const mat_t i, register 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 ao, const mat_t a, const mat_t b, const mat_t c, const mat_t d) |
void | bn_matXvec (register vect_t ov, register const mat_t im, register const vect_t iv) |
void | bn_mat_inv (register mat_t output, const mat_t input) |
int | bn_mat_inverse (register mat_t output, const mat_t input) |
void | bn_vtoh_move (register vect_t h, register const vect_t v) |
void | bn_htov_move (register vect_t v, register const vect_t h) |
void | bn_mat_trn (mat_t om, register const mat_t im) |
void | bn_mat_ae (register fastf_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, fastf_t *vec_ae, fastf_t *vec_twist, fastf_t accuracy) |
void | bn_vec_ae (vect_t vect, fastf_t az, fastf_t el) |
void | bn_vec_aed (vect_t vect, fastf_t az, fastf_t el, fastf_t distance) |
void | bn_mat_angles (register fastf_t *mat, double alpha_in, double beta_in, double ggamma_in) |
void | bn_mat_angles_rad (register mat_t mat, double alpha, double beta, double ggamma) |
void | bn_eigen2x2 (fastf_t *val1, fastf_t *val2, fastf_t *vec1, fastf_t *vec2, fastf_t a, fastf_t b, fastf_t c) |
void | bn_vec_perp (vect_t new, const vect_t old) |
void | bn_mat_fromto (mat_t m, const vect_t from, const vect_t to) |
void | bn_mat_xrot (fastf_t *m, double sinx, double cosx) |
void | bn_mat_yrot (fastf_t *m, double siny, double cosy) |
void | bn_mat_zrot (fastf_t *m, double sinz, double cosz) |
void | bn_mat_lookat (mat_t rot, const vect_t dir, int yflip) |
void | bn_vec_ortho (register vect_t out, register const vect_t in) |
int | bn_mat_scale_about_pt (mat_t mat, const point_t pt, const double scale) |
void | bn_mat_xform_about_pt (mat_t mat, const mat_t xform, const point_t pt) |
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) |
Variables | |
const mat_t | bn_mat_identity = MAT_INIT_IDN |
4 x 4 Matrix manipulation functions...
Matrix array elements have the following positions in the matrix:
| 0 1 2 3 | | 0 | [ 0 1 2 3 ] | 4 5 6 7 | | 1 | | 8 9 10 11 | | 2 | | 12 13 14 15 | | 3 | preVector (vect_t) Matrix (mat_t) postVector (vect_t)
TODO: need a better way to control tolerancing, either via additional tolerance parameters or perhaps providing a global tolerance state interface.
Definition in file mat.c.
B N _ M A T _ M U L 2
o = i * o
A convenience wrapper for bn_mat_mul() to update a matrix in place. The argument ordering is confusing either way.
Definition at line 179 of file mat.c.
References bn_mat_mul(), and MAT_COPY.
B N _ M A T X V E C
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.
B N _ M A T _ I N V
The matrix pointed at by "input" is inverted and stored in the area pointed at by "output".
Calls bu_bomb if matrix is singular.
Definition at line 258 of file mat.c.
References bn_mat_inverse(), and bn_mat_print().
B N _ M A T _ I N V E R S E
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 alogorithm Note: Inversion is done in place, with 3 work vectors
void bn_mat_ae | ( | register fastf_t * | m, | |
double | azimuth, | |||
double | elev | |||
) |
B N _ M A T _ A E
Compute a 4x4 rotation matrix given Azimuth and Elevation.
Azimuth is +X, Elevation is +Z, both in degrees.
Formula due to Doug Gwyn, BRL.
Definition at line 431 of file mat.c.
References bn_degtorad.
void bn_aet_vec | ( | fastf_t * | az, | |
fastf_t * | el, | |||
fastf_t * | twist, | |||
fastf_t * | vec_ae, | |||
fastf_t * | vec_twist, | |||
fastf_t | accuracy | |||
) |
B N _ A E T _ V E C
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 stabilze flutter between equivalent extremes of atan2(), and to snap twist to zero when elevation is near +/- 90
Definition at line 496 of file mat.c.
References bn_ae_vec(), bn_atan2(), bn_radtodeg, NEAR_EQUAL, NEAR_ZERO, VCROSS, VDOT, VSET, VUNITIZE, X, and Y.
void bn_mat_angles | ( | register fastf_t * | mat, | |
double | alpha_in, | |||
double | beta_in, | |||
double | ggamma_in | |||
) |
B N _ M A T _ A N G L E S
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
Definition at line 577 of file mat.c.
References bn_degtorad, MAT_IDN, NEAR_ZERO, and ZERO.
void bn_mat_angles_rad | ( | register mat_t | mat, | |
double | alpha, | |||
double | beta, | |||
double | ggamma | |||
) |
B N _ M A T _ A N G L E S _ R A D
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, | |||
fastf_t * | vec1, | |||
fastf_t * | vec2, | |||
fastf_t | a, | |||
fastf_t | b, | |||
fastf_t | c | |||
) |
void bn_mat_xrot | ( | fastf_t * | m, | |
double | sinx, | |||
double | cosx | |||
) |
void bn_mat_yrot | ( | fastf_t * | m, | |
double | siny, | |||
double | cosy | |||
) |
void bn_mat_zrot | ( | fastf_t * | m, | |
double | sinz, | |||
double | cosz | |||
) |
B N _ V E C _ O R T H O
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
Definition at line 1030 of file mat.c.
References MAGSQ, NEAR_ZERO, UNLIKELY, V3ARGS, VSETALL, X, Y, Z, and ZERO.