00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef __BN_H__
00073 #define __BN_H__
00074
00075 __BEGIN_DECLS
00076
00077 #ifndef BN_EXPORT
00078 # if defined(_WIN32) && !defined(__CYGWIN__) && defined(BRLCAD_DLL)
00079 # ifdef BN_EXPORT_DLL
00080 # define BN_EXPORT __declspec(dllexport)
00081 # else
00082 # define BN_EXPORT __declspec(dllimport)
00083 # endif
00084 # else
00085 # define BN_EXPORT
00086 # endif
00087 #endif
00088
00089 #define BN_H_VERSION "@(#)$Header: /cvsroot/brlcad/brlcad/include/bn.h,v 14.19 2006/09/18 05:24:07 lbutler Exp $ (BRL)"
00090
00091
00092 #include "vmath.h"
00093
00094 #define BN_AZIMUTH 0
00095 #define BN_ELEVATION 1
00096 #define BN_TWIST 2
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 struct bn_tol {
00138 unsigned long magic;
00139 double dist;
00140 double dist_sq;
00141 double perp;
00142 double para;
00143 };
00144 #define BN_TOL_MAGIC 0x98c734bb
00145 #define BN_CK_TOL(_p) BU_CKMAG(_p, BN_TOL_MAGIC, "bn_tol")
00146
00147 #define BN_VECT_ARE_PARALLEL(_dot,_tol) \
00148 (((_dot) < 0) ? ((-(_dot))>=(_tol)->para) : ((_dot) >= (_tol)->para))
00149 #define BN_VECT_ARE_PERP(_dot,_tol) \
00150 (((_dot) < 0) ? ((-(_dot))<=(_tol)->perp) : ((_dot) <= (_tol)->perp))
00151
00152 #define BN_APPROXEQUAL(_a, _b, _tol) (fabs( (_a) - (_b) ) <= _tol->dist)
00153
00154
00155
00156
00157
00158
00159 BN_EXPORT BU_EXTERN(void anim_v_permute,
00160 (mat_t m));
00161 BN_EXPORT BU_EXTERN(void anim_v_unpermute,
00162 (mat_t m));
00163 BN_EXPORT BU_EXTERN(void anim_tran,
00164 (mat_t m));
00165 BN_EXPORT BU_EXTERN(int anim_mat2zyx,
00166 (const mat_t viewrot,
00167 vect_t angle));
00168 BN_EXPORT BU_EXTERN(int anim_mat2ypr,
00169 (mat_t viewrot,
00170 vect_t angle));
00171 BN_EXPORT BU_EXTERN(int anim_mat2quat,
00172 (quat_t quat,
00173 const mat_t viewrot));
00174 BN_EXPORT BU_EXTERN(void anim_ypr2mat,
00175 (mat_t m,
00176 const vect_t a));
00177 BN_EXPORT BU_EXTERN(void anim_ypr2vmat,
00178 (mat_t m,
00179 const vect_t a));
00180 BN_EXPORT BU_EXTERN(void anim_y_p_r2mat,
00181 (mat_t m,
00182 double y,
00183 double p,
00184 double r));
00185 BN_EXPORT BU_EXTERN(void anim_dy_p_r2mat,
00186 (mat_t m,
00187 double y,
00188 double p,
00189 double r));
00190 BN_EXPORT BU_EXTERN(void anim_dy_p_r2vmat,
00191 (mat_t m,
00192 double yaw,
00193 double pch,
00194 double rll));
00195 BN_EXPORT BU_EXTERN(void anim_x_y_z2mat,
00196 (mat_t m,
00197 double x,
00198 double y,
00199 double z));
00200 BN_EXPORT BU_EXTERN(void anim_dx_y_z2mat,
00201 (mat_t m,
00202 double x,
00203 double y,
00204 double z));
00205 BN_EXPORT BU_EXTERN(void anim_zyx2mat,
00206 (mat_t m,
00207 const vect_t a));
00208 BN_EXPORT BU_EXTERN(void anim_z_y_x2mat,
00209 (mat_t m,
00210 double x,
00211 double y,
00212 double z));
00213 BN_EXPORT BU_EXTERN(void anim_dz_y_x2mat,
00214 (mat_t m,
00215 double x,
00216 double y,
00217 double z));
00218 BN_EXPORT BU_EXTERN(void anim_quat2mat,
00219 (mat_t m,
00220 const quat_t qq));
00221 BN_EXPORT BU_EXTERN(void anim_dir2mat,
00222 (mat_t m,
00223 const vect_t d,
00224 const vect_t d2));
00225 BN_EXPORT BU_EXTERN(void anim_dirn2mat,
00226 (mat_t m,
00227 const vect_t dx,
00228 const vect_t dn));
00229 BN_EXPORT BU_EXTERN(int anim_steer_mat,
00230 (mat_t mat,
00231 vect_t point,
00232 int end));
00233 BN_EXPORT BU_EXTERN(void anim_add_trans,
00234 (mat_t m,
00235 const vect_t post,
00236 const vect_t pre));
00237 BN_EXPORT BU_EXTERN(void anim_rotatez,
00238 (fastf_t a,
00239 vect_t d));
00240 BN_EXPORT BU_EXTERN(void anim_mat_print,
00241 (FILE *fp,
00242 const mat_t m,
00243 int s_colon));
00244 BN_EXPORT BU_EXTERN(void anim_mat_printf,
00245 (FILE *fp,
00246 const mat_t m,
00247 const char *formstr,
00248 const char *linestr,
00249 const char *endstr));
00250 BN_EXPORT BU_EXTERN(void anim_view_rev,
00251 (mat_t m));
00252
00253
00254
00255
00256 BN_EXPORT BU_EXTERN(int bn_decode_mat,
00257 (mat_t m,
00258 const char *str));
00259 BN_EXPORT BU_EXTERN(int bn_decode_quat,
00260 (quat_t q,
00261 const char *str));
00262 BN_EXPORT BU_EXTERN(int bn_decode_vect,
00263 (vect_t v,
00264 const char *str));
00265 BN_EXPORT BU_EXTERN(int bn_decode_hvect,
00266 (hvect_t v,
00267 const char *str));
00268 BN_EXPORT BU_EXTERN(void bn_encode_mat,
00269 (struct bu_vls *vp,
00270 const mat_t m));
00271 BN_EXPORT BU_EXTERN(void bn_encode_quat,
00272 (struct bu_vls *vp,
00273 const quat_t q));
00274 BN_EXPORT BU_EXTERN(void bn_encode_vect,
00275 (struct bu_vls *vp,
00276 const vect_t v));
00277 BN_EXPORT BU_EXTERN(void bn_encode_hvect,
00278 (struct bu_vls *vp,
00279 const hvect_t v));
00280
00281
00282 BN_EXPORT BU_EXTERN(void bn_tcl_setup,
00283 ());
00284 #ifdef BRLCAD_DEBUG
00285 BN_EXPORT BU_EXTERN(int Bn_d_Init,
00286 ());
00287 #else
00288 BN_EXPORT BU_EXTERN(int Bn_Init,
00289 ());
00290 #endif
00291 BN_EXPORT BU_EXTERN(void bn_tcl_mat_print,
00292 ());
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 typedef struct bn_complex {
00305 double re;
00306 double im;
00307 } bn_complex_t;
00308
00309
00310
00311 #define bn_cx_copy( ap, bp ) {*(ap) = *(bp);}
00312 #define bn_cx_neg( cp ) { (cp)->re = -((cp)->re);(cp)->im = -((cp)->im);}
00313 #define bn_cx_real( cp ) (cp)->re
00314 #define bn_cx_imag( cp ) (cp)->im
00315
00316 #define bn_cx_add( ap, bp ) { (ap)->re += (bp)->re; (ap)->im += (bp)->im;}
00317 #define bn_cx_ampl( cp ) hypot( (cp)->re, (cp)->im )
00318 #define bn_cx_amplsq( cp ) ( (cp)->re * (cp)->re + (cp)->im * (cp)->im )
00319 #define bn_cx_conj( cp ) { (cp)->im = -(cp)->im; }
00320 #define bn_cx_cons( cp, r, i ) { (cp)->re = r; (cp)->im = i; }
00321 #define bn_cx_phas( cp ) atan2( (cp)->im, (cp)->re )
00322 #define bn_cx_scal( cp, s ) { (cp)->re *= (s); (cp)->im *= (s); }
00323 #define bn_cx_sub( ap, bp ) { (ap)->re -= (bp)->re; (ap)->im -= (bp)->im;}
00324
00325 #define bn_cx_mul( ap, bp ) \
00326 { FAST fastf_t a__re, b__re; \
00327 (ap)->re = ((a__re=(ap)->re)*(b__re=(bp)->re)) - (ap)->im*(bp)->im; \
00328 (ap)->im = a__re*(bp)->im + (ap)->im*b__re; }
00329
00330
00331 #define bn_cx_mul2( ap, bp, cp ) { \
00332 (ap)->re = (cp)->re * (bp)->re - (cp)->im * (bp)->im; \
00333 (ap)->im = (cp)->re * (bp)->im + (cp)->im * (bp)->re; }
00334
00335 BN_EXPORT BU_EXTERN(void bn_cx_div,
00336 (bn_complex_t *ap,
00337 const bn_complex_t *bp));
00338 BN_EXPORT BU_EXTERN(void bn_cx_sqrt,
00339 (bn_complex_t *op,
00340 const bn_complex_t *ip));
00341
00342
00343
00344
00345
00346
00347 BN_EXPORT extern const mat_t bn_mat_identity;
00348
00349 BN_EXPORT BU_EXTERN(void bn_mat_print,
00350 (const char *title,
00351 const mat_t m));
00352 BN_EXPORT BU_EXTERN(void bn_mat_print_guts,
00353 (const char *title,
00354 const mat_t m,
00355 char *buf));
00356 BN_EXPORT BU_EXTERN(double bn_atan2,
00357 (double x, double y));
00358
00359 #if 0
00360 BN_EXPORT BU_EXTERN(void bn_mat_zero,
00361 (mat_t m));
00362 BN_EXPORT BU_EXTERN(void bn_mat_idn,
00363 (mat_t m));
00364 BN_EXPORT BU_EXTERN(void bn_mat_copy,
00365 (register mat_t dest,
00366 register const mat_t src));
00367 #else
00368 #define bn_mat_zero( _m ) { \
00369 bu_log("%s:%d bn_mat_zero() is deprecated, use MAT_ZERO()\n", \
00370 __FILE__, __LINE__); \
00371 (_m)[0] = (_m)[1] = (_m)[2] = (_m)[3] = \
00372 (_m)[4] = (_m)[5] = (_m)[6] = (_m)[7] = \
00373 (_m)[8] = (_m)[9] = (_m)[10] = (_m)[11] = \
00374 (_m)[12] = (_m)[13] = (_m)[14] = (_m)[15] = 0.0; }
00375
00376
00377
00378 #define bn_mat_idn( _m ) { \
00379 bu_log("%s:%d bn_mat_idn() is deprecated, use MAT_IDN()\n", \
00380 __FILE__, __LINE__); \
00381 (_m)[1] = (_m)[2] = (_m)[3] = (_m)[4] = \
00382 (_m)[6] = (_m)[7] = (_m)[8] = (_m)[9] = \
00383 (_m)[11] = (_m)[12] = (_m)[13] = (_m)[14] = 0.0; \
00384 (_m)[0] = (_m)[5] = (_m)[10] = (_m)[15] = 1.0; }
00385
00386
00387
00388
00389 #define bn_mat_copy( _d, _s ) { \
00390 bu_log("%s:%d bn_mat_copy() is deprecated, use MAT_COPY()\n", \
00391 __FILE__, __LINE__); \
00392 (_d)[0] = (_s)[0];\
00393 (_d)[1] = (_s)[1];\
00394 (_d)[2] = (_s)[2];\
00395 (_d)[3] = (_s)[3];\
00396 (_d)[4] = (_s)[4];\
00397 (_d)[5] = (_s)[5];\
00398 (_d)[6] = (_s)[6];\
00399 (_d)[7] = (_s)[7];\
00400 (_d)[8] = (_s)[8];\
00401 (_d)[9] = (_s)[9];\
00402 (_d)[10] = (_s)[10];\
00403 (_d)[11] = (_s)[11];\
00404 (_d)[12] = (_s)[12];\
00405 (_d)[13] = (_s)[13];\
00406 (_d)[14] = (_s)[14];\
00407 (_d)[15] = (_s)[15]; }
00408
00409
00410
00411 #endif
00412
00413 BN_EXPORT BU_EXTERN(void bn_mat_mul,
00414 (register mat_t o,
00415 register const mat_t a,
00416 register const mat_t b));
00417 BN_EXPORT BU_EXTERN(void bn_mat_mul2,
00418 (register const mat_t i,
00419 register mat_t o));
00420 BN_EXPORT BU_EXTERN(void bn_mat_mul3,
00421 (mat_t o,
00422 const mat_t a,
00423 const mat_t b,
00424 const mat_t c));
00425 BN_EXPORT BU_EXTERN(void bn_mat_mul4,
00426 (mat_t o,
00427 const mat_t a,
00428 const mat_t b,
00429 const mat_t c,
00430 const mat_t d));
00431 BN_EXPORT BU_EXTERN(void bn_matXvec,
00432 (register hvect_t ov,
00433 register const mat_t im,
00434 register const hvect_t iv));
00435 BN_EXPORT BU_EXTERN(void bn_mat_inv,
00436 (register mat_t output,
00437 const mat_t input));
00438 BN_EXPORT BU_EXTERN(int bn_mat_inverse,
00439 (register mat_t output,
00440 const mat_t input));
00441 BN_EXPORT BU_EXTERN(void bn_vtoh_move,
00442 (register vect_t h,
00443 register const vect_t v));
00444 BN_EXPORT BU_EXTERN(void bn_htov_move,
00445 (register vect_t v,
00446 register const vect_t h));
00447 BN_EXPORT BU_EXTERN(void bn_mat_trn,
00448 (mat_t om,
00449 register const mat_t im));
00450 BN_EXPORT BU_EXTERN(void bn_mat_ae,
00451 (register mat_t m,
00452 double azimuth,
00453 double elev));
00454 BN_EXPORT BU_EXTERN(void bn_ae_vec,
00455 (fastf_t *azp,
00456 fastf_t *elp,
00457 const vect_t v));
00458 BN_EXPORT BU_EXTERN(void bn_aet_vec,
00459 (fastf_t *az,
00460 fastf_t *el,
00461 fastf_t *twist,
00462 vect_t vec_ae,
00463 vect_t vec_twist,
00464 fastf_t accuracy));
00465
00466 BN_EXPORT BU_EXTERN(void bn_mat_angles,
00467 (register mat_t mat,
00468 double alpha,
00469 double beta, double ggamma));
00470 BN_EXPORT BU_EXTERN(void bn_mat_angles_rad,
00471 (register mat_t mat,
00472 double alpha,
00473 double beta,
00474 double ggamma));
00475
00476 BN_EXPORT BU_EXTERN(void bn_eigen2x2,
00477 (fastf_t *val1,
00478 fastf_t *val2,
00479 vect_t vec1,
00480 vect_t vec2,
00481 fastf_t a,
00482 fastf_t b,
00483 fastf_t c));
00484
00485 BN_EXPORT BU_EXTERN(void bn_vec_perp,
00486 (vect_t new_vec,
00487 const vect_t old_vec));
00488 BN_EXPORT BU_EXTERN(void bn_mat_fromto,
00489 (mat_t m,
00490 const vect_t from,
00491 const vect_t to));
00492 BN_EXPORT BU_EXTERN(void bn_mat_xrot,
00493 (mat_t m,
00494 double sinx,
00495 double cosx));
00496 BN_EXPORT BU_EXTERN(void bn_mat_yrot,
00497 (mat_t m,
00498 double siny,
00499 double cosy));
00500 BN_EXPORT BU_EXTERN(void bn_mat_zrot,
00501 (mat_t m,
00502 double sinz,
00503 double cosz));
00504 BN_EXPORT BU_EXTERN(void bn_mat_lookat,
00505 (mat_t rot,
00506 const vect_t dir,
00507 int yflip));
00508 BN_EXPORT BU_EXTERN(void bn_vec_ortho,
00509 (register vect_t out,
00510 register const vect_t in));
00511 BN_EXPORT BU_EXTERN(int bn_mat_scale_about_pt,
00512 (mat_t mat,
00513 const point_t pt,
00514 const double scale));
00515 BN_EXPORT BU_EXTERN(void bn_mat_xform_about_pt,
00516 (mat_t mat,
00517 const mat_t xform,
00518 const point_t pt));
00519 BN_EXPORT BU_EXTERN(int bn_mat_is_equal,
00520 (const mat_t a,
00521 const mat_t b,
00522 const struct bn_tol *tol));
00523 BN_EXPORT BU_EXTERN(int bn_mat_is_identity,
00524 (const mat_t m));
00525 BN_EXPORT BU_EXTERN(void bn_mat_arb_rot,
00526 (mat_t m,
00527 const point_t pt,
00528 const vect_t dir,
00529 const fastf_t ang));
00530 BN_EXPORT BU_EXTERN(matp_t bn_mat_dup,
00531 (const mat_t in));
00532 BN_EXPORT BU_EXTERN(int bn_mat_ck,
00533 (const char *title,
00534 const mat_t m));
00535 BN_EXPORT BU_EXTERN(fastf_t bn_mat_det3,
00536 (const mat_t m));
00537 BN_EXPORT BU_EXTERN(fastf_t bn_mat_determinant,
00538 (const mat_t m));
00539
00540 BN_EXPORT BU_EXTERN(int bn_mat_is_non_unif,
00541 (const mat_t m));
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 struct bn_unif {
00554 long magic;
00555 long msr_seed;
00556 int msr_double_ptr;
00557 double *msr_doubles;
00558 int msr_long_ptr;
00559 long *msr_longs;
00560 };
00561
00562 #define BN_UNIF_MAGIC 12481632
00563 #define BN_GAUSS_MAGIC 512256128
00564
00565 #define BN_CK_UNIF(_p) BU_CKMAG(_p, BN_UNIF_MAGIC, "bn_unif")
00566 #define BN_CK_GAUSS(_p) BU_CKMAG(_p, BN_GAUSS_MAGIC, "bn_gauss")
00567
00568
00569
00570
00571
00572
00573
00574
00575 struct bn_gauss {
00576 long magic;
00577 long msr_gauss_seed;
00578 int msr_gauss_dbl_ptr;
00579 double *msr_gauss_doubles;
00580 int msr_gauss_ptr;
00581 double *msr_gausses;
00582 };
00583
00584 BN_EXPORT BU_EXTERN(struct bn_unif *bn_unif_init,
00585 (long setseed,
00586 int method));
00587 BN_EXPORT BU_EXTERN(void bn_unif_free,
00588 (struct bn_unif *p));
00589 BN_EXPORT BU_EXTERN(long bn_unif_long_fill,
00590 (struct bn_unif *p));
00591 BN_EXPORT BU_EXTERN(double bn_unif_double_fill,
00592 (struct bn_unif *p));
00593 BN_EXPORT BU_EXTERN(struct bn_gauss *bn_gauss_init,
00594 (long setseed,
00595 int method));
00596 BN_EXPORT BU_EXTERN(void bn_gauss_free,
00597 (struct bn_gauss *p));
00598 BN_EXPORT BU_EXTERN(double bn_gauss_fill,
00599 (struct bn_gauss *p));
00600
00601 #define BN_UNIF_LONG(_p) \
00602 (((_p)->msr_long_ptr ) ? \
00603 (_p)->msr_longs[--(_p)->msr_long_ptr] : \
00604 bn_unif_long_fill(_p))
00605 #define BN_UNIF_DOUBLE(_p) \
00606 (((_p)->msr_double_ptr) ? \
00607 (_p)->msr_doubles[--(_p)->msr_double_ptr] : \
00608 bn_unif_double_fill(_p))
00609
00610 #define BN_UNIF_CIRCLE(_p,_x,_y,_r) { \
00611 do { \
00612 (_x) = 2.0*BN_UNIF_DOUBLE((_p)); \
00613 (_y) = 2.0*BN_UNIF_DOUBLE((_p)); \
00614 (_r) = (_x)*(_x)+(_y)*(_y); \
00615 } while ((_r) >= 1.0); }
00616
00617 #define BN_UNIF_SPHERE(_p,_x,_y,_z,_r) { \
00618 do { \
00619 (_x) = 2.0*BN_UNIF_DOUBLE(_p); \
00620 (_y) = 2.0*BN_UNIF_DOUBLE(_p); \
00621 (_z) = 2.0*BN_UNIF_DOUBLE(_p); \
00622 (_r) = (_x)*(_x)+(_y)*(_y)+(_z)*(_z);\
00623 } while ((_r) >= 1.0) }
00624
00625 #define BN_GAUSS_DOUBLE(_p) \
00626 (((_p)->msr_gauss_ptr) ? \
00627 (_p)->msr_gausses[--(_p)->msr_gauss_ptr] : \
00628 bn_gauss_fill(_p))
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639 BN_EXPORT BU_EXTERN(void bn_noise_init,
00640 ());
00641 BN_EXPORT BU_EXTERN(double bn_noise_perlin,
00642 (point_t pt));
00643
00644 BN_EXPORT BU_EXTERN(void bn_noise_vec,
00645 (point_t point,
00646 point_t result));
00647 BN_EXPORT BU_EXTERN(double bn_noise_fbm,
00648 (point_t point,
00649 double h_val,
00650 double lacunarity,
00651 double octaves));
00652 BN_EXPORT BU_EXTERN(double bn_noise_turb,
00653 (point_t point,
00654 double h_val,
00655 double lacunarity,
00656 double octaves));
00657 BN_EXPORT BU_EXTERN(double bn_noise_mf,
00658 (point_t point,
00659 double h_val,
00660 double lacunarity,
00661 double octaves,
00662 double offset));
00663 BN_EXPORT BU_EXTERN(double bn_noise_ridged,
00664 (point_t point,
00665 double h_val,
00666 double lacunarity,
00667 double octaves,
00668 double offset));
00669
00670
00671
00672
00673
00674
00675
00676
00677 BN_EXPORT BU_EXTERN(int bn_distsq_line3_line3,
00678 (fastf_t dist[3],
00679 point_t P,
00680 vect_t d,
00681 point_t Q,
00682 vect_t e,
00683 point_t pt1,
00684 point_t pt2));
00685
00686 BN_EXPORT BU_EXTERN(int bn_dist_pt3_lseg3,
00687 (fastf_t *dist,
00688 point_t pca,
00689 const point_t a,
00690 const point_t b,
00691 const point_t p,
00692 const struct bn_tol *tol));
00693 BN_EXPORT BU_EXTERN(int bn_3pts_collinear,
00694 (point_t a,
00695 point_t b,
00696 point_t c,
00697 const struct bn_tol *tol));
00698 BN_EXPORT BU_EXTERN(int bn_pt3_pt3_equal,
00699 ( const point_t a,
00700 const point_t b,
00701 const struct bn_tol *tol));
00702 BN_EXPORT BU_EXTERN(int bn_dist_pt2_lseg2,
00703 (fastf_t *dist_sq,
00704 fastf_t pca[2],
00705 const point_t a,
00706 const point_t b,
00707 const point_t p,
00708 const struct bn_tol *tol));
00709 BN_EXPORT BU_EXTERN(int bn_isect_lseg3_lseg3,
00710 (fastf_t *dist,
00711 const point_t p, const vect_t pdir,
00712 const point_t q, const vect_t qdir,
00713 const struct bn_tol *tol));
00714 BN_EXPORT BU_EXTERN(int bn_isect_line3_line3,
00715 (fastf_t *t, fastf_t *u,
00716 const point_t p,
00717 const vect_t d,
00718 const point_t a,
00719 const vect_t c,
00720 const struct bn_tol *tol));
00721 BN_EXPORT BU_EXTERN(int bn_2line3_colinear,
00722 (const point_t p1,
00723 const vect_t d1,
00724 const point_t p2,
00725 const vect_t d2,
00726 double range,
00727 const struct bn_tol *tol));
00728 BN_EXPORT BU_EXTERN(int bn_isect_pt2_lseg2,
00729 (fastf_t *dist,
00730 const point_t a,
00731 const point_t b,
00732 const point_t p,
00733 const struct bn_tol *tol));
00734 BN_EXPORT BU_EXTERN(int bn_isect_line2_lseg2,
00735 (fastf_t *dist,
00736 const point_t p,
00737 const vect_t d,
00738 const point_t a,
00739 const vect_t c,
00740 const struct bn_tol *tol));
00741 BN_EXPORT BU_EXTERN(int bn_isect_lseg2_lseg2,
00742 (fastf_t *dist,
00743 const point_t p,
00744 const vect_t pdir,
00745 const point_t q,
00746 const vect_t qdir,
00747 const struct bn_tol *tol));
00748 BN_EXPORT BU_EXTERN(int bn_isect_line2_line2,
00749 (fastf_t *dist,
00750 const point_t p,
00751 const vect_t d,
00752 const point_t a,
00753 const vect_t c,
00754 const struct bn_tol *tol));
00755 BN_EXPORT BU_EXTERN(double bn_dist_pt3_pt3,
00756 (const point_t a,
00757 const point_t b));
00758 BN_EXPORT BU_EXTERN(int bn_3pts_distinct,
00759 (const point_t a,
00760 const point_t b,
00761 const point_t c,
00762 const struct bn_tol *tol));
00763 BN_EXPORT BU_EXTERN(int bn_mk_plane_3pts,
00764 (plane_t plane,
00765 const point_t a,
00766 const point_t b,
00767 const point_t c,
00768 const struct bn_tol *tol));
00769 BN_EXPORT BU_EXTERN(int bn_mkpoint_3planes,
00770 (point_t pt,
00771 const plane_t a,
00772 const plane_t b,
00773 const plane_t c));
00774 BN_EXPORT BU_EXTERN(int bn_isect_line3_plane,
00775 (fastf_t *dist,
00776 const point_t pt,
00777 const vect_t dir,
00778 const plane_t plane,
00779 const struct bn_tol *tol));
00780 BN_EXPORT BU_EXTERN(int bn_isect_2planes,
00781 (point_t pt,
00782 vect_t dir,
00783 const plane_t a,
00784 const plane_t b,
00785 const vect_t rpp_min,
00786 const struct bn_tol *tol));
00787 BN_EXPORT BU_EXTERN(int bn_isect_2lines,
00788 (fastf_t *t,
00789 fastf_t *u,
00790 const point_t p,
00791 const vect_t d,
00792 const point_t a,
00793 const vect_t c,
00794 const struct bn_tol *tol));
00795 BN_EXPORT BU_EXTERN(int bn_isect_line_lseg,
00796 (fastf_t *t, const point_t p,
00797 const vect_t d,
00798 const point_t a,
00799 const point_t b,
00800 const struct bn_tol *tol));
00801 BN_EXPORT BU_EXTERN(double bn_dist_line3_pt3,
00802 (const point_t pt,
00803 const vect_t dir,
00804 const point_t a));
00805 BN_EXPORT BU_EXTERN(double bn_distsq_line3_pt3,
00806 (const point_t pt,
00807 const vect_t dir,
00808 const point_t a));
00809 BN_EXPORT BU_EXTERN(double bn_dist_line_origin,
00810 (const point_t pt,
00811 const vect_t dir));
00812 BN_EXPORT BU_EXTERN(double bn_dist_line2_point2,
00813 (const point_t pt,
00814 const vect_t dir,
00815 const point_t a));
00816 BN_EXPORT BU_EXTERN(double bn_distsq_line2_point2,
00817 (const point_t pt,
00818 const vect_t dir,
00819 const point_t a));
00820 BN_EXPORT BU_EXTERN(double bn_area_of_triangle,
00821 (const point_t a,
00822 const point_t b,
00823 const point_t c));
00824 BN_EXPORT BU_EXTERN(int bn_isect_pt_lseg,
00825 (fastf_t *dist,
00826 const point_t a,
00827 const point_t b,
00828 const point_t p,
00829 const struct bn_tol *tol));
00830 BN_EXPORT BU_EXTERN(double bn_dist_pt_lseg,
00831 (point_t pca,
00832 const point_t a,
00833 const point_t b,
00834 const point_t p,
00835 const struct bn_tol *tol));
00836 BN_EXPORT BU_EXTERN(void bn_rotate_bbox,
00837 (point_t omin,
00838 point_t omax,
00839 const mat_t mat,
00840 const point_t imin,
00841 const point_t imax));
00842 BN_EXPORT BU_EXTERN(void bn_rotate_plane,
00843 (plane_t oplane,
00844 const mat_t mat,
00845 const plane_t iplane));
00846 BN_EXPORT BU_EXTERN(int bn_coplanar,
00847 (const plane_t a,
00848 const plane_t b,
00849 const struct bn_tol *tol));
00850 BN_EXPORT BU_EXTERN(double bn_angle_measure,
00851 (vect_t vec,
00852 const vect_t x_dir,
00853 const vect_t y_dir));
00854 BN_EXPORT BU_EXTERN(double bn_dist_pt3_along_line3,
00855 (const point_t p,
00856 const vect_t d,
00857 const point_t x));
00858 BN_EXPORT BU_EXTERN(double bn_dist_pt2_along_line2,
00859 (const point_t p,
00860 const vect_t d,
00861 const point_t x));
00862 BN_EXPORT BU_EXTERN(int bn_between,
00863 (double left,
00864 double mid,
00865 double right,
00866 const struct bn_tol *tol));
00867 BN_EXPORT BU_EXTERN(int bn_does_ray_isect_tri,
00868 (const point_t pt,
00869 const vect_t dir,
00870 const point_t V,
00871 const point_t A,
00872 const point_t B,
00873 point_t inter));
00874 BN_EXPORT BU_EXTERN(int bn_hlf_class,
00875 (const plane_t half_eqn,
00876 const vect_t min, const vect_t max,
00877 const struct bn_tol *tol));
00878
00879 #define BN_CLASSIFY_UNIMPLEMENTED 0x0000
00880 #define BN_CLASSIFY_OVERLAPPING 0x0002
00881 #define BN_CLASSIFY_INSIDE 0x0001
00882 #define BN_CLASSIFY_OUTSIDE 0x0003
00883
00884 BN_EXPORT BU_EXTERN(int bn_isect_planes,
00885 (point_t pt,
00886 const plane_t planes[],
00887 const int pl_count));
00888
00889
00890
00891
00892
00893
00894
00895 #define BN_MAX_POLY_DEGREE 4
00896
00897
00898
00899 typedef struct bn_poly {
00900 long magic;
00901 int dgr;
00902 double cf[BN_MAX_POLY_DEGREE+1];
00903 } bn_poly_t;
00904 #define BN_POLY_MAGIC 0x506f4c79
00905 #define BN_CK_POLY(_p) BU_CKMAG(_p, BN_POLY_MAGIC, "struct bn_poly")
00906 #define BN_POLY_NULL ((struct bn_poly *)NULL)
00907
00908 BN_EXPORT BU_EXTERN(struct bn_poly *bn_poly_mul,
00909 (struct bn_poly *product,
00910 const struct bn_poly *m1,
00911 const struct bn_poly *m2));
00912 BN_EXPORT BU_EXTERN(struct bn_poly *bn_poly_scale,
00913 (struct bn_poly *eqn,
00914 double factor));
00915 BN_EXPORT BU_EXTERN(struct bn_poly *bn_poly_add,
00916 (struct bn_poly *sum,
00917 const struct bn_poly *poly1,
00918 const struct bn_poly *poly2));
00919 BN_EXPORT BU_EXTERN(struct bn_poly *bn_poly_sub,
00920 (struct bn_poly *diff,
00921 const struct bn_poly *poly1,
00922 const struct bn_poly *poly2));
00923 BN_EXPORT BU_EXTERN(void bn_poly_synthetic_division,
00924 (struct bn_poly *quo,
00925 struct bn_poly *rem,
00926 const struct bn_poly *dvdend,
00927 const struct bn_poly *dvsor));
00928 BN_EXPORT BU_EXTERN(int bn_poly_quadratic_roots,
00929 (struct bn_complex roots[],
00930 const struct bn_poly *quadrat));
00931 BN_EXPORT BU_EXTERN(int bn_poly_cubic_roots,
00932 (struct bn_complex roots[],
00933 const struct bn_poly *eqn));
00934 BN_EXPORT BU_EXTERN(int bn_poly_quartic_roots,
00935 (struct bn_complex roots[],
00936 const struct bn_poly *eqn));
00937 BN_EXPORT BU_EXTERN(void bn_pr_poly,
00938 (const char *title,
00939 const struct bn_poly *eqn));
00940 BN_EXPORT BU_EXTERN(void bn_pr_roots,
00941 (const char *title,
00942 const struct bn_complex roots[],
00943 int n));
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953 BN_EXPORT BU_EXTERN(void quat_mat2quat,
00954 (quat_t quat,
00955 const mat_t mat));
00956 BN_EXPORT BU_EXTERN(void quat_quat2mat,
00957 (mat_t mat,
00958 const quat_t quat));
00959 BN_EXPORT BU_EXTERN(double quat_distance,
00960 (const quat_t q1,
00961 const quat_t q2));
00962 BN_EXPORT BU_EXTERN(void quat_double,
00963 (quat_t qout,
00964 const quat_t q1,
00965 const quat_t q2));
00966 BN_EXPORT BU_EXTERN(void quat_bisect,
00967 (quat_t qout,
00968 const quat_t q1,
00969 const quat_t q2));
00970 BN_EXPORT BU_EXTERN(void quat_slerp,
00971 (quat_t qout,
00972 const quat_t q1,
00973 const quat_t q2,
00974 double f));
00975 BN_EXPORT BU_EXTERN(void quat_sberp,
00976 (quat_t qout,
00977 const quat_t q1,
00978 const quat_t qa,
00979 const quat_t qb,
00980 const quat_t q2,
00981 double f));
00982 BN_EXPORT BU_EXTERN(void quat_make_nearest,
00983 (quat_t q1,
00984 const quat_t q2));
00985 BN_EXPORT BU_EXTERN(void quat_print,
00986 (const char *title,
00987 const quat_t quat));
00988 BN_EXPORT BU_EXTERN(void quat_exp,
00989 (quat_t out,
00990 const quat_t in));
00991 BN_EXPORT BU_EXTERN(void quat_log,
00992 (quat_t out,
00993 const quat_t in));
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018 #define BN_RAND_TABSIZE 4096
01019 #define BN_RAND_TABMASK 0xfff
01020 #define BN_RANDSEED( _i, _seed ) _i = ((unsigned)_seed) % BN_RAND_TABSIZE
01021 BN_EXPORT extern const float bn_rand_table[BN_RAND_TABSIZE];
01022
01023
01024 #define BN_RANDOM( _i ) bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]
01025
01026
01027 #define BN_RANDHALF( _i ) (bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]-0.5)
01028 #define BN_RANDHALF_INIT(_p) _p = bn_rand_table
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038 #define BN_RANDHALFTABSIZE 16535
01039 BN_EXPORT extern int bn_randhalftabsize;
01040 BN_EXPORT extern float bn_rand_halftab[BN_RANDHALFTABSIZE];
01041
01042 #define bn_rand_half(_p) \
01043 ( (++(_p) >= &bn_rand_halftab[bn_randhalftabsize] || \
01044 (_p) < bn_rand_halftab) ? \
01045 *((_p) = bn_rand_halftab) : *(_p))
01046
01047 #define bn_rand_init(_p, _seed) \
01048 (_p) = &bn_rand_halftab[ \
01049 (int)( \
01050 (bn_rand_halftab[(_seed)%bn_randhalftabsize] + 0.5) * \
01051 (bn_randhalftabsize-1)) ]
01052
01053
01054 #define bn_rand0to1(_q) (bn_rand_half(_q)+0.5)
01055
01056 #define BN_SINTABSIZE 2048
01057 BN_EXPORT extern double bn_sin_scale;
01058 #define bn_tab_sin(_a) (((_a) > 0) ? \
01059 ( bn_sin_table[(int)((0.5+ (_a)*bn_sin_scale))&(BN_SINTABSIZE-1)] ) :\
01060 (-bn_sin_table[(int)((0.5- (_a)*bn_sin_scale))&(BN_SINTABSIZE-1)] ))
01061 BN_EXPORT extern const float bn_sin_table[BN_SINTABSIZE];
01062
01063 BN_EXPORT extern void bn_mathtab_constant();
01064
01065
01066
01067
01068
01069
01070 #define CK_POW_2(dimen) { register unsigned long j; register int ok;\
01071 for (ok=0, j=0 ; j < sizeof(unsigned long) * 8 ; j++) { \
01072 if ( (1<<j) == dimen) { ok = 1; break; } \
01073 } \
01074 if ( ! ok ) { \
01075 bu_log("%s:%d value %d should be power of 2 (2^%d)\n", \
01076 __FILE__, __LINE__, dimen, j); \
01077 bu_bomb("CK_POW_2"); \
01078 }\
01079 }
01080
01081 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_double_decompose,
01082 (double *tbuf,
01083 double *buf,
01084 unsigned long dimen,
01085 unsigned long depth,
01086 unsigned long limit));
01087 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_double_reconstruct,
01088 (double *tbuf,
01089 double *buf,
01090 unsigned long dimen,
01091 unsigned long depth,
01092 unsigned long subimage_size,
01093 unsigned long limit));
01094
01095 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_float_decompose,
01096 (float *tbuf,
01097 float *buf,
01098 unsigned long dimen,
01099 unsigned long depth,
01100 unsigned long limit));
01101 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_float_reconstruct,
01102 (float *tbuf,
01103 float *buf,
01104 unsigned long dimen,
01105 unsigned long depth,
01106 unsigned long subimage_size,
01107 unsigned long limit));
01108
01109 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_char_decompose,
01110 (char *tbuf,
01111 char *buf,
01112 unsigned long dimen,
01113 unsigned long depth,
01114 unsigned long limit));
01115 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_char_reconstruct,
01116 (char *tbuf, char *buf,
01117 unsigned long dimen,
01118 unsigned long depth,
01119 unsigned long subimage_size,
01120 unsigned long limit));
01121
01122 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_short_decompose,
01123 (short *tbuf, short *buf,
01124 unsigned long dimen,
01125 unsigned long depth,
01126 unsigned long limit));
01127 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_short_reconstruct,
01128 (short *tbuf, short *buf,
01129 unsigned long dimen,
01130 unsigned long depth,
01131 unsigned long subimage_size,
01132 unsigned long limit));
01133
01134 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_int_decompose,
01135 (int *tbuf, int *buf,
01136 unsigned long dimen,
01137 unsigned long depth,
01138 unsigned long limit));
01139 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_int_reconstruct,
01140 (int *tbuf,
01141 int *buf,
01142 unsigned long dimen,
01143 unsigned long depth,
01144 unsigned long subimage_size,
01145 unsigned long limit));
01146
01147 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_long_decompose,
01148 (long *tbuf, long *buf,
01149 unsigned long dimen,
01150 unsigned long depth,
01151 unsigned long limit));
01152 BN_EXPORT BU_EXTERN(void bn_wlt_haar_1d_long_reconstruct,
01153 (long *tbuf, long *buf,
01154 unsigned long dimen,
01155 unsigned long depth,
01156 unsigned long subimage_size,
01157 unsigned long limit));
01158
01159
01160
01161 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_double_decompose,
01162 (double *tbuf,
01163 double *buf,
01164 unsigned long dimen,
01165 unsigned long depth,
01166 unsigned long limit));
01167 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_double_reconstruct,
01168 (double *tbuf,
01169 double *buf,
01170 unsigned long dimen,
01171 unsigned long depth,
01172 unsigned long subimage_size,
01173 unsigned long limit));
01174
01175 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_float_decompose,
01176 (float *tbuf,
01177 float *buf,
01178 unsigned long dimen,
01179 unsigned long depth,
01180 unsigned long limit));
01181 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_float_reconstruct,
01182 (float *tbuf,
01183 float *buf,
01184 unsigned long dimen,
01185 unsigned long depth,
01186 unsigned long subimage_size,
01187 unsigned long limit));
01188
01189 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_char_decompose,
01190 (char *tbuf,
01191 char *buf,
01192 unsigned long dimen,
01193 unsigned long depth,
01194 unsigned long limit));
01195 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_char_reconstruct,
01196 (char *tbuf,
01197 char *buf,
01198 unsigned long dimen,
01199 unsigned long depth,
01200 unsigned long subimage_size,
01201 unsigned long limit));
01202
01203 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_short_decompose,
01204 (short *tbuf,
01205 short *buf,
01206 unsigned long dimen,
01207 unsigned long depth,
01208 unsigned long limit));
01209 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_short_reconstruct,
01210 (short *tbuf,
01211 short *buf,
01212 unsigned long dimen,
01213 unsigned long depth,
01214 unsigned long subimage_size,
01215 unsigned long limit));
01216
01217 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_int_decompose,
01218 (int *tbuf,
01219 int *buf,
01220 unsigned long dimen,
01221 unsigned long depth,
01222 unsigned long limit));
01223 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_int_reconstruct,
01224 (int *tbuf,
01225 int *buf,
01226 unsigned long dimen,
01227 unsigned long depth,
01228 unsigned long subimage_size,
01229 unsigned long limit));
01230
01231 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_long_decompose,
01232 (long *tbuf,
01233 long *buf,
01234 unsigned long dimen,
01235 unsigned long depth,
01236 unsigned long limit));
01237 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_long_reconstruct,
01238 (long *tbuf,
01239 long *buf,
01240 unsigned long dimen,
01241 unsigned long depth,
01242 unsigned long subimage_size,
01243 unsigned long limit));
01244
01245
01246
01247 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_double_decompose2,
01248 (double *tbuf,
01249 double *buf,
01250 unsigned long dimen,
01251 unsigned long width,
01252 unsigned long height,
01253 unsigned long limit));
01254 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_double_reconstruct2,
01255 (double *tbuf,
01256 double *buf,
01257 unsigned long dimen,
01258 unsigned long width,
01259 unsigned long height,
01260 unsigned long subimage_size,
01261 unsigned long limit));
01262
01263 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_float_decompose2,
01264 (float *tbuf,
01265 float *buf,
01266 unsigned long dimen,
01267 unsigned long width,
01268 unsigned long height,
01269 unsigned long limit));
01270 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_float_reconstruct2,
01271 (float *tbuf,
01272 float *buf,
01273 unsigned long dimen,
01274 unsigned long width,
01275 unsigned long height,
01276 unsigned long subimage_size,
01277 unsigned long limit));
01278
01279 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_char_decompose2,
01280 (char *tbuf,
01281 char *buf,
01282 unsigned long dimen,
01283 unsigned long width,
01284 unsigned long height,
01285 unsigned long limit));
01286 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_char_reconstruct2,
01287 (char *tbuf,
01288 char *buf,
01289 unsigned long dimen,
01290 unsigned long width,
01291 unsigned long height,
01292 unsigned long subimage_size,
01293 unsigned long limit));
01294
01295 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_short_decompose2,
01296 (short *tbuf,
01297 short *buf,
01298 unsigned long dimen,
01299 unsigned long width,
01300 unsigned long height,
01301 unsigned long limit));
01302 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_short_reconstruct2,
01303 (short *tbuf,
01304 short *buf,
01305 unsigned long dimen,
01306 unsigned long width,
01307 unsigned long height,
01308 unsigned long subimage_size,
01309 unsigned long limit));
01310
01311 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_int_decompose2,
01312 (int *tbuf,
01313 int *buf,
01314 unsigned long dimen,
01315 unsigned long width,
01316 unsigned long height,
01317 unsigned long limit));
01318 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_int_reconstruct2,
01319 (int *tbuf,
01320 int *buf,
01321 unsigned long dimen,
01322 unsigned long width,
01323 unsigned long height,
01324 unsigned long subimage_size,
01325 unsigned long limit));
01326
01327 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_long_decompose2,
01328 (long *tbuf,
01329 long *buf,
01330 unsigned long dimen,
01331 unsigned long width,
01332 unsigned long height,
01333 unsigned long limit));
01334 BN_EXPORT BU_EXTERN(void bn_wlt_haar_2d_long_reconstruct2,
01335 (long *tbuf,
01336 long *buf,
01337 unsigned long dimen,
01338 unsigned long width,
01339 unsigned long height,
01340 unsigned long subimage_size,
01341 unsigned long limit));
01342
01343
01344
01345
01346 BN_EXPORT extern const double bn_pi;
01347 BN_EXPORT extern const double bn_twopi;
01348 BN_EXPORT extern const double bn_halfpi;
01349 BN_EXPORT extern const double bn_invpi;
01350 BN_EXPORT extern const double bn_inv2pi;
01351 BN_EXPORT extern const double bn_inv255;
01352 BN_EXPORT extern const double bn_degtorad;
01353 BN_EXPORT extern const double bn_radtodeg;
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397 struct bn_table {
01398 long magic;
01399 int nx;
01400 fastf_t x[1];
01401 };
01402 #define BN_TABLE_MAGIC 0x53706374
01403 #define BN_CK_TABLE(_p) BU_CKMAG(_p, BN_TABLE_MAGIC, "bn_table")
01404 #define BN_TABLE_NULL ((struct bn_table *)NULL)
01405
01406
01407 #ifndef NO_BOMBING_MACROS
01408 # define BN_GET_TABLE(_table, _nx) { \
01409 if( (_nx) < 1 ) bu_bomb("RT_GET_TABLE() _nx < 1\n"); \
01410 _table = (struct bn_table *)bu_calloc( 1, \
01411 sizeof(struct bn_table) + sizeof(fastf_t)*(_nx), \
01412 "struct bn_table" ); \
01413 _table->magic = BN_TABLE_MAGIC; \
01414 _table->nx = (_nx); }
01415 #else
01416 # define BN_GET_TABLE(_table, _nx) { \
01417 _table = (struct bn_table *)bu_calloc( 1, \
01418 sizeof(struct bn_table) + sizeof(fastf_t)*(_nx), \
01419 "struct bn_table" ); \
01420 _table->magic = BN_TABLE_MAGIC; \
01421 _table->nx = (_nx); }
01422 #endif
01423
01424 struct bn_tabdata {
01425 long magic;
01426 int ny;
01427 const struct bn_table *table;
01428 fastf_t y[1];
01429 };
01430 #define BN_TABDATA_MAGIC 0x53736d70
01431 #define BN_CK_TABDATA(_p) BU_CKMAG(_p, BN_TABDATA_MAGIC, "bn_tabdata")
01432 #define BN_TABDATA_NULL ((struct bn_tabdata *)NULL)
01433
01434 #define BN_SIZEOF_TABDATA_Y(_tabdata) sizeof(fastf_t)*((_tabdata)->ny)
01435 #define BN_SIZEOF_TABDATA(_table) ( sizeof(struct bn_tabdata) + \
01436 sizeof(fastf_t)*((_table)->nx-1))
01437
01438
01439 #define BN_GET_TABDATA(_data, _table) { \
01440 BN_CK_TABLE(_table);\
01441 _data = (struct bn_tabdata *)bu_calloc( 1, \
01442 BN_SIZEOF_TABDATA(_table), "struct bn_tabdata" ); \
01443 _data->magic = BN_TABDATA_MAGIC; \
01444 _data->ny = (_table)->nx; \
01445 _data->table = (_table); }
01446
01447
01448
01449
01450
01451 BN_EXPORT BU_EXTERN(void bn_table_free,
01452 (struct bn_table *tabp));
01453 BN_EXPORT BU_EXTERN(void bn_tabdata_free,
01454 (struct bn_tabdata *data));
01455 BN_EXPORT BU_EXTERN(void bn_ck_table,
01456 (const struct bn_table *tabp));
01457 BN_EXPORT BU_EXTERN(struct bn_table *bn_table_make_uniform,
01458 (int num,
01459 double first,
01460 double last));
01461 BN_EXPORT BU_EXTERN(void bn_tabdata_add,
01462 (struct bn_tabdata *out,
01463 const struct bn_tabdata *in1,
01464 const struct bn_tabdata *in2));
01465 BN_EXPORT BU_EXTERN(void bn_tabdata_mul,
01466 (struct bn_tabdata *out,
01467 const struct bn_tabdata *in1,
01468 const struct bn_tabdata *in2));
01469 BN_EXPORT BU_EXTERN(void bn_tabdata_mul3,
01470 (struct bn_tabdata *out,
01471 const struct bn_tabdata *in1,
01472 const struct bn_tabdata *in2,
01473 const struct bn_tabdata *in3));
01474 BN_EXPORT BU_EXTERN(void bn_tabdata_incr_mul3_scale,
01475 (struct bn_tabdata *out,
01476 const struct bn_tabdata *in1,
01477 const struct bn_tabdata *in2,
01478 const struct bn_tabdata *in3,
01479 double scale));
01480 BN_EXPORT BU_EXTERN(void bn_tabdata_incr_mul2_scale,
01481 (struct bn_tabdata *out,
01482 const struct bn_tabdata *in1,
01483 const struct bn_tabdata *in2,
01484 double scale));
01485 BN_EXPORT BU_EXTERN(void bn_tabdata_scale,
01486 (struct bn_tabdata *out,
01487 const struct bn_tabdata *in1,
01488 double scale));
01489 BN_EXPORT BU_EXTERN(void bn_table_scale,
01490 (struct bn_table *tabp,
01491 double scale));
01492 BN_EXPORT BU_EXTERN(void bn_tabdata_join1,
01493 (struct bn_tabdata *out,
01494 const struct bn_tabdata *in1,
01495 double scale,
01496 const struct bn_tabdata *in2));
01497 BN_EXPORT BU_EXTERN(void bn_tabdata_join2,
01498 (struct bn_tabdata *out,
01499 const struct bn_tabdata *in1,
01500 double scale2,
01501 const struct bn_tabdata *in2,
01502 double scale3,
01503 const struct bn_tabdata *in3));
01504 BN_EXPORT BU_EXTERN(void bn_tabdata_blend2,
01505 (struct bn_tabdata *out,
01506 double scale1,
01507 const struct bn_tabdata *in1,
01508 double scale2,
01509 const struct bn_tabdata *in2));
01510 BN_EXPORT BU_EXTERN(void bn_tabdata_blend3,
01511 (struct bn_tabdata *out,
01512 double scale1,
01513 const struct bn_tabdata *in1,
01514 double scale2,
01515 const struct bn_tabdata *in2,
01516 double scale3,
01517 const struct bn_tabdata *in3));
01518 BN_EXPORT BU_EXTERN(double bn_tabdata_area1,
01519 (const struct bn_tabdata *in));
01520 BN_EXPORT BU_EXTERN(double bn_tabdata_area2,
01521 (const struct bn_tabdata *in));
01522 BN_EXPORT BU_EXTERN(double bn_tabdata_mul_area1,
01523 (const struct bn_tabdata *in1,
01524 const struct bn_tabdata *in2));
01525 BN_EXPORT BU_EXTERN(double bn_tabdata_mul_area2,
01526 (const struct bn_tabdata *in1,
01527 const struct bn_tabdata *in2));
01528 BN_EXPORT BU_EXTERN(fastf_t bn_table_lin_interp,
01529 (const struct bn_tabdata *samp,
01530 double wl));
01531 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_resample_max,
01532 (const struct bn_table *newtable,
01533 const struct bn_tabdata *olddata));
01534 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_resample_avg,
01535 (const struct bn_table *newtable,
01536 const struct bn_tabdata *olddata));
01537 BN_EXPORT BU_EXTERN(int bn_table_write,
01538 (const char *filename,
01539 const struct bn_table *tabp));
01540 BN_EXPORT BU_EXTERN(struct bn_table *bn_table_read,
01541 (const char *filename));
01542 BN_EXPORT BU_EXTERN(void bn_pr_table,
01543 (const char *title,
01544 const struct bn_table *tabp));
01545 BN_EXPORT BU_EXTERN(void bn_pr_tabdata,
01546 (const char *title,
01547 const struct bn_tabdata *data));
01548 BN_EXPORT BU_EXTERN(int bn_print_table_and_tabdata,
01549 (const char *filename,
01550 const struct bn_tabdata *data));
01551 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_read_table_and_tabdata,
01552 (const char *filename));
01553 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_binary_read,
01554 (const char *filename,
01555 int num,
01556 const struct bn_table *tabp));
01557 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_malloc_array,
01558 (const struct bn_table *tabp,
01559 int num));
01560 BN_EXPORT BU_EXTERN(void bn_tabdata_copy,
01561 (struct bn_tabdata *out,
01562 const struct bn_tabdata *in));
01563 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_dup,
01564 (const struct bn_tabdata *in));
01565 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_get_constval,
01566 (double val,
01567 const struct bn_table *tabp));
01568 BN_EXPORT BU_EXTERN(void bn_tabdata_constval,
01569 (struct bn_tabdata *data,
01570 double val));
01571 BN_EXPORT BU_EXTERN(void bn_tabdata_to_tcl,
01572 (struct bu_vls *vp,
01573 const struct bn_tabdata *data));
01574 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_from_array,
01575 (const double *array));
01576 BN_EXPORT BU_EXTERN(void bn_tabdata_freq_shift,
01577 (struct bn_tabdata *out,
01578 const struct bn_tabdata *in,
01579 double offset));
01580 BN_EXPORT BU_EXTERN(int bn_table_interval_num_samples,
01581 (const struct bn_table *tabp,
01582 double low,
01583 double hi));
01584 BN_EXPORT BU_EXTERN(int bn_table_delete_sample_pts,
01585 (struct bn_table *tabp,
01586 int i,
01587 int j));
01588 BN_EXPORT BU_EXTERN(struct bn_table *bn_table_merge2,
01589 (const struct bn_table *a,
01590 const struct bn_table *b));
01591 BN_EXPORT BU_EXTERN(struct bn_tabdata *bn_tabdata_mk_linear_filter,
01592 (const struct bn_table *spectrum,
01593 double lower_wavelen,
01594 double upper_wavelen));
01595
01596
01597
01598 #define BN_VLIST_CHUNK 35
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624 struct bn_vlist {
01625 struct bu_list l;
01626 int nused;
01627 int cmd[BN_VLIST_CHUNK];
01628 point_t pt[BN_VLIST_CHUNK];
01629 };
01630 #define BN_VLIST_NULL ((struct bn_vlist *)0)
01631 #define BN_VLIST_MAGIC 0x98237474
01632 #define BN_CK_VLIST(_p) BU_CKMAG((_p), BN_VLIST_MAGIC, "bn_vlist")
01633 #define BN_CK_VLIST_TCL(_interp,_p) BU_CKMAG_TCL(_interp,(_p), BN_VLIST_MAGIC, "bn_vlist")
01634
01635
01636 #define BN_VLIST_LINE_MOVE 0
01637 #define BN_VLIST_LINE_DRAW 1
01638 #define BN_VLIST_POLY_START 2
01639 #define BN_VLIST_POLY_MOVE 3
01640 #define BN_VLIST_POLY_DRAW 4
01641 #define BN_VLIST_POLY_END 5
01642 #define BN_VLIST_POLY_VERTNORM 6
01643
01644
01645
01646
01647
01648
01649
01650
01651 #define BN_GET_VLIST(_free_hd,p) {\
01652 (p) = BU_LIST_FIRST( bn_vlist, (_free_hd) ); \
01653 if( BU_LIST_IS_HEAD( (p), (_free_hd) ) ) { \
01654 (p) = (struct bn_vlist *)bu_malloc(sizeof(struct bn_vlist), "bn_vlist"); \
01655 (p)->l.magic = BN_VLIST_MAGIC; \
01656 } else { \
01657 BU_LIST_DEQUEUE( &((p)->l) ); \
01658 } \
01659 (p)->nused = 0; \
01660 }
01661
01662
01663 #define BN_FREE_VLIST(_free_hd,hd) { \
01664 BU_CK_LIST_HEAD( (hd) ); \
01665 BU_LIST_APPEND_LIST( (_free_hd), (hd) ); \
01666 }
01667
01668 #define BN_ADD_VLIST(_free_hd,_dest_hd,pnt,draw) { \
01669 register struct bn_vlist *_vp; \
01670 BU_CK_LIST_HEAD( _dest_hd ); \
01671 _vp = BU_LIST_LAST( bn_vlist, (_dest_hd) ); \
01672 if( BU_LIST_IS_HEAD( _vp, (_dest_hd) ) || _vp->nused >= BN_VLIST_CHUNK ) { \
01673 BN_GET_VLIST(_free_hd, _vp); \
01674 BU_LIST_INSERT( (_dest_hd), &(_vp->l) ); \
01675 } \
01676 VMOVE( _vp->pt[_vp->nused], (pnt) ); \
01677 _vp->cmd[_vp->nused++] = (draw); \
01678 }
01679
01680
01681
01682
01683
01684
01685
01686 struct bn_vlblock {
01687 long magic;
01688 int nused;
01689 int max;
01690 long *rgb;
01691 struct bu_list *head;
01692 struct bu_list *free_vlist_hd;
01693 };
01694 #define BN_VLBLOCK_MAGIC 0x981bd112
01695 #define BN_CK_VLBLOCK(_p) BU_CKMAG((_p), BN_VLBLOCK_MAGIC, "bn_vlblock")
01696
01697 BN_EXPORT BU_EXTERN(void bn_vlist_3string,
01698 (struct bu_list *vhead,
01699 struct bu_list *free_hd,
01700 const char *string,
01701 const point_t origin,
01702 const mat_t rot,
01703 double scale));
01704 BN_EXPORT BU_EXTERN(void bn_vlist_2string,
01705 (struct bu_list *vhead,
01706 struct bu_list *free_hd,
01707 const char *string,
01708 double x,
01709 double y,
01710 double scale,
01711 double theta));
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723 struct vert_root {
01724 long magic;
01725 int tree_type;
01726 union vert_tree *the_tree;
01727 fastf_t *the_array;
01728 unsigned long curr_vert;
01729 unsigned long max_vert;
01730 };
01731
01732 #define TREE_TYPE_VERTS 1
01733 #define TREE_TYPE_VERTS_AND_NORMS 2
01734
01735 #define VERT_BLOCK 512
01736
01737 #define VERT_TREE_MAGIC 0x56455254
01738 #define BN_CK_VERT_TREE(_p) BU_CKMAG(_p, VERT_TREE_MAGIC, "vert_tree")
01739
01740 BN_EXPORT BU_EXTERN(struct vert_root *create_vert_tree,
01741 ());
01742 BN_EXPORT BU_EXTERN(struct vert_root *create_vert_tree_w_norms,
01743 ());
01744 BN_EXPORT BU_EXTERN(void free_vert_tree,
01745 (struct vert_root *tree_root));
01746 BN_EXPORT BU_EXTERN(int Add_vert,
01747 (double x,
01748 double y,
01749 double z,
01750 struct vert_root *tree_root,
01751 fastf_t local_tol_sq));
01752 BN_EXPORT BU_EXTERN(int Add_vert_and_norm,
01753 (double x,
01754 double y,
01755 double z,
01756 double nx,
01757 double ny,
01758 double nz,
01759 struct vert_root *tree_root,
01760 fastf_t local_tol_sq));
01761 BN_EXPORT BU_EXTERN(void clean_vert_tree,
01762 (struct vert_root *tree_root));
01763
01764
01765
01766 BN_EXPORT BU_EXTERN(void tp_setup,
01767 ());
01768
01769
01770
01771
01772 BN_EXPORT extern const char bn_version[];
01773
01774
01775 __END_DECLS
01776
01777 #endif
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788