Data Structures | |
struct | bn_complex |
Files | |
file | complex.c |
Defines | |
#define | bn_cx_copy(ap, bp) {*(ap) = *(bp);} |
#define | bn_cx_neg(cp) { (cp)->re = -((cp)->re);(cp)->im = -((cp)->im);} |
#define | bn_cx_real(cp) (cp)->re |
#define | bn_cx_imag(cp) (cp)->im |
#define | bn_cx_add(ap, bp) { (ap)->re += (bp)->re; (ap)->im += (bp)->im;} |
#define | bn_cx_ampl(cp) hypot((cp)->re, (cp)->im) |
#define | bn_cx_amplsq(cp) ((cp)->re * (cp)->re + (cp)->im * (cp)->im) |
#define | bn_cx_conj(cp) { (cp)->im = -(cp)->im; } |
#define | bn_cx_cons(cp, r, i) { (cp)->re = r; (cp)->im = i; } |
#define | bn_cx_phas(cp) atan2((cp)->im, (cp)->re) |
#define | bn_cx_scal(cp, s) { (cp)->re *= (s); (cp)->im *= (s); } |
#define | bn_cx_sub(ap, bp) { (ap)->re -= (bp)->re; (ap)->im -= (bp)->im;} |
#define | bn_cx_mul(ap, bp) |
#define | bn_cx_mul2(ap, bp, cp) |
#define | bn_mat_zero(_m) |
#define | bn_mat_idn(_m) |
#define | bn_mat_copy(_d, _s) |
Typedefs | |
typedef struct bn_complex | bn_complex_t |
Functions | |
void | bn_cx_div (bn_complex_t *ap, const bn_complex_t *bp) |
Divide one complex by another. | |
void | bn_cx_sqrt (bn_complex_t *op, const bn_complex_t *ip) |
Compute square root of complex number. | |
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 (vect_t h, const vect_t v) |
void | bn_htov_move (vect_t v, const vect_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 vect_t from, const vect_t to) |
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_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 |
#define bn_cx_neg | ( | cp | ) | { (cp)->re = -((cp)->re);(cp)->im = -((cp)->im);} |
#define bn_cx_add | ( | ap, | |||
bp | ) | { (ap)->re += (bp)->re; (ap)->im += (bp)->im;} |
#define bn_cx_ampl | ( | cp | ) | hypot((cp)->re, (cp)->im) |
Definition at line 469 of file bn.h.
Referenced by bn_cx_sqrt().
#define bn_cx_amplsq | ( | cp | ) | ((cp)->re * (cp)->re + (cp)->im * (cp)->im) |
#define bn_cx_cons | ( | cp, | |||
r, | |||||
i | ) | { (cp)->re = r; (cp)->im = i; } |
#define bn_cx_scal | ( | cp, | |||
s | ) | { (cp)->re *= (s); (cp)->im *= (s); } |
#define bn_cx_sub | ( | ap, | |||
bp | ) | { (ap)->re -= (bp)->re; (ap)->im -= (bp)->im;} |
#define bn_cx_mul | ( | ap, | |||
bp | ) |
#define bn_cx_mul2 | ( | ap, | |||
bp, | |||||
cp | ) |
#define bn_mat_zero | ( | _m | ) |
{ \
bu_log("%s:%d bn_mat_zero() is deprecated, use MAT_ZERO()\n", \
__FILE__, __LINE__); \
(_m)[0] = (_m)[1] = (_m)[2] = (_m)[3] = \
(_m)[4] = (_m)[5] = (_m)[6] = (_m)[7] = \
(_m)[8] = (_m)[9] = (_m)[10] = (_m)[11] = \
(_m)[12] = (_m)[13] = (_m)[14] = (_m)[15] = 0.0; }
#define bn_mat_idn | ( | _m | ) |
{ \
bu_log("%s:%d bn_mat_idn() is deprecated, use MAT_IDN()\n", \
__FILE__, __LINE__); \
(_m)[1] = (_m)[2] = (_m)[3] = (_m)[4] = \
(_m)[6] = (_m)[7] = (_m)[8] = (_m)[9] = \
(_m)[11] = (_m)[12] = (_m)[13] = (_m)[14] = 0.0; \
(_m)[0] = (_m)[5] = (_m)[10] = (_m)[15] = 1.0; }
#define bn_mat_copy | ( | _d, | |||
_s | ) |
{ \
bu_log("%s:%d bn_mat_copy() is deprecated, use MAT_COPY()\n", \
__FILE__, __LINE__); \
(_d)[0] = (_s)[0];\
(_d)[1] = (_s)[1];\
(_d)[2] = (_s)[2];\
(_d)[3] = (_s)[3];\
(_d)[4] = (_s)[4];\
(_d)[5] = (_s)[5];\
(_d)[6] = (_s)[6];\
(_d)[7] = (_s)[7];\
(_d)[8] = (_s)[8];\
(_d)[9] = (_s)[9];\
(_d)[10] = (_s)[10];\
(_d)[11] = (_s)[11];\
(_d)[12] = (_s)[12];\
(_d)[13] = (_s)[13];\
(_d)[14] = (_s)[14];\
(_d)[15] = (_s)[15]; }
typedef struct bn_complex bn_complex_t |
"complex number" data type:
void bn_cx_div | ( | bn_complex_t * | ap, | |
const bn_complex_t * | bp | |||
) |
Divide one complex by another.
B N _ C X _ D I V bn_cx_div(&a, &b). divides a by b. Zero divisor fails. a and b may coincide. Result stored in a.
void bn_cx_sqrt | ( | bn_complex_t * | op, | |
const bn_complex_t * | ip | |||
) |
Compute square root of complex number.
B N _ C X _ S Q R T bn_cx_sqrt(&out, &c) replaces out by sqrt(c)
Note: This is a double-valued function; the result of bn_cx_sqrt() always has nonnegative imaginary part.
Definition at line 69 of file complex.c.
References bn_cx_ampl, bn_complex::im, bn_complex::re, and ZERO.
void bn_mat_print | ( | const char * | title, | |
const mat_t | m | |||
) |
B N _ M A T _ P R I N T
Definition at line 91 of file mat.c.
References bn_mat_print_guts().
Referenced by bn_mat_ck(), and bn_mat_inv().
void bn_mat_print_guts | ( | const char * | title, | |
const mat_t | m, | |||
char * | buf, | |||
int | buflen | |||
) |
Definition at line 58 of file mat.c.
Referenced by bn_mat_print(), bn_mat_print_vls(), and bn_tcl_mat_print().
void bn_mat_print_vls | ( | const char * | title, | |
const mat_t | m, | |||
struct bu_vls * | vls | |||
) |
B N _ M A T _ P R I N T _ V L S
Definition at line 105 of file mat.c.
References bn_mat_print_guts().
double bn_atan2 | ( | double | y, | |
double | x | |||
) |
B N _ A T A N 2
A wrapper for the system atan2(). On the Silicon Graphics, and perhaps on others, x==0 incorrectly returns infinity.
Definition at line 123 of file mat.c.
References M_PI_2.
Referenced by bn_ae_vec(), and bn_aet_vec().
Referenced by bn_mat_arb_rot().
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 197 of file mat.c.
References bn_mat_mul().
Referenced by bn_wrt_point_direc().
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 214 of file mat.c.
References bn_mat_mul().
Referenced by bn_wrt_point_direc().
Referenced by bn_math_cmd().
Referenced by bn_isect_planes(), bn_math_cmd(), and bn_wrt_point_direc().
Referenced by bn_mat_inv().
Referenced by bn_mat_fromto(), and bn_math_cmd().
void bn_mat_ae | ( | mat_t | m, | |
double | azimuth, | |||
double | elev | |||
) |
Referenced by bn_math_cmd().
void bn_ae_vec | ( | fastf_t * | azp, | |
fastf_t * | elp, | |||
const vect_t | v | |||
) |
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 471 of file mat.c.
References bn_atan2(), bn_radtodeg, X, Y, and Z.
Referenced by bn_aet_vec(), and bn_math_cmd().
void bn_aet_vec | ( | fastf_t * | az, | |
fastf_t * | el, | |||
fastf_t * | twist, | |||
vect_t | vec_ae, | |||
vect_t | vec_twist, | |||
fastf_t | accuracy | |||
) |
Referenced by bn_math_cmd().
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 | ( | mat_t | mat, | |
double | alpha, | |||
double | beta, | |||
double | ggamma | |||
) |
Referenced by bn_math_cmd(), bn_vlist_2string(), PL_FORTRAN(), and tp_2symbol().
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 | |||
) |
Referenced by bn_math_cmd().
B N _ V E C _ P E R P
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
Definition at line 751 of file mat.c.
References VCROSS, VMOVE, VSETALL, X, Y, Z, and ZERO.
Referenced by bn_mat_fromto(), and bn_math_cmd().
B N _ M A T _ F R O M T O
Given two vectors, compute a rotation matrix that will transform space by the angle between the two. There are many candidate matricies.
The input 'from' and 'to' vectors need not be unit length. MAT4X3VEC(to, m, from) is the identity that is created.
FIXME: make tolerance configurable
The method used here is from Graphics Gems, A. Glasner, ed. page 531, "The Use of Coordinate Frames in Computer Graphics", by Ken Turkowski, Example 6.
Definition at line 782 of file mat.c.
References A, bn_mat_mul(), bn_mat_trn(), bn_vec_perp(), M, MAT4X3VEC, MAT_IDN, N, Q, R, UNLIKELY, V3ARGS, VCROSS, VDOT, VMOVE, VSET, VUNITIZE, X, Y, and Z.
Referenced by bn_math_cmd(), and bn_wrt_point_direc().
void bn_mat_xrot | ( | mat_t | m, | |
double | sinx, | |||
double | cosx | |||
) |
Referenced by bn_math_cmd().
void bn_mat_yrot | ( | mat_t | m, | |
double | siny, | |||
double | cosy | |||
) |
Referenced by bn_mat_lookat(), and bn_math_cmd().
void bn_mat_zrot | ( | mat_t | m, | |
double | sinz, | |||
double | cosz | |||
) |
Referenced by bn_mat_lookat(), and bn_math_cmd().
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 966 of file mat.c.
References bn_mat_mul(), bn_mat_yrot(), bn_mat_zrot(), MAT4X3VEC, MAT_COPY, MAT_IDN, V3ARGS, VPRINT, VSET, X, x, Y, Z, and z.
Referenced by bn_math_cmd().
Referenced by bn_math_cmd(), and tp_3vector().
B N _ M A T _ S C A L E _ A B O U T _ P T
Build a matrix to scale uniformly around a given point.
FIXME: make tolerance configurable
Definition at line 1084 of file mat.c.
References bn_mat_mul(), MAT_DELTAS_VEC, MAT_DELTAS_VEC_NEG, MAT_IDN, MAT_ZERO, and ZERO.
Referenced by bn_mat_scale_about_pt_wrapper().
B N _ M A T _ X F O R M _ A B O U T _ P T
Build a matrix to apply arbitary 4x4 transformation around a given point.
Definition at line 1115 of file mat.c.
References bn_mat_mul(), MAT_DELTAS_VEC, MAT_DELTAS_VEC_NEG, and MAT_IDN.
Referenced by bn_math_cmd().
B N _ M A T _ I S _ E Q U A L
Definition at line 1137 of file mat.c.
References BN_CK_TOL, bn_tol::dist, NEAR_ZERO, and bn_tol::perp.
int bn_mat_is_identity | ( | const mat_t | m | ) |
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 1195 of file mat.c.
References bn_mat_identity.
B N _ M A T _ A R B _ R O T
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
Definition at line 1211 of file mat.c.
References bn_mat_mul(), bn_mat_mul2(), MAT_IDN, MDX, MDY, MDZ, X, Y, Z, and ZERO.
Referenced by bn_math_cmd().
int bn_mat_ck | ( | const char * | title, | |
const mat_t | m | |||
) |
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 1294 of file mat.c.
References A, bn_mat_print(), NEAR_ZERO, VDIVIDE_TOL, VDOT, and VMOVE.
fastf_t bn_mat_det3 | ( | const mat_t | m | ) |
fastf_t bn_mat_determinant | ( | const mat_t | m | ) |
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 1363 of file mat.c.
Referenced by bn_isect_planes().
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 | |||
) |
B N _ W R T _ P O I N T _ D I R E C
Given a model-space transformation matrix "change", return a matrix which applies the change with-respect-to given "point" and "direc".
Definition at line 1426 of file mat.c.
References bn_mat_fromto(), bn_mat_inv(), bn_mat_mul3(), bn_mat_mul4(), MAT_DELTAS_VEC_NEG, MAT_IDN, and VSET.
const mat_t bn_mat_identity |
Definition at line 54 of file mat.c.
Referenced by bn_mat_is_identity().