#include "common.h"
#include <stdio.h>
#include <math.h>
#include <strings.h>
#include "machine.h"
#include "bu.h"
#include "vmath.h"
#include "bn.h"
Include dependency graph for mat.c:
Go to the source code of this file.
Functions | |
void | bn_mat_print_guts (const char *title, const mat_t m, char *obuf) |
void | bn_mat_print (const char *title, const mat_t m) |
double | bn_atan2 (double y, double x) |
A wrapper for the system atan2(). On the Silicon Graphics, and perhaps on others, x==0 incorrectly returns infinity. | |
void | bn_mat_mul (register mat_t o, register const mat_t a, register const mat_t b) |
Multiply matrix "a" by "b" and store the result in "o". NOTE: This is different from multiplying "b" by "a" (most of the time!) NOTE: "o" must not be the same as either of the inputs. | |
void | bn_mat_mul2 (register const mat_t i, register mat_t o) |
A convenience wrapper for bn_mat_mul() to update a matrix in place. The arugment ordering is confusing either way. | |
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) |
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. | |
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_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) |
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. | |
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) |
This routine builds a Homogeneous rotation matrix, given alpha, beta, and gamma as angles of rotation, in radians. | |
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) |
Given a vector, create another vector which is perpendicular to it. The output vector will have unit length only if the input vector did. | |
void | bn_mat_fromto (mat_t m, const vect_t from, const vect_t to) |
Given two vectors, compute a rotation matrix that will transform space by the angle between the two. There are many candidate matricies. | |
void | bn_mat_xrot (fastf_t *m, double sinx, double cosx) |
void | bn_mat_yrot (fastf_t *m, double siny, double cosy) |
Given the sin and cos of a Y rotation angle, produce the rotation matrix. | |
void | bn_mat_zrot (fastf_t *m, double sinz, double cosz) |
Given the sin and cos of a Z rotation angle, produce the rotation matrix. | |
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) |
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. | |
int | bn_mat_scale_about_pt (mat_t mat, const point_t pt, const double scale) |
Build a matrix to scale uniformly around a given point. | |
void | bn_mat_xform_about_pt (mat_t mat, const mat_t xform, const point_t pt) |
Build a matrix to apply arbitary 4x4 transformation around a given point. | |
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) |
Construct a transformation matrix for rotation about an arbitrary axis. | |
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) |
Variables | |
const mat_t | bn_mat_identity |
| 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)
Michael John Muuss
Lee A. Butler
Definition in file mat.c.
|
Definition at line 105 of file mat.c. Referenced by bn_mat_print(), and bn_tcl_mat_print(). |
|
B N _ M A T _ P R I N T Definition at line 136 of file mat.c. References bn_mat_print_guts(), and bu_log(). Referenced by bn_mat_ck(), bn_mat_inv(), db_do_anim(), db_shader_mat(), nmg_flatten_face(), rt_dsp_shot(), rt_ehy_print(), rt_ell_print(), rt_epa_print(), rt_eto_print(), rt_part_print(), rt_rec_print(), rt_rhc_print(), rt_rpc_print(), rt_sph_print(), rt_submodel_import(), rt_submodel_import5(), rt_submodel_print(), rt_tgc_print(), and rt_tor_print(). Here is the call graph for this function: ![]() |
|
A wrapper for the system atan2(). On the Silicon Graphics, and perhaps on others, x==0 incorrectly returns infinity. B N _ A T A N 2 Definition at line 152 of file mat.c. Referenced by bn_ae_vec(), bn_aet_vec(), rt_ell_uv(), rt_part_uv(), and rt_sph_uv(). |
|
|
A convenience wrapper for bn_mat_mul() to update a matrix in place. The arugment ordering is confusing either way. B N _ M A T _ M U L 2 o = i * o Definition at line 260 of file mat.c. References bn_mat_mul(), and MAT_COPY. Referenced by bn_mat_arb_rot(), vo_mat_aet(), and vo_rot(). Here is the call graph for this function: ![]() |
|
B N _ M A T _ M U L 3 o = a * b * c The output matrix may be the same as 'b' or 'c', but may not be 'a'. Definition at line 276 of file mat.c. References bn_mat_mul(). Here is the call graph for this function: ![]() |
|
B N _ M A T _ M U L 4 o = a * b * c * d The output matrix may be the same as any input matrix. Definition at line 292 of file mat.c. References bn_mat_mul(). Here is the call graph for this function: ![]() |
|
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 X V E C |
|
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 335 of file mat.c. References bn_mat_inverse(), bn_mat_print(), bu_bomb(), and bu_log(). Referenced by bn_math_cmd(), db_region_mat(), nmg_snurb_is_planar(), rt_dsp_import5(), rt_ebm_prep(), rt_ell_tess(), rt_ell_tnurb(), rt_eto_prep(), rt_extrude_prep(), rt_hf_to_dsp(), rt_part_tess(), rt_submodel_prep(), rt_tor_prep(), rt_vol_prep(), vo_mrotPoint_cmd(), vo_rot(), vo_update(), vo_viewDir_cmd(), wdb_ocenter_cmd(), wdb_orotate_cmd(), wdb_oscale_cmd(), and wdb_otranslate_cmd(). Here is the call graph for this function: ![]() |
|
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
Definition at line 361 of file mat.c. References FAST, LOCAL, and MAT_COPY. Referenced by bn_mat_inv(), and rt_bend_pipe_prep(). |
|
B N _ H T O V _ M O V E 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. Definition at line 466 of file mat.c. References bu_log(), SMALL_FASTF, W, X, Y, and Z. Here is the call graph for this function: ![]() |
|
B N _ M A T _ T R N Definition at line 491 of file mat.c. Referenced by bn_mat_fromto(), bn_math_cmd(), rt_ehy_plot(), rt_ehy_prep(), rt_ehy_tess(), rt_ell_prep(), rt_ell_tess(), rt_ell_tnurb(), rt_epa_plot(), rt_epa_prep(), rt_epa_tess(), rt_linear_pipe_prep(), rt_part_prep(), rt_part_tess(), rt_rec_prep(), rt_rhc_plot(), rt_rhc_prep(), rt_rhc_tess(), rt_rpc_plot(), rt_rpc_prep(), rt_rpc_tess(), and rt_superell_prep(). |
|
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 526 of file mat.c. References bn_degtorad, and LOCAL. |
|
B N _ A E _ V E C Find the azimuth and elevation angles that correspond to the direction (not including twist) given by a direction vector. Definition at line 565 of file mat.c. References bn_atan2(), bn_radtodeg, X, Y, and Z. Referenced by bn_aet_vec(), bn_math_cmd(), db_tree_describe(), db_tree_flatten_describe(), and vo_lookat_cmd(). Here is the call graph for this function: ![]() |
|
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. B N _ A E T _ V E C Definition at line 589 of file mat.c. References bn_ae_vec(), bn_atan2(), bn_radtodeg, NEAR_ZERO, VCROSS, VDOT, VSET, VUNITIZE, X, and Y. Here is the call graph for this function: ![]() |
|
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. Definition at line 637 of file mat.c. References bn_degtorad, LOCAL, and MAT_IDN. |
|
This routine builds a Homogeneous rotation matrix, given alpha, beta, and gamma as angles of rotation, in radians. B N _ M A T _ A N G L E S _ R A D 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. |
|
B N _ E I G E N 2 X 2 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. B N _ V E C _ P E R P Definition at line 805 of file mat.c. References LOCAL, VCROSS, VMOVE, VSETALL, X, Y, and Z. Referenced by bn_mat_fromto(), bn_math_cmd(), nmg_eu_2vecs_perp(), nmg_to_tgc(), rt_grp_plot(), rt_hlf_plot(), and rt_hlf_prep(). |
|
Given two vectors, compute a rotation matrix that will transform space by the angle between the two. There are many candidate matricies. B N _ M A T _ F R O M T O The input 'from' and 'to' vectors need not be unit length. MAT4X3VEC( to, m, from ) is the identity that is created. Definition at line 833 of file mat.c. References A, bn_mat_mul(), bn_mat_trn(), bn_vec_perp(), bu_log(), M, MAT4X3VEC, MAT_IDN, Q, R, V3ARGS, VCROSS, VDOT, VMOVE, VSET, VUNITIZE, X, Y, and Z. Referenced by bn_math_cmd(), nmg_flatten_face(), nmg_isect2d_prep(), rt_extrude_prep(), and rt_part_tess(). Here is the call graph for this function: ![]() |
|
B N _ M A T _ X R O T Given the sin and cos of an X rotation angle, produce the rotation matrix. |
|
Given the sin and cos of a Y rotation angle, produce the rotation matrix. B N _ M A T _ Y R O T |
|
Given the sin and cos of a Z rotation angle, produce the rotation matrix. B N _ M A T _ Z R O T |
|
B N _ M A T _ L O O K A T 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. 1) Rotate D about Z to match +X axis. Azimuth adjustment. 2) Rotate D about Y to match -Y axis. Elevation adjustment. 3) Rotate D about Z to make projection of X axis again point in the +X direction. Twist adjustment. 4) Optionally, flip sign on Y axis if original Z becomes inverted. This can be nice for static frames, but is astonishing when used in animation. Definition at line 1010 of file mat.c. References bn_mat_mul(), bn_mat_yrot(), bn_mat_zrot(), bu_log(), MAT4X3VEC, MAT_COPY, MAT_IDN, VPRINT, VSET, X, Y, and Z. Referenced by bn_math_cmd(). Here is the call graph for this function: ![]() |
|
|
Build a matrix to scale uniformly around a given point. B N _ M A T _ S C A L E _ A B O U T _ P T
Definition at line 1123 of file mat.c. References bn_mat_mul(), MAT_DELTAS_VEC, MAT_DELTAS_VEC_NEG, MAT_IDN, MAT_ZERO, NEAR_ZERO, and SMALL. Referenced by bn_mat_scale_about_pt_wrapper(), db_parse_1anim(), and wdb_oscale_cmd(). Here is the call graph for this function: ![]() |
|
Build a matrix to apply arbitary 4x4 transformation around a given point. B N _ M A T _ X F O R M _ A B O U T _ P T Definition at line 1152 of file mat.c. References bn_mat_mul(), MAT_DELTAS_VEC, MAT_DELTAS_VEC_NEG, and MAT_IDN. Referenced by bn_math_cmd(), vo_rot(), and wdb_orotate_cmd(). Here is the call graph for this function: ![]() |
|
B N _ M A T _ I S _ E Q U A L
Definition at line 1174 of file mat.c. References BN_CK_TOL, bn_tol::dist, NEAR_ZERO, and bn_tol::perp. Referenced by rt_find_identical_solid(), rt_gettree_leaf(), and shoot_and_plot(). |
|
B N _ M A T _ I S _ I D E N T I T Y This routine is intended for detecting identity matricies 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.
Definition at line 1234 of file mat.c. References bn_mat_identity. Referenced by db_tcl_tree_parse(), db_tree_counter(), rt_arbn_import5(), rt_comb_import5(), and rt_comb_v5_serialize(). |
|
Construct a transformation matrix for rotation about an arbitrary axis. B N _ M A T _ A R B _ R O T The axis is defined by a point (pt) and a unit direction vector (dir). The angle of rotation is "ang" Definition at line 1248 of file mat.c. References bn_mat_mul(), bn_mat_mul2(), MAT_IDN, MDX, MDY, MDZ, X, Y, and Z. Referenced by bn_math_cmd(), draw_pipe_bend(), tesselate_pipe_bend(), and vo_arot_cmd(). Here is the call graph for this function: ![]() |
|
B N _ M A T _ D U P Return a pointer to a copy of the matrix in dynamically allocated memory. Definition at line 1309 of file mat.c. References bcopy, and bu_malloc(). Referenced by db_dup_subtree(), db_tcl_tree_parse(), db_tree_mul_dbleaf(), and rt_comb_import5(). Here is the call graph for this function: ![]() |
|
B N _ M A T _ C K Check to ensure that a rotation matrix preserves axis perpendicularily. Note that not all matricies are rotation matricies.
Definition at line 1329 of file mat.c. References A, bn_mat_print(), bu_bomb(), bu_debug, BU_DEBUG_COREDUMP, BU_DEBUG_MATH, bu_log(), MAT4X3VEC, NEAR_ZERO, VDIVIDE_TOL, VDOT, and VMOVE. Referenced by db_recurse(), and db_tcl_tree_parse(). Here is the call graph for this function: ![]() |
|
B N _ M A T _ D E T 3 Calculates the determinant of the 3X3 "rotation" part of the passed matrix Definition at line 1378 of file mat.c. References FAST. |
|
B N _ M A T _ D E T E R M I N A N T Calculates the determinant of the 4X4 matrix Definition at line 1396 of file mat.c. Referenced by nmg_snurb_is_planar(). |
|
Definition at line 1427 of file mat.c. References MAGSQ. Referenced by rt_tor_import5(). |
|
Initial value: { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 } Definition at line 94 of file mat.c. Referenced by bn_mat_is_identity(), db_tree_describe(), db_tree_flatten_describe(), rt_comb_export4(), rt_db_external5_to_internal5(), rt_db_get_internal(), rt_extrude_import(), rt_extrude_import5(), rt_gettree_leaf(), shoot_and_plot(), wdb_nmg_simplify_cmd(), and wdb_shells_cmd(). |