Revision: 41060
http://brlcad.svn.sourceforge.net/brlcad/?rev=41060&view=rev
Author: brlcad
Date: 2010-10-18 21:24:09 +0000 (Mon, 18 Oct 2010)
Log Message:
-----------
quell verbose compilation warnings, reorder to eliminate forward decls
Modified Paths:
--------------
brlcad/trunk/src/anim/anim_cascade.c
brlcad/trunk/src/anim/anim_fly.c
brlcad/trunk/src/anim/anim_hardtrack.c
brlcad/trunk/src/anim/anim_lookat.c
brlcad/trunk/src/anim/anim_track.c
brlcad/trunk/src/anim/anim_turn.c
brlcad/trunk/src/anim/cattrack.c
brlcad/trunk/src/anim/cattrack.h
Modified: brlcad/trunk/src/anim/anim_cascade.c
===================================================================
--- brlcad/trunk/src/anim/anim_cascade.c 2010-10-18 21:16:50 UTC (rev
41059)
+++ brlcad/trunk/src/anim/anim_cascade.c 2010-10-18 21:24:09 UTC (rev
41060)
@@ -161,7 +161,7 @@
main (int argc, char *argv[])
{
int val;
- fastf_t time, yaw1, pitch1, roll1, yaw2, pitch2, roll2;
+ fastf_t elapsed, yaw1, pitch1, roll1, yaw2, pitch2, roll2;
vect_t cen1, cen2, cen_ans, ang_ans, rad_ang_ans, rotated;
mat_t m_rot1, m_rot2, m_ans;
int one_time, read_cen1, read_cen2, read_rot1, read_rot2;
@@ -233,12 +233,12 @@
one_time = (!(read_cen1||read_cen2||read_rot1||read_rot2));
read_time = one_time ? 0 : print_time;
- time = 0.0;
+ elapsed = 0.0;
val = 3;
while (1) {
if (read_time) {
- val=scanf("%lf", &time);
+ val=scanf("%lf", &elapsed);
if (val < 1) break;
}
if (read_cen1)
@@ -275,7 +275,7 @@
VSCALE(ang_ans, rad_ang_ans, RAD2DEG);
if (print_time) {
- printf("%g", time);
+ printf("%g", elapsed);
}
printf("\t%.12g\t%.12g\t%.12g", cen_ans[0], cen_ans[1], cen_ans[2]);
printf("\t%.12g\t%.12g\t%.12g", ang_ans[0], ang_ans[1], ang_ans[2]);
Modified: brlcad/trunk/src/anim/anim_fly.c
===================================================================
--- brlcad/trunk/src/anim/anim_fly.c 2010-10-18 21:16:50 UTC (rev 41059)
+++ brlcad/trunk/src/anim/anim_fly.c 2010-10-18 21:24:09 UTC (rev 41060)
@@ -59,14 +59,150 @@
#define END 3
#define STOP 4
+/* determine the yaw of the given direction vector */
+fastf_t xyz2yaw(fastf_t *d)
+{
+ fastf_t yaw;
+ yaw = RAD2DEG*atan2(d[1], d[0]);
+ if (yaw < 0.0) yaw += 360.0;
+ return yaw;
+}
+
+/* determine the pitch of the given direction vector */
+fastf_t xyz2pch(fastf_t *d)
+{
+ fastf_t x;
+ x = sqrt(d[0]*d[0] + d[1]*d[1]);
+ return (RAD2DEG*atan2(d[2], x));
+
+}
+
+/* given the 3-d velocity and acceleration of an imaginary aircraft,
+ find the amount of bank the aircraft would need to undergo.
+ Algorithm: the bank angle is proportional to the cross product
+ of the horizontal velocity and horizontal acceleration, up to a
+ maximum bank of 90 degrees in either direction. */
+fastf_t bank(fastf_t *acc, fastf_t *vel)
+{
+ fastf_t cross;
+
+ cross = vel[1]*acc[0] - vel[0]*acc[1];
+
+ if (estimate_f) {
+ max_cross = ( fabs(cross) > max_cross) ? fabs(cross) : max_cross;
+ }
+
+ cross *= magic_factor;
+
+ if (cross > 90) cross = 90;
+ if (cross < -90) cross = -90;
+ return cross;
+}
+
+
+/* given f(t), f(t+h), f(t+2*h), and h, calculate f'' */
+fastf_t f_double_prm(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h)
+{
+ return (x0 - 2.0*x1 + x2)/(h*h);
+}
+
+
+void
+get_orientation(fastf_t *p0, fastf_t *p1, fastf_t *p2, fastf_t (*function) (/*
??? */), fastf_t *p_yaw, fastf_t *p_pch, fastf_t *p_rll)
+{
+ int i;
+ fastf_t step, vel[3], accel[3];
+
+ static fastf_t last_yaw;
+ static int not_first_time, upside_down;
+
+ step = p2[0] - p1[0];
+ for (i=1;i<4;i++) {
+ vel[i-1] = (*function)(p0[i], p1[i], p2[i], step);
+ accel[i-1] = f_double_prm(p0[i], p1[i], p2[i], step);
+ }
+ *p_yaw = xyz2yaw(vel);
+ *p_pch = xyz2pch(vel);
+ *p_rll = bank(accel, vel);
+
+ if (NEAR_ZERO(fabs(*p_pch) - 90.0, SMALL_FASTF)) /* don't change yaw if
velocity vertical */
+ *p_yaw = last_yaw;
+
+ /* avoid sudden yaw changes in vertical loops */
+ if (not_first_time&&loop) {
+ if ((fabs(last_yaw - *p_yaw)<181.0)&&(fabs(last_yaw - *p_yaw)>179.0))
+ upside_down = (upside_down) ? 0 : 1;
+ if (upside_down)
+ (*p_rll) += 180;
+ }
+
+ last_yaw = *p_yaw;
+ not_first_time = 1;
+}
+
+
+/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t) */
+fastf_t f_prm_0(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h)
+{
+ return -(3.0*x0 - 4.0*x1 + x2)/(2*h);
+}
+
+
+/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+h) */
+fastf_t f_prm_1(fastf_t x0, fastf_t UNUSED(x1), fastf_t x2, fastf_t h)
+{
+ return (x2 - x0)/(2*h);
+}
+
+
+/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+2h) */
+fastf_t f_prm_2(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h)
+{
+ return (x0 - 4.0*x1 + 3.0*x2)/(2*h);
+}
+
+
+/* code to read command line arguments*/
+#define OPT_STR "b:f:p:s:r"
+int get_args(int argc, char **argv)
+{
+ int c;
+
+ estimate_f = 0;
+ while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ switch (c) {
+ case 'b':
+ sscanf(bu_optarg, "%lf", &max_bank);
+ estimate_f = 1;
+ break;
+ case 'f':
+ sscanf(bu_optarg, "%lf", &magic_factor);
+ magic_factor *= 0.001; /* to put factors in a more reasonable
range */
+ break;
+ case 'p':
+ sscanf(bu_optarg, "%d", &print_int);
+ break;
+ case 'r':
+ loop = 0;
+ break;
+ case 's':
+ sscanf(bu_optarg, "%lf", &desired_step);
+ break;
+ default:
+ fprintf(stderr, "Unknown option: -%c\n", c);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+
int
main(int argc, char **argv)
{
int count, status, num_read, enn, i, pp;
fastf_t *points, *cur;
fastf_t yaw, pch, rll, stepsize, first[4], second[4];
- fastf_t f_prm_0(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h),
f_prm_1(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h), f_prm_2(fastf_t x0,
fastf_t x1, fastf_t x2, fastf_t h);
- void get_orientation(fastf_t *p0, fastf_t *p1, fastf_t *p2, fastf_t
(*function) (/* ??? */), fastf_t *p_yaw, fastf_t *p_pch, fastf_t *p_rll);
yaw = pch = rll = 0.0;
@@ -171,141 +307,7 @@
return 0;
}
-void
-get_orientation(fastf_t *p0, fastf_t *p1, fastf_t *p2, fastf_t (*function) (/*
??? */), fastf_t *p_yaw, fastf_t *p_pch, fastf_t *p_rll)
-{
- int i;
- fastf_t step, vel[3], accel[3];
- fastf_t f_double_prm(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h),
xyz2yaw(fastf_t *d), xyz2pch(fastf_t *d), bank(fastf_t *acc, fastf_t *vel);
- static fastf_t last_yaw;
- static int not_first_time, upside_down;
-
- step = p2[0] - p1[0];
- for (i=1;i<4;i++) {
- vel[i-1] = (*function)(p0[i], p1[i], p2[i], step);
- accel[i-1] = f_double_prm(p0[i], p1[i], p2[i], step);
- }
- *p_yaw = xyz2yaw(vel);
- *p_pch = xyz2pch(vel);
- *p_rll = bank(accel, vel);
-
- if (fabs(*p_pch)==90.0) /* don't change yaw if velocity vertical */
- *p_yaw = last_yaw;
-
- /* avoid sudden yaw changes in vertical loops */
- if (not_first_time&&loop) {
- if ((fabs(last_yaw - *p_yaw)<181.0)&&(fabs(last_yaw - *p_yaw)>179.0))
- upside_down = (upside_down) ? 0 : 1;
- if (upside_down)
- (*p_rll) += 180;
- }
-
- last_yaw = *p_yaw;
- not_first_time = 1;
-}
-
-/* determine the yaw of the given direction vector */
-fastf_t xyz2yaw(fastf_t *d)
-{
- fastf_t yaw;
- yaw = RAD2DEG*atan2(d[1], d[0]);
- if (yaw < 0.0) yaw += 360.0;
- return yaw;
-}
-
-/* determine the pitch of the given direction vector */
-fastf_t xyz2pch(fastf_t *d)
-{
- fastf_t x;
- x = sqrt(d[0]*d[0] + d[1]*d[1]);
- return (RAD2DEG*atan2(d[2], x));
-
-}
-
-/* given the 3-d velocity and acceleration of an imaginary aircraft,
- find the amount of bank the aircraft would need to undergo.
- Algorithm: the bank angle is proportional to the cross product
- of the horizontal velocity and horizontal acceleration, up to a
- maximum bank of 90 degrees in either direction. */
-fastf_t bank(fastf_t *acc, fastf_t *vel)
-{
- fastf_t cross;
-
- cross = vel[1]*acc[0] - vel[0]*acc[1];
-
- if (estimate_f) {
- max_cross = ( fabs(cross) > max_cross) ? fabs(cross) : max_cross;
- }
-
- cross *= magic_factor;
-
- if (cross > 90) cross = 90;
- if (cross < -90) cross = -90;
- return cross;
-}
-
-/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t) */
-fastf_t f_prm_0(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h)
-{
- return -(3.0*x0 - 4.0*x1 + x2)/(2*h);
-}
-
-/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+h) */
-fastf_t f_prm_1(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h)
-{
- return (x2 - x0)/(2*h);
-}
-
-/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+2h) */
-fastf_t f_prm_2(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h)
-{
- return (x0 - 4.0*x1 + 3.0*x2)/(2*h);
-}
-
-
-/* given f(t), f(t+h), f(t+2*h), and h, calculate f'' */
-fastf_t f_double_prm(fastf_t x0, fastf_t x1, fastf_t x2, fastf_t h)
-{
- return (x0 - 2.0*x1 + x2)/(h*h);
-}
-
-
-/* code to read command line arguments*/
-#define OPT_STR "b:f:p:s:r"
-int get_args(int argc, char **argv)
-{
- int c;
-
- estimate_f = 0;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
- switch (c) {
- case 'b':
- sscanf(bu_optarg, "%lf", &max_bank);
- estimate_f = 1;
- break;
- case 'f':
- sscanf(bu_optarg, "%lf", &magic_factor);
- magic_factor *= 0.001; /* to put factors in a more reasonable
range */
- break;
- case 'p':
- sscanf(bu_optarg, "%d", &print_int);
- break;
- case 'r':
- loop = 0;
- break;
- case 's':
- sscanf(bu_optarg, "%lf", &desired_step);
- break;
- default:
- fprintf(stderr, "Unknown option: -%c\n", c);
- return 0;
- }
- }
- return 1;
-}
-
-
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/anim/anim_hardtrack.c
===================================================================
--- brlcad/trunk/src/anim/anim_hardtrack.c 2010-10-18 21:16:50 UTC (rev
41059)
+++ brlcad/trunk/src/anim/anim_hardtrack.c 2010-10-18 21:24:09 UTC (rev
41060)
@@ -336,7 +336,7 @@
return 0;
}
num_wheels = -1;
- if (radius) {
+ if (!NEAR_ZERO(radius, SMALL_FASTF)) {
while (!feof(stream)) {
fscanf(stream, "%*f %*f %*f");
num_wheels++;
@@ -354,7 +354,7 @@
/*read rest of track info */
for (i=0;i<NW;i++) {
fscanf(stream, "%lf %lf %lf", temp, temp+1, temp+2);
- if (radius)
+ if (!NEAR_ZERO(radius, SMALL_FASTF))
x[i].w.rad = radius;
else
fscanf(stream, "%lf", & x[i].w.rad);
Modified: brlcad/trunk/src/anim/anim_lookat.c
===================================================================
--- brlcad/trunk/src/anim/anim_lookat.c 2010-10-18 21:16:50 UTC (rev 41059)
+++ brlcad/trunk/src/anim/anim_lookat.c 2010-10-18 21:24:09 UTC (rev 41060)
@@ -79,7 +79,7 @@
int
main(int argc, char *argv[])
{
- fastf_t time, vsize=0.0;
+ fastf_t t /* time */, vsize=0.0;
vect_t eye, look, dir, angles, norm, temp;
quat_t quat;
mat_t mat;
@@ -93,7 +93,7 @@
VSET(norm, 0.0, 1.0, 0.0);
while (!feof(stdin)) {
- val=scanf("%lf %lf %lf %lf %lf %lf %lf", &time, eye, eye+1, eye+2,
look, look+1, look+2);
+ val=scanf("%lf %lf %lf %lf %lf %lf %lf", &t, eye, eye+1, eye+2, look,
look+1, look+2);
if (val < 7) {
break;
}
@@ -125,7 +125,7 @@
angles[0] *= RAD2DEG;
angles[1] *= RAD2DEG;
angles[2] *= RAD2DEG;
- printf("%.10g", time);
+ printf("%.10g", t);
if (print_viewsize)
printf("\t%.10g", vsize);
printf("\t%.10g\t%.10g\t%.10g", eye[0], eye[1], eye[2]);
@@ -133,7 +133,7 @@
break;
case LOOKAT_QUAT:
anim_mat2quat(quat, mat);
- printf("%.10g", time);
+ printf("%.10g", t);
if (print_viewsize)
printf("\t%.10g", vsize);
printf("\t%.10g\t%.10g\t%.10g", eye[0], eye[1], eye[2]);
Modified: brlcad/trunk/src/anim/anim_track.c
===================================================================
--- brlcad/trunk/src/anim/anim_track.c 2010-10-18 21:16:50 UTC (rev 41059)
+++ brlcad/trunk/src/anim/anim_track.c 2010-10-18 21:24:09 UTC (rev 41060)
@@ -403,7 +403,7 @@
/* caternary section */
if ( curve_a > VDIVIDE_TOL) {
- pos[X] = hyper_get_x(curve_a, 0.0, s_start+dist, 0, 0, 0);
+ pos[X] = hyper_get_x(curve_a, 0.0, s_start+dist);
pos[Y] = x[0].w.pos[Y];
pos[Z] = hyper_get_z(curve_a, curve_b, 0.0, pos[X]);
pos[X] += curve_c;
Modified: brlcad/trunk/src/anim/anim_turn.c
===================================================================
--- brlcad/trunk/src/anim/anim_turn.c 2010-10-18 21:16:50 UTC (rev 41059)
+++ brlcad/trunk/src/anim/anim_turn.c 2010-10-18 21:24:09 UTC (rev 41060)
@@ -87,7 +87,7 @@
main(int argc, char *argv[])
{
int count;
- fastf_t val, time, roll_ang, yaw, sign;
+ fastf_t val, t /* time */, roll_ang, yaw, sign;
vect_t v, point, front, back, zero, temp1, temp2;
mat_t m_from_world, m_to_world;
@@ -118,7 +118,7 @@
count = 0;
while (1) {
/* read one line of table */
- val = scanf("%lf%*[^-0123456789]", &time); /*read time, ignore garbage*/
+ val = scanf("%lf%*[^-0123456789]", &t); /*read time, ignore garbage*/
val = scanf("%lf %lf %lf", point, point+1, point +2);
if (val < 3) {
break;
@@ -170,12 +170,12 @@
roll_ang -= sign * MAGNITUDE(v) / radius;
if (!(count%print_int))
- printf("%.10g %.10g %.10g 0.0\n", time, factor*RAD2DEG*yaw,
RAD2DEG*roll_ang);
+ printf("%.10g %.10g %.10g 0.0\n", t, factor*RAD2DEG*yaw,
RAD2DEG*roll_ang);
}
else {
/* print position and orientation of vehicle */
if (!(count%print_int))
- printf("%.10g %.10g %.10g %.10g %.10g 0.0 0.0\n", time,
front[0], front[1], front[2], RAD2DEG * angle);
+ printf("%.10g %.10g %.10g %.10g %.10g 0.0 0.0\n", t, front[0],
front[1], front[2], RAD2DEG * angle);
}
count++;
}
Modified: brlcad/trunk/src/anim/cattrack.c
===================================================================
--- brlcad/trunk/src/anim/cattrack.c 2010-10-18 21:16:50 UTC (rev 41059)
+++ brlcad/trunk/src/anim/cattrack.c 2010-10-18 21:24:09 UTC (rev 41060)
@@ -51,9 +51,7 @@
fastf_t
-hyper_get_x(fastf_t a, fastf_t c, fastf_t s, int d, int x, int cos_ang)
- /* curve parameters */
- /* arclength value */
+hyper_get_x(fastf_t a, fastf_t c, fastf_t s)
{
fastf_t arg, asinh_arg;
Modified: brlcad/trunk/src/anim/cattrack.h
===================================================================
--- brlcad/trunk/src/anim/cattrack.h 2010-10-18 21:16:50 UTC (rev 41059)
+++ brlcad/trunk/src/anim/cattrack.h 2010-10-18 21:24:09 UTC (rev 41060)
@@ -34,7 +34,7 @@
*
* Left to calling routine to avoid dividing by zero.
*/
-fastf_t hyper_get_x(fastf_t a, fastf_t c, fastf_t s, int d, int x, int
cos_ang);
+fastf_t hyper_get_x(fastf_t a, fastf_t c, fastf_t s);
/**
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits