Revision: 41061
http://brlcad.svn.sourceforge.net/brlcad/?rev=41061&view=rev
Author: brlcad
Date: 2010-10-18 21:45:15 +0000 (Mon, 18 Oct 2010)
Log Message:
-----------
more restructuring and cleanup including ws/style consistency cleanup along
with forward decl elimination and comment restructuring.
Modified Paths:
--------------
brlcad/trunk/src/anim/Makefile.am
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_keyread.c
brlcad/trunk/src/anim/anim_lookat.c
brlcad/trunk/src/anim/anim_offset.c
brlcad/trunk/src/anim/anim_orient.c
brlcad/trunk/src/anim/anim_script.c
brlcad/trunk/src/anim/anim_sort.c
brlcad/trunk/src/anim/anim_time.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/chan_add.c
brlcad/trunk/src/anim/chan_mult.c
brlcad/trunk/src/anim/chan_permute.c
Modified: brlcad/trunk/src/anim/Makefile.am
===================================================================
--- brlcad/trunk/src/anim/Makefile.am 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/Makefile.am 2010-10-18 21:45:15 UTC (rev 41061)
@@ -17,7 +17,7 @@
chan_permute
AM_CPPFLAGS = ${TCL_CPPFLAGS}
-# AM_CFLAGS = ${STRICT_FLAGS}
+AM_CFLAGS = ${STRICT_FLAGS}
anim_cascade_SOURCES = anim_cascade.c
anim_cascade_LDADD = ${BN}
Modified: brlcad/trunk/src/anim/anim_cascade.c
===================================================================
--- brlcad/trunk/src/anim/anim_cascade.c 2010-10-18 21:24:09 UTC (rev
41060)
+++ brlcad/trunk/src/anim/anim_cascade.c 2010-10-18 21:45:15 UTC (rev
41061)
@@ -19,25 +19,27 @@
*
*/
/** @file anim_cascade.c
- * Purpose: Given position and orientation of main frame of reference,
+ *
+ * Purpose: Given position and orientation of main frame of reference,
* along with the position and orientation of another frame with respect
* to the main frame, give the absolute orientation and position of the
* second frame.
- * For example, given the position and orientation of a tank, and of the
- * turret relative to the tank, you can get the absolute position and
- * orientation of the turret at each time.
- * Or, optionally, given position and orientation of main frame of
- * reference, and the absolute position and orientation of another frame,
- * find the position and orientation of the second frame in terms of the main
+ *
+ * For example, given the position and orientation of a tank, and of
+ * the turret relative to the tank, you can get the absolute position
+ * and orientation of the turret at each time. Or, optionally, given
+ * position and orientation of main frame of reference, and the
+ * absolute position and orientation of another frame, find the
+ * position and orientation of the second frame in terms of the main
* frame of reference. (-i option).
*
- * Usage:
- * anim_cascade main.table < relative.table > absolute.table
+ * Usage: anim_cascade main.table < relative.table > absolute.table
*
- * The format of the tables is:
- * time x y z yaw pitch roll
- * unless specified otherwise by options.
+ * Unless specified otherwise by options, the format of the table file
+ * is in the space-delimited form:
*
+ * time x y z yaw pitch roll
+ *
*/
#include "common.h"
@@ -53,9 +55,9 @@
#define OPT_STR "so:f:r:a:"
-#define CASCADE_A 0
-#define CASCADE_R 1
-#define CASCADE_F 2
+#define CASCADE_A 0
+#define CASCADE_R 1
+#define CASCADE_F 2
vect_t fcenter, fypr, rcenter, rypr, acenter, aypr;
@@ -70,7 +72,7 @@
output_mode = CASCADE_A;
cmd_fcen = cmd_fypr = cmd_rcen = cmd_rypr = cmd_acen = cmd_aypr = 0;
print_time = 1;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
switch (c) {
case 'f':
d = *(bu_optarg);
@@ -81,7 +83,7 @@
bu_optind += 3;
cmd_fcen = 1;
break;
- } else if ( d =='y') {
+ } else if (d =='y') {
sscanf(argv[bu_optind], "%lf", fypr+0);
sscanf(argv[bu_optind+1], "%lf", fypr+1);
sscanf(argv[bu_optind+2], "%lf", fypr+2);
@@ -101,7 +103,7 @@
bu_optind += 3;
cmd_rcen = 1;
break;
- } else if ( d =='y') {
+ } else if (d =='y') {
sscanf(argv[bu_optind], "%lf", rypr+0);
sscanf(argv[bu_optind+1], "%lf", rypr+1);
sscanf(argv[bu_optind+2], "%lf", rypr+2);
@@ -121,7 +123,7 @@
bu_optind += 3;
cmd_acen = 1;
break;
- } else if ( d =='y') {
+ } else if (d =='y') {
sscanf(argv[bu_optind], "%lf", aypr+0);
sscanf(argv[bu_optind+1], "%lf", aypr+1);
sscanf(argv[bu_optind+2], "%lf", aypr+2);
Modified: brlcad/trunk/src/anim/anim_fly.c
===================================================================
--- brlcad/trunk/src/anim/anim_fly.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_fly.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -19,14 +19,15 @@
*
*/
/** @file anim_fly.c
- * Simulate flying motion, for an airplane or virtual camera.
*
- * This filter operates on animation tables. Given the desired position
- * of the airplane in each frame, anim_fly produces a table including the
- * plane's position and orientation. A "magic factor" should be supplied
- * to control the severity of banking. Looping behavior can be toggled
- * with another option.
+ * Simulate flying motion, for an airplane or virtual camera.
*
+ * This filter operates on animation tables. Given the desired
+ * position of the airplane in each frame, anim_fly produces a table
+ * including the plane's position and orientation. A "magic factor"
+ * should be supplied to control the severity of banking. Looping
+ * behavior can be toggled with another option.
+ *
*/
#include "common.h"
@@ -40,8 +41,17 @@
#include "anim.h"
-#define MAXN 100
+#define MAXN 100
+#define OPT_STR "b:f:p:s:r"
+#define PREP -1
+#define START 0
+#define MIDDLE 1
+#define WANE 2
+#define END 3
+#define STOP 4
+
+
int estimate_f = 0;
fastf_t max_bank = 0;
fastf_t max_cross = 0;
@@ -50,17 +60,10 @@
fastf_t magic_factor = 1.0;
fastf_t desired_step = 0.1;
-int get_args(int argc, char **argv);
-#define PREP -1
-#define START 0
-#define MIDDLE 1
-#define WANE 2
-#define END 3
-#define STOP 4
-
/* determine the yaw of the given direction vector */
-fastf_t xyz2yaw(fastf_t *d)
+fastf_t
+xyz2yaw(fastf_t *d)
{
fastf_t yaw;
yaw = RAD2DEG*atan2(d[1], d[0]);
@@ -68,8 +71,10 @@
return yaw;
}
+
/* determine the pitch of the given direction vector */
-fastf_t xyz2pch(fastf_t *d)
+fastf_t
+xyz2pch(fastf_t *d)
{
fastf_t x;
x = sqrt(d[0]*d[0] + d[1]*d[1]);
@@ -77,19 +82,22 @@
}
+
/* 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)
+ * 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;
+ max_cross = (fabs(cross) > max_cross) ? fabs(cross) : max_cross;
}
cross *= magic_factor;
@@ -101,7 +109,8 @@
/* 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)
+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);
}
@@ -142,34 +151,37 @@
/* 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)
+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)
+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)
+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
+get_args(int argc, char **argv)
{
int c;
estimate_f = 0;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
switch (c) {
case 'b':
sscanf(bu_optarg, "%lf", &max_bank);
@@ -198,7 +210,7 @@
int
-main(int argc, char **argv)
+main(int argc, char *argv[])
{
int count, status, num_read, enn, i, pp;
fastf_t *points, *cur;
@@ -215,8 +227,9 @@
scanf("%lf %lf %lf %lf", second, second+1, second+2, second+3);
stepsize = second[0]-first[0];
- /* determine n, the number of points to store ahead and behind
- * the current point. 2n points are stored, minimum enn=2 */
+ /* determine n, the number of points to store ahead and behind the
+ * current point. 2n points are stored, minimum enn=2
+ */
enn = (int) (desired_step/stepsize);
if (enn>MAXN) enn=MAXN;
if (enn<1) enn=1;
Modified: brlcad/trunk/src/anim/anim_hardtrack.c
===================================================================
--- brlcad/trunk/src/anim/anim_hardtrack.c 2010-10-18 21:24:09 UTC (rev
41060)
+++ brlcad/trunk/src/anim/anim_hardtrack.c 2010-10-18 21:45:15 UTC (rev
41061)
@@ -20,8 +20,8 @@
*/
/** @file anim_hardtrack.c
*
- * Animate the links and wheels of a tracked vehicle. It is assumed
- * that the wheels do not translate with respect to the vehicle.
+ * Animate the links and wheels of a tracked vehicle. It is assumed
+ * that the wheels do not translate with respect to the vehicle.
*
*/
@@ -40,51 +40,55 @@
#define OPT_STR "b:d:f:i:l:pr:w:sg:m:c"
-#define NW num_wheels
+#define NW num_wheels
#define NEXT(i) (i+1)%NW
#define PREV(i) (i+NW-1)%NW
-#define TRACK_ANIM 0
-#define TRACK_ARCED 1
+#define TRACK_ANIM 0
+#define TRACK_ARCED 1
typedef double *pdouble;
struct wheel {
- vect_t pos; /* displacement of wheel from vehicle origin */
- fastf_t rad; /* radius of wheel */
- fastf_t ang0; /* angle where track meets wheel; 0 < a < 2pi */
- fastf_t ang1; /* angle where track leaves wheel; 0 < a < 2pi
*/
- fastf_t arc; /* arclength of contact between wheel and track
*/
+ vect_t pos; /* displacement of wheel from vehicle origin */
+ fastf_t rad; /* radius of wheel */
+ fastf_t ang0; /* angle where track meets wheel; 0 < a < 2pi */
+ fastf_t ang1; /* angle where track leaves wheel; 0 < a < 2pi */
+ fastf_t arc; /* arclength of contact between wheel and track */
};
+
struct track {
- vect_t pos0; /* beginning point of track section */
- vect_t pos1; /* end point of track section */
- vect_t dir; /* unit vector: direction of track section */
- fastf_t len; /* length of track section */
+ vect_t pos0; /* beginning point of track section */
+ vect_t pos1; /* end point of track section */
+ vect_t dir; /* unit vector: direction of track section */
+ fastf_t len; /* length of track section */
};
+
struct slope {
- vect_t dir; /* vector from previous to current axle */
- fastf_t len; /* length of vector described above */
+ vect_t dir; /* vector from previous to current axle */
+ fastf_t len; /* length of vector described above */
};
+
struct all {
- struct wheel w; /* parameters describing the track around a
wheel */
- struct track t; /* track between this wheel and the previous
wheel */
- struct slope s; /* vector between this axle and the previous
axle */
+ struct wheel w; /* parameters describing the track around a wheel */
+ struct track t; /* track between this wheel and the previous wheel */
+ struct slope s; /* vector between this axle and the previous axle */
};
+
struct rlink {
- vect_t pos; /* reverse of initial position */
- fastf_t ang; /* initial angle */
+ vect_t pos; /* reverse of initial position */
+ fastf_t ang; /* initial angle */
};
/* variables describing track geometry - used by main, trackprep, get_link */
struct all *x;
-struct rlink *r; /* reverse of initial locations of links */
+struct rlink *r; /* reverse of initial locations of links */
int num_links, num_wheels;
fastf_t track_y, tracklen;
@@ -93,7 +97,7 @@
int link_nindex; /* argv[link_nindex] = linkname*/
int print_wheel; /* flag: do wheel animation */
int print_link; /* flag: do link animation */
-int print_mode; /* anim for rt or arced for mged */
+int print_mode; /* anim for rt or arced for mged */
int arced_frame; /* which frame to arced */
int links_placed; /* flag: links are initially on the track */
int axes, cent; /* flags: alternate axes, centroid specified */
@@ -101,14 +105,15 @@
int first_frame; /* integer with which to begin numbering frames */
fastf_t radius; /* common radius of all wheels */
fastf_t init_dist; /* initial distance of first link along track */
+char link_cmd[10]; /* default is "rarc" */
+char wheel_cmd[10]; /* default is "lmul" */
+int get_circumf; /* flag: just return circumference of track */
vect_t centroid, rcentroid; /* alternate centroid and its reverse */
mat_t m_axes, m_rev_axes; /* matrices to and from alternate axes */
-char link_cmd[10]; /* default is "rarc" */
-char wheel_cmd[10]; /* default is "lmul" */
-int get_circumf; /* flag: just return circumference of track */
-int get_link(fastf_t *pos, fastf_t *angle_p, fastf_t dist)
+int
+get_link(fastf_t *pos, fastf_t *angle_p, fastf_t dist)
{
int i;
vect_t temp;
@@ -117,7 +122,7 @@
while (dist < 0.0)
dist += tracklen;
for (i=0;i<NW;i++) {
- if ( (dist -= x[i].t.len) < 0 ) {
+ if ((dist -= x[i].t.len) < 0) {
VSCALE(temp, (x[i].t.dir), dist);
VADD2(pos, x[i].t.pos1, temp);
*angle_p = atan2(x[i].t.dir[2], x[i].t.dir[0]);
@@ -137,24 +142,24 @@
}
-int get_args(int argc, char **argv)
+int
+get_args(int argc, char **argv)
{
fastf_t yaw, pch, rll;
- void anim_dx_y_z2mat(fastf_t *, double, double, double),
anim_dz_y_x2mat(fastf_t *, double, double, double);
int c, i;
axes = cent = links_placed = print_wheel = print_link = 0;
get_circumf = 0;
print_mode = TRACK_ANIM;
bu_strlcpy(link_cmd, "rarc", sizeof(link_cmd));
bu_strlcpy(wheel_cmd, "lmul", sizeof(wheel_cmd));
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
i=0;
switch (c) {
case 'b':
bu_optind -= 1;
- sscanf(argv[bu_optind+(i++)], "%lf", &yaw );
- sscanf(argv[bu_optind+(i++)], "%lf", &pch );
- sscanf(argv[bu_optind+(i++)], "%lf", &rll );
+ sscanf(argv[bu_optind+(i++)], "%lf", &yaw);
+ sscanf(argv[bu_optind+(i++)], "%lf", &pch);
+ sscanf(argv[bu_optind+(i++)], "%lf", &rll);
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
@@ -225,7 +230,9 @@
}
-int track_prep(void)/*run once at the beginning to establish important track
info*/
+/* run once at the beginning to establish important track info */
+int
+track_prep(void)
{
int i;
fastf_t phi, costheta, link_angle, arc_angle;
@@ -239,7 +246,7 @@
/*calculate end angle of previous wheel - atan2(y, x)*/
phi = atan2(x[i].s.dir[2], x[i].s.dir[0]);/*absolute angle of slope*/
costheta = (x[PREV(i)].w.rad - x[i].w.rad)/x[i].s.len;/*cosine of
special angle*/
- x[PREV(i)].w.ang1 = phi + acos(costheta);
+ x[PREV(i)].w.ang1 = phi + acos(costheta);
while (x[PREV(i)].w.ang1 < 0.0)
x[PREV(i)].w.ang1 += 2.0*M_PI;
x[i].w.ang0 = x[PREV(i)].w.ang1;
@@ -255,8 +262,7 @@
x[i].w.ang0 = 0.5*(x[i].w.ang0 + x[i].w.ang1);
x[i].w.ang1 = x[i].w.ang0;
x[i].w.arc = 0.0;
- }
- else {
+ } else {
/* convex - angles are already correct */
x[i].w.arc = arc_angle;
}
@@ -323,7 +329,7 @@
return -1;
}
- if (axes || cent ) {
+ if (axes || cent) {
/* vehicle has own reference frame */
anim_add_trans(m_axes, centroid, zero);
anim_add_trans(m_rev_axes, zero, rcentroid);
@@ -398,28 +404,24 @@
scanf("%lf %lf %lf", &yaw, &pitch, &roll);
anim_dy_p_r2mat(mat_v, yaw, pitch, roll);
anim_add_trans(mat_v, p3, rcentroid);
- }
- else {
+ } else {
/* analyze positions for steering */
/*get useful direction unit vectors*/
if (frame == first_frame) {
/* first frame*/
VSUBUNIT(dir, p3, p2);
VMOVE(dir2, dir);
- }
- else if (val < 3) {
+ } else if (val < 3) {
/*last frame*/
VSUBUNIT(dir, p2, p1);
VMOVE(dir2, dir);
- }
- else if (frame > first_frame) {
+ } else if (frame > first_frame) {
/*normal*/
VSUBUNIT(dir, p3, p1);
VSUBUNIT(dir2, p2, p1);/*needed for vertical case*/
- }
- else go = 0;/*first time through loop;no p2*/
+ } else go = 0;/*first time through loop;no p2*/
- /*create matrix which would move vehicle*/
+ /*create matrix which would move vehicle*/
anim_dir2mat(mat_v, dir, dir2);
anim_add_trans(mat_v, p2, rcentroid);
}
@@ -450,8 +452,7 @@
/* link moved from vehicle coords */
bn_mat_mul(mat_x, wmat, m_rev_axes);
bn_mat_mul(wmat, m_axes, mat_x);
- }
- else if (axes || cent) {
+ } else if (axes || cent) {
/* link moved to vehicle coords */
MAT_MOVE(mat_x, wmat);
bn_mat_mul(wmat, m_axes, mat_x);
Modified: brlcad/trunk/src/anim/anim_keyread.c
===================================================================
--- brlcad/trunk/src/anim/anim_keyread.c 2010-10-18 21:24:09 UTC (rev
41060)
+++ brlcad/trunk/src/anim/anim_keyread.c 2010-10-18 21:45:15 UTC (rev
41061)
@@ -19,21 +19,22 @@
*
*/
/** @file anim_keyread.c
- * Convert an list of mged-style 'savekey' keyframes into an
- * animation table
*
- * The output table specifies the orientation in one of three ways:
+ * Convert an list of mged-style 'savekey' keyframes into an animation
+ * table
*
- * default - quaternions in the order x, y, z, w.
+ * The output table specifies the orientation in one of three ways:
*
- * -z option - Eulers angles, in the order xyz. The model axes are
- * considered to be rotated about the camera's z, y, and
- * x axes (in that order).
+ * default - quaternions in the order x, y, z, w.
*
- * -y option - Eulers angles in the form yaw, pitch, roll.
+ * -z option - Eulers angles, in the order xyz. The model axes are
+ * considered to be rotated about the camera's z, y, and x axes (in
+ * that order).
*
- * This is more or less a special case of anim_orient.c
+ * -y option - Eulers angles in the form yaw, pitch, roll.
*
+ * This is more or less a special case of anim_orient.c
+ *
*/
#include "common.h"
@@ -49,23 +50,24 @@
#define OPT_STR "yzqr"
-#define YPR 0
-#define XYZ 1
-#define QUATERNION 2
+#define YPR 0
+#define XYZ 1
+#define QUATERNION 2
-#define DEGREES 0
-#define RADIANS 1
+#define DEGREES 0
+#define RADIANS 1
-#define NORMAL 0
-#define ERROR1 1
-#define ERROR2 2
+#define NORMAL 0
+#define ERROR1 1
+#define ERROR2 2
int mode;
int units;
-int get_args(int argc, char **argv)
+int
+get_args(int argc, char **argv)
{
int c;
@@ -73,7 +75,7 @@
mode = QUATERNION; /* default */
units = DEGREES;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
switch (c) {
case 'y':
mode = YPR;
@@ -134,8 +136,7 @@
if (units == DEGREES)
VSCALE(angle, angle, RAD2DEG);
printf("%.10g\t%.10g\t%.10g\n", angle[0], angle[1], angle[2]);
- }
- else if (mode==XYZ) {
+ } else if (mode==XYZ) {
c = anim_mat2zyx(angle, viewrot);
if (c==ERROR1)
fprintf(stderr, "Warning: x and z rotations arbitrarily defined
at time = %f.\n", time);
@@ -144,8 +145,7 @@
if (units == DEGREES)
VSCALE(angle, angle, RAD2DEG);
printf("%.10g\t%.10g\t%.10g\n", angle[X], angle[Y], angle[Z]);
- }
- else if (mode==QUATERNION) {
+ } else if (mode==QUATERNION) {
anim_mat2quat(quat, viewrot);
printf("%.10g\t%.10g\t%.10g\t%.10g\n", quat[X], quat[Y], quat[Z],
quat[W]);
}
Modified: brlcad/trunk/src/anim/anim_lookat.c
===================================================================
--- brlcad/trunk/src/anim/anim_lookat.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_lookat.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -19,7 +19,8 @@
*
*/
/** @file anim_lookat.c
- * Given animation tables for the position of the virtual camera
+ *
+ * Given animation tables for the position of the virtual camera
* and a point to look at at each time, this program produces an animation
* script to control the camera. The view is kept rightside up, whenever
* possible. When looking vertically up or down, the exact orientation
@@ -40,9 +41,9 @@
#define OPT_STR "f:yqv"
-#define LOOKAT_SCRIPT 0
-#define LOOKAT_YPR 1
-#define LOOKAT_QUAT 2
+#define LOOKAT_SCRIPT 0
+#define LOOKAT_YPR 1
+#define LOOKAT_QUAT 2
int frame = 0;
@@ -50,10 +51,11 @@
int print_viewsize = 0;
-int get_args(int argc, char **argv)
+int
+get_args(int argc, char **argv)
{
int c;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
switch (c) {
case 'f':
sscanf(bu_optarg, "%d", &frame);
@@ -146,6 +148,7 @@
return 0;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/anim/anim_offset.c
===================================================================
--- brlcad/trunk/src/anim/anim_offset.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_offset.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -19,12 +19,13 @@
*
*/
/** @file anim_offset.c
- * Animate an object which is rigidly attached to another.
*
- * Given an animation table specifying the position and orientation of
- * one object, anim_offset produces a similar table specifying the
- * position of an object rigidly attached to it.
+ * Animate an object which is rigidly attached to another.
*
+ * Given an animation table specifying the position and orientation of
+ * one object, anim_offset produces a similar table specifying the
+ * position of an object rigidly attached to it.
+ *
*/
#include "common.h"
@@ -32,29 +33,54 @@
#include <math.h>
#include <stdio.h>
-#include "vmath.h"
#include "bu.h"
+#include "bn.h"
#include "anim.h"
+#include "vmath.h"
+#define OPT_STR "ro:"
+
+
int full_print = 0;
vect_t offset;
-int get_args(int argc, char **argv);
-extern void anim_dy_p_r2mat(fastf_t *, double, double, double);
-extern void anim_add_trans(fastf_t *, const fastf_t *, const fastf_t *);
int
-main(int argc, char **argv)
+get_args(int argc, char **argv)
{
+ int c;
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ switch (c) {
+ case 'r':
+ full_print = 1;
+ break;
+ case 'o':
+ sscanf(argv[bu_optind-1], "%lf", offset+0);
+ sscanf(argv[bu_optind], "%lf", offset+1);
+ sscanf(argv[bu_optind+1], "%lf", offset+2);
+ bu_optind += 2;
+ break;
+ default:
+ fprintf(stderr, "Unknown option: -%c\n", c);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+
+int
+main(int argc, char *argv[])
+{
int val;
fastf_t yaw, pitch, roll, time;
vect_t temp, point, zero;
mat_t mat;
- VSETALL( temp, 0.0 );
- VSETALL( point, 0.0 );
- VSETALL( zero, 0.0 );
+ VSETALL(temp, 0.0);
+ VSETALL(point, 0.0);
+ VSETALL(zero, 0.0);
(void) get_args(argc, argv);
@@ -80,31 +106,7 @@
return 0;
}
-#define OPT_STR "ro:"
-int get_args(int argc, char **argv)
-{
- int c;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
- switch (c) {
- case 'r':
- full_print = 1;
- break;
- case 'o':
- sscanf(argv[bu_optind-1], "%lf", offset+0);
- sscanf(argv[bu_optind], "%lf", offset+1);
- sscanf(argv[bu_optind+1], "%lf", offset+2);
- bu_optind += 2;
- break;
- default:
- fprintf(stderr, "Unknown option: -%c\n", c);
- return 0;
- }
- }
- return 1;
-}
-
-
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/anim/anim_orient.c
===================================================================
--- brlcad/trunk/src/anim/anim_orient.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_orient.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,18 +20,23 @@
*/
/** @file anim_orient.c
*
- * Convert between different orientation formats. The formats are:
- * quaternion, yaw-pitch-roll, azimuth-elevation-twist, xyz angles,
- * pre-multiplication rotation matrices, and transposed matrices (inverses).
- * By default, the information is assumed to represent a transformation
- * which should be an object which initially faces the x-axis, with the
- * z-axis going up. Alternatively, the information can be interpreted as
- * transformations which should be applied to an object initially facing the
- * negative z-axis, with the y-axis going up.
- * The conversion is done by converting each input form to a matrix,
- * and then converting that matrix to the desired output form.
- * Angles may be specified in radians or degrees.
+ * Convert between different orientation formats. The formats are:
+ * quaternion, yaw-pitch-roll, azimuth-elevation-twist, xyz angles,
+ * pre-multiplication rotation matrices, and transposed matrices
+ * (inverses).
*
+ * By default, the information is assumed to represent a
+ * transformation which should be an object which initially faces the
+ * x-axis, with the z-axis going up. Alternatively, the information
+ * can be interpreted as transformations which should be applied to an
+ * object initially facing the negative z-axis, with the y-axis going
+ * up.
+ *
+ * The conversion is done by converting each input form to a matrix,
+ * and then converting that matrix to the desired output form.
+ *
+ * Angles may be specified in radians or degrees.
+ *
*/
#include "common.h"
@@ -46,18 +51,18 @@
#include "vmath.h"
-#define YPR 0
-#define XYZ 1
-#define AET 2
-#define QUAT 3
-#define MAT 4
+#define YPR 0
+#define XYZ 1
+#define AET 2
+#define QUAT 3
+#define MAT 4
-#define DEGREES 0
-#define RADIANS 1
+#define DEGREES 0
+#define RADIANS 1
-#define ANIM_NORMAL 0
-#define ANIM_ERROR1 1
-#define ANIM_ERROR2 2
+#define ANIM_NORMAL 0
+#define ANIM_ERROR1 1
+#define ANIM_ERROR2 2
int upright;
@@ -65,7 +70,8 @@
int input_perm, output_perm, input_inv, output_inv;
-int parse_args(int argc, char **argv)
+int
+parse_args(int argc, char **argv)
{
int c;
char *cp;
@@ -85,7 +91,7 @@
if (argc > 2) {
/*read output mode */
cp = argv[2];
- while ( (c=*cp++) ) {
+ while ((c=*cp++)) {
switch (c) {
case 'q':
output_mode = QUAT;
@@ -123,7 +129,7 @@
if (argc > 1) {
/*read input mode */
cp = argv[1];
- while ( (c=*cp++) ) {
+ while ((c=*cp++)) {
switch (c) {
case 'q':
input_mode = QUAT;
@@ -185,7 +191,7 @@
case AET:
num_read = scanf("%lf %lf %lf", angle, angle+1, angle+2);
/* convert to radians if in degrees */
- if (input_units==DEGREES) {
+ if (input_units==DEGREES) {
VSCALE(angle, angle, DEG2RAD);
}
break;
Modified: brlcad/trunk/src/anim/anim_script.c
===================================================================
--- brlcad/trunk/src/anim/anim_script.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_script.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,11 +20,11 @@
*/
/** @file anim_script.c
*
- * Turn an animation table into an animation script suitable for
- * use by rt. Anim_script.c makes a script for one object at a time (or the
- * virtual camera). Some of the available options include rotation
- * only, translation only, automatic steering, and specifying reference
- * coordinates.
+ * Turn an animation table into an animation script suitable for
+ * use by rt. Anim_script.c makes a script for one object at a time (or the
+ * virtual camera). Some of the available options include rotation
+ * only, translation only, automatic steering, and specifying reference
+ * coordinates.
*
*/
@@ -40,20 +40,21 @@
#include "anim.h"
-#define OPT_STR "a:b:c:d:f:m:pqrstv:"
+#define OPT_STR "a:b:c:d:f:m:pqrstv:"
/* info from command line args */
int relative_a, relative_c, axes, translate, quaternion, rotate;/*flags*/
int steer, view, readview, permute; /* flags*/
int first_frame;
-fastf_t viewsize;
+fastf_t viewsize;
vect_t centroid, rcentroid, front;
mat_t m_axes, m_rev_axes; /* rotational analogue of centroid */
char mat_cmd[10]; /* default is lmul */
-int get_args(int argc, char **argv)
+int
+get_args(int argc, char **argv)
{
int c, i, yes;
@@ -62,14 +63,14 @@
rotate = translate = 1; /* defaults */
quaternion = permute = 0;
bu_strlcpy(mat_cmd, "lmul", sizeof(mat_cmd));
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
i=0;
switch (c) {
case 'a':
bu_optind -= 1;
- sscanf(argv[bu_optind+(i++)], "%lf", &yaw );
- sscanf(argv[bu_optind+(i++)], "%lf", &pch );
- sscanf(argv[bu_optind+(i++)], "%lf", &rll );
+ sscanf(argv[bu_optind+(i++)], "%lf", &yaw);
+ sscanf(argv[bu_optind+(i++)], "%lf", &pch);
+ sscanf(argv[bu_optind+(i++)], "%lf", &rll);
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
@@ -78,9 +79,9 @@
break;
case 'b':
bu_optind -= 1;
- sscanf(argv[bu_optind+(i++)], "%lf", &yaw );
- sscanf(argv[bu_optind+(i++)], "%lf", &pch );
- sscanf(argv[bu_optind+(i++)], "%lf", &rll );
+ sscanf(argv[bu_optind+(i++)], "%lf", &yaw);
+ sscanf(argv[bu_optind+(i++)], "%lf", &pch);
+ sscanf(argv[bu_optind+(i++)], "%lf", &rll);
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
@@ -245,8 +246,7 @@
printf("%.10g %.10g %.10g 0\n", -a[0], -a[4], -a[8]);
printf("0 0 0 1;\n");
printf("end;\n");
- }
- else if (go) {
+ } else if (go) {
printf("start %d;\n", frame);
printf("clean;\n");
printf("anim %s matrix %s\n", *(argv+bu_optind), mat_cmd);
Modified: brlcad/trunk/src/anim/anim_sort.c
===================================================================
--- brlcad/trunk/src/anim/anim_sort.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_sort.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,10 +20,10 @@
*/
/** @file anim_sort.c
*
- * Combine multiple animation scripts on standard input into a
- * single script on standard output. The output can be in natural order
- * or in a scrambled order for incrementally increasing time
- * resolution (-i option).
+ * Combine multiple animation scripts on standard input into a single
+ * script on standard output. The output can be in natural order or in
+ * a scrambled order for incrementally increasing time resolution (-i
+ * option).
*
*/
@@ -36,22 +36,46 @@
#include "bu.h"
-#define MAXLEN 50 /*maximum length of lines to be read */
+#define OPT_STR "ci"
+
+#define MAXLEN 50 /*maximum length of lines to be read */
#define MAXLINES 30 /* maximum length of lines to be stored*/
int suppressed; /* flag: suppress printing of 'clean;' commands
*/
int incremental; /* flag: order for incremental time resolution */
-int get_args(int argc, char **argv);
+int get_args(int argc, char **argv)
+{
+
+ int c;
+ suppressed = 0;
+
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ switch (c) {
+ case 'c':
+ suppressed = 1;
+ break;
+ case 'i':
+ incremental = 1;
+ break;
+ default:
+ fprintf(stderr, "Unknown option: -%c\n", c);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+
int
-main(int argc, char **argv)
+main(int argc, char *argv[])
{
- int length, frame_number, number, success, maxnum;
- int first_frame, spread, reserve;
- long last_pos;
- char line[MAXLEN];
- char pbuffer[MAXLEN*MAXLINES];
+ int length, frame_number, number, success, maxnum;
+ int first_frame, spread, reserve;
+ long last_pos;
+ char line[MAXLEN];
+ char pbuffer[MAXLEN*MAXLINES];
if (!get_args(argc, argv))
@@ -63,13 +87,12 @@
if (strncmp(line, "start", 5)) {
printf("%s", line);
last_pos = ftell(stdin);
- }
- else
+ } else
break;
}
/* read the frame number of the first "start" command */
- sscanf( strpbrk(line, "0123456789"), "%d", &frame_number);
+ sscanf(strpbrk(line, "0123456789"), "%d", &frame_number);
/* find the highest frame number in the file */
maxnum = 0;
@@ -91,7 +114,7 @@
success = 1;
while (length--) {
number = -1;
- success = 0; /* tells whether or not any frames have been found which
have the current frame number*/
+ success = 0; /* tells whether or not any frames have been found which
have the current frame number*/
if (incremental) {
fseek(stdin, 0L, 0);
} else {
@@ -102,13 +125,13 @@
pbuffer[0] = '\0'; /* delete old pbuffer */
/* inner loop: search through the entire file for frames */
- /* which have the current frame number */
+ /* which have the current frame number */
while (!feof(stdin)) {
/*read to next "start" command*/
while (bu_fgets(line, MAXLEN, stdin)!=NULL) {
if (!strncmp(line, "start", 5)) {
- sscanf( strpbrk(line, "0123456789"), "%d", &number);
+ sscanf(strpbrk(line, "0123456789"), "%d", &number);
break;
}
}
@@ -162,31 +185,7 @@
return 0;
}
-#define OPT_STR "ci"
-int get_args(int argc, char **argv)
-{
-
- int c;
- suppressed = 0;
-
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
- switch (c) {
- case 'c':
- suppressed = 1;
- break;
- case 'i':
- incremental = 1;
- break;
- default:
- fprintf(stderr, "Unknown option: -%c\n", c);
- return 0;
- }
- }
- return 1;
-}
-
-
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/anim/anim_time.c
===================================================================
--- brlcad/trunk/src/anim/anim_time.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_time.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,10 +20,10 @@
*/
/** @file anim_time.c
*
- * Given an animation path consiting of time stamps and 3-d points,
- * estimate new time stamps based on the distances between points, the
- * given starting and ending times, and optionally specified starting
- * and ending velocities.
+ * Given an animation path consiting of time stamps and 3-d points,
+ * estimate new time stamps based on the distances between points, the
+ * given starting and ending times, and optionally specified starting
+ * and ending velocities.
*
*/
@@ -33,19 +33,20 @@
#include <math.h>
#include <stdio.h>
+#include "bu.h"
#include "vmath.h"
-#include "bu.h"
-#include "raytrace.h"
-#define MAXLEN 64
-#define DIVIDE_TOL (1.0e-10)
-#define MAXITS 100
-#define DELTA (1.0e-6)
-#define TIME_NONE 0
-#define TIME_ABSOLUTE 1
-#define TIME_RELATIVE 2
+#define OPT_STR "ds:e:i:f:qm:v"
+#define MAXLEN 64
+#define MAXITS 100
+#define DELTA (1.0e-6)
+#define TIME_NONE 0
+#define TIME_ABSOLUTE 1
+#define TIME_RELATIVE 2
+
+
/* command line variables */
fastf_t inv0, inv1;
int v0_set = TIME_NONE;
@@ -56,7 +57,6 @@
int domem = 0;
int debug = 0;
-int get_args(int argc, char **argv);
fastf_t
gettime(fastf_t dist, fastf_t a, fastf_t b, fastf_t c, fastf_t init)
@@ -70,7 +70,7 @@
success = 0;
while (countdown-->0) {
temp = (3.0*a*old+2.0*b)*old+c;
- if (temp<DIVIDE_TOL) {
+ if (temp<VDIVIDE_TOL) {
new = 0.75*old;
} else {
new = old - (((a*old+b)*old+c)*old-dist)/temp;
@@ -88,6 +88,59 @@
}
+
+int get_args(int argc, char **argv)
+{
+ int c;
+
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ switch (c) {
+ case 's':
+ sscanf(bu_optarg, "%lf", &inv0);
+ v0_set = TIME_ABSOLUTE;
+ break;
+ case 'e':
+ sscanf(bu_optarg, "%lf", &inv1);
+ v1_set = TIME_ABSOLUTE;
+ break;
+ case 'i':
+ sscanf(bu_optarg, "%lf", &inv0);
+ v0_set = TIME_RELATIVE;
+ if ((inv0>3.0)||(inv0<0.0)) {
+ fprintf(stderr, "anim_time: -i argument must lie between
0.0 and 3.0\n");
+ return 0;
+ }
+ break;
+ case 'f':
+ sscanf(bu_optarg, "%lf", &inv1);
+ v1_set = TIME_RELATIVE;
+ if ((inv1>3.0)||(inv1<0.0)) {
+ fprintf(stderr, "anim_time: -f argument must lie between
0.0 and 3.0\n");
+ return 0;
+ }
+ break;
+ case 'q':
+ query = 1;
+ break;
+ case 'm':
+ sscanf(bu_optarg, "%d", &maxlines);
+ domem = 1;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'd':
+ debug = 1;
+ break;
+ default:
+ fprintf(stderr, "Unknown option: -%c\n", c);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+
int
main(int argc, char **argv)
{
@@ -149,11 +202,11 @@
return 0;
}
- if (time < DIVIDE_TOL) {
+ if (time < VDIVIDE_TOL) {
fprintf(stderr, "anim_time: time too small. Only %f s.\n", time);
return 10;
}
- if (dist < DIVIDE_TOL) {
+ if (dist < VDIVIDE_TOL) {
fprintf(stderr, "anim_time: pathlength too small. Only %f\n", dist);
return 10;
}
@@ -229,59 +282,7 @@
return 0;
}
-/* code to read command line arguments*/
-#define OPT_STR "ds:e:i:f:qm:v"
-int get_args(int argc, char **argv)
-{
- int c;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
- switch (c) {
- case 's':
- sscanf(bu_optarg, "%lf", &inv0);
- v0_set = TIME_ABSOLUTE;
- break;
- case 'e':
- sscanf(bu_optarg, "%lf", &inv1);
- v1_set = TIME_ABSOLUTE;
- break;
- case 'i':
- sscanf(bu_optarg, "%lf", &inv0);
- v0_set = TIME_RELATIVE;
- if ((inv0>3.0)||(inv0<0.0)) {
- fprintf(stderr, "anim_time: -i argument must lie between
0.0 and 3.0\n");
- return 0;
- }
- break;
- case 'f':
- sscanf(bu_optarg, "%lf", &inv1);
- v1_set = TIME_RELATIVE;
- if ((inv1>3.0)||(inv1<0.0)) {
- fprintf(stderr, "anim_time: -f argument must lie between
0.0 and 3.0\n");
- return 0;
- }
- break;
- case 'q':
- query = 1;
- break;
- case 'm':
- sscanf(bu_optarg, "%d", &maxlines);
- domem = 1;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'd':
- debug = 1;
- break;
- default:
- fprintf(stderr, "Unknown option: -%c\n", c);
- return 0;
- }
- }
- return 1;
-}
-
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/anim/anim_track.c
===================================================================
--- brlcad/trunk/src/anim/anim_track.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_track.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,8 +20,8 @@
*/
/** @file anim_track.c
*
- * Animate the links and wheels of a tracked vehicle. Handles tracks that
- * change in shape during the animation.
+ * Animate the links and wheels of a tracked vehicle. Handles tracks that
+ * change in shape during the animation.
*
*/
@@ -41,19 +41,19 @@
#define OPT_STR "sycuvb:d:f:i:r:p:w:g:m:l:a"
-#define GIVEN 0
-#define CALCULATED 1
-#define STEERED 2
+#define GIVEN 0
+#define CALCULATED 1
+#define STEERED 2
-#define PRINT_ANIM 0
-#define PRINT_ARCED 1
+#define PRINT_ANIM 0
+#define PRINT_ARCED 1
-#define TRACK_MIN 0
-#define TRACK_FIXED 1
-#define TRACK_STRETCH 2
-#define TRACK_ELASTIC 3
+#define TRACK_MIN 0
+#define TRACK_FIXED 1
+#define TRACK_STRETCH 2
+#define TRACK_ELASTIC 3
-#define NW num_wheels
+#define NW num_wheels
#define NEXT(i) (i+1)%NW
#define PREV(i) (i+NW-1)%NW
@@ -61,29 +61,32 @@
typedef double *pdouble;
struct wheel {
- vect_t pos; /* displacement of wheel from vehicle origin */
- fastf_t rad; /* radius of wheel */
- fastf_t ang0; /* angle where track meets wheel 0<a<2pi*/
- fastf_t ang1; /* angle where track leaves wheel 0<a<p2i */
- fastf_t arc; /* radian length of contact between wheel and
track 0<a<pi*/
+ vect_t pos; /* displacement of wheel from vehicle origin */
+ fastf_t rad; /* radius of wheel */
+ fastf_t ang0; /* angle where track meets wheel 0<a<2pi*/
+ fastf_t ang1; /* angle where track leaves wheel 0<a<p2i */
+ fastf_t arc; /* radian length of contact between wheel and track
0<a<pi*/
};
+
struct track {
- vect_t pos0; /* beginning point of track section */
- vect_t pos1; /* end of track section */
- vect_t dir; /* unit vector:direction of track section
ending here*/
- fastf_t len; /* length of track section ending here*/
+ vect_t pos0; /* beginning point of track section */
+ vect_t pos1; /* end of track section */
+ vect_t dir; /* unit vector:direction of track section
ending here*/
+ fastf_t len; /* length of track section ending here*/
};
+
struct slope {
- vect_t dir; /* vector from previous to current axle*/
- fastf_t len; /* length of vector above*/
+ vect_t dir; /* vector from previous to current axle*/
+ fastf_t len; /* length of vector above*/
};
+
struct all {
- struct wheel w; /* parameters describing the track around a
wheel */
- struct track t; /* track between this wheel and the previous
wheel */
- struct slope s; /* vector between this axle and the previous
axle */
+ struct wheel w; /* parameters describing the track around a wheel */
+ struct track t; /* track between this wheel and the previous wheel */
+ struct slope s; /* vector between this axle and the previous axle */
};
@@ -99,25 +102,26 @@
int link_nindex; /* argv[link_nindex] = linkname*/
int print_wheel; /* flag: do wheel animation */
int print_link; /* flag: do link animation */
-int print_mode; /* anim for rt or arced for mged */
+int print_mode; /* anim for rt or arced for mged */
int arced_frame; /* which frame to arced */
-int axes, cent; /* flags: alternate axes, centroid specified */
-int dist_mode; /* given, steered, or calculated */
-int first_frame; /* integer to begin numbering frames */
+int axes, cent; /* flags: alternate axes, centroid specified */
+int dist_mode; /* given, steered, or calculated */
+int first_frame; /* integer to begin numbering frames */
fastf_t init_dist; /* initial distance of first link along track */
int one_radius; /* flag: common radius specified */
fastf_t radius; /* common radius of all wheels */
-vect_t centroid, rcentroid; /* alternate centroid and its reverse */
-mat_t m_axes, m_rev_axes; /* matrices to and from alternate axes */
-char link_cmd[10]; /* default is "rarc" */
-char wheel_cmd[10]; /* default is "lmul" */
+char link_cmd[10]; /* default is "rarc" */
+char wheel_cmd[10]; /* default is "lmul" */
int get_circumf; /* flag: just return circumference of track */
-int read_wheels; /* flag: read new wheel positions each frame */
+int read_wheels; /* flag: read new wheel positions each frame */
int len_mode; /* mode for track_len */
int anti_strobe; /* flag: take measures against strobing effect */
+vect_t centroid, rcentroid; /* alternate centroid and its reverse */
+mat_t m_axes, m_rev_axes; /* matrices to and from alternate axes */
-int get_args(int argc, char **argv)
+int
+get_args(int argc, char **argv)
{
int c, i;
fastf_t yaw, pch, rll;
@@ -135,7 +139,7 @@
len_mode = TRACK_MIN;
anti_strobe = 0;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
i=0;
switch (c) {
case 's':
@@ -155,9 +159,9 @@
break;
case 'b':
bu_optind -= 1;
- sscanf(argv[bu_optind+(i++)], "%lf", &yaw );
- sscanf(argv[bu_optind+(i++)], "%lf", &pch );
- sscanf(argv[bu_optind+(i++)], "%lf", &rll );
+ sscanf(argv[bu_optind+(i++)], "%lf", &yaw);
+ sscanf(argv[bu_optind+(i++)], "%lf", &pch);
+ sscanf(argv[bu_optind+(i++)], "%lf", &rll);
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
@@ -256,7 +260,7 @@
* rest of the x[i] structs and also calculates values for curve_a, curve_b,
* curve_c, and s_start, which describe the caternary segment
* return values: 0 = GOOD
- * -1 = BAD. Track too short to fit around wheels
+ * -1 = BAD. Track too short to fit around wheels
*/
int
track_prep(void)
@@ -274,7 +278,7 @@
/*calculate end angle of previous wheel assuming all convex*/
phi = atan2(x[i].s.dir[2], x[i].s.dir[0]);/*absolute angle of slope*/
costheta = (x[PREV(i)].w.rad - x[i].w.rad)/x[i].s.len;/*cosine of
special angle*/
- x[PREV(i)].w.ang1 = phi + acos(costheta);
+ x[PREV(i)].w.ang1 = phi + acos(costheta);
while (x[PREV(i)].w.ang1 < 0.0)
x[PREV(i)].w.ang1 += 2.0*M_PI;
x[i].w.ang0 = x[PREV(i)].w.ang1;
@@ -289,8 +293,7 @@
x[i].w.ang0 = 0.5*(x[i].w.ang0 + x[i].w.ang1);
x[i].w.ang1 = x[i].w.ang0;
x[i].w.arc = 0.0;
- }
- else {
+ } else {
/* convex - angles are already correct */
x[i].w.arc = arc_angle;
}
@@ -335,8 +338,7 @@
if ((len_mode==TRACK_ELASTIC)||(len_mode==TRACK_STRETCH)) {
tracklen += (x[0].t.len-hyperlen);
hyperlen = tracklen - linearlen;
- }
- else {
+ } else {
return -1;/*bad, track is too short*/
}
}
@@ -384,7 +386,7 @@
/* we want it to ignore the distance between wheel(n-1) and wheel(0)*/
dist += x[0].t.len;
for (i=0;i<NW;i++) {
- if ( (dist -= x[i].t.len) < 0 ) {
+ if ((dist -= x[i].t.len) < 0) {
VSCALE(temp, (x[i].t.dir), dist);
VADD2(pos, x[i].t.pos1, temp);
*angle_p = atan2(x[i].t.dir[2], x[i].t.dir[0]);
@@ -402,14 +404,13 @@
}
/* caternary section */
- if ( curve_a > VDIVIDE_TOL) {
+ if (curve_a > VDIVIDE_TOL) {
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;
*angle_p = hyper_get_ang(curve_a, curve_c, pos[X]);
- }
- else {
+ } else {
/* practically linear */
VSCALE(temp, (x[0].t.dir), dist);
VADD2(pos, x[0].t.pos0, temp);
@@ -451,7 +452,7 @@
if (!get_args(argc, argv))
fprintf(stderr, "Anim_track: Argument error.\n");
- if (axes || cent ) {
+ if (axes || cent) {
/* vehicle has own reference frame */
anim_add_trans(m_axes, centroid, zero);
anim_add_trans(m_rev_axes, zero, rcentroid);
@@ -542,8 +543,7 @@
if (val < 1) {
break;
}
- }
- else if (dist_mode==CALCULATED) {
+ } else if (dist_mode==CALCULATED) {
scanf("%*f");/*time*/
scanf("%lf %lf %lf", cent_pos, cent_pos+1, cent_pos+2);
val = scanf("%lf %lf %lf", &yaw, &pch, &roll);
Modified: brlcad/trunk/src/anim/anim_turn.c
===================================================================
--- brlcad/trunk/src/anim/anim_turn.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/anim_turn.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,12 +20,12 @@
*/
/** @file anim_turn.c
*
- * Animate front-wheel steered vehicles.
+ * Animate front-wheel steered vehicles.
*
- * This is a filter which operates on animation tables. Given an
- * animation table for the position of the front axle, anim_turn produces
- * an animation table for position and orientation. Options provide for
- * animating the wheels and/or steering wheel.
+ * This is a filter which operates on animation tables. Given an
+ * animation table for the position of the front axle, anim_turn produces
+ * an animation table for position and orientation. Options provide for
+ * animating the wheels and/or steering wheel.
*
*/
@@ -50,10 +50,11 @@
fastf_t factor = 1.0;
-int get_args(int argc, char **argv)
+int
+get_args(int argc, char **argv)
{
int c;
- while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
+ while ((c=bu_getopt(argc, argv, OPT_STR)) != EOF) {
switch (c) {
case 'l':
sscanf(bu_optarg, "%lf", &length);
@@ -93,13 +94,13 @@
/* initialize variables */
VSETALL(zero, 0.0);
- VSETALL( v, 0.0 );
- VSETALL( point, 0.0 );
- VSETALL( front, 0.0 );
- VSETALL( back, 0.0 );
- VSETALL( temp1, 0.0 );
- VSETALL( temp2, 0.0 );
- for ( count=0; count<ELEMENTS_PER_MAT; count++ )
+ VSETALL(v, 0.0);
+ VSETALL(point, 0.0);
+ VSETALL(front, 0.0);
+ VSETALL(back, 0.0);
+ VSETALL(temp1, 0.0);
+ VSETALL(temp2, 0.0);
+ for (count=0; count<ELEMENTS_PER_MAT; count++)
m_from_world[count]=m_to_world[count]=0.0;
length = angle = radius = roll_ang = 0.0;
@@ -112,7 +113,7 @@
VSCAN(temp1);
scanf("%*f%*[^-0123456789]");
VSCAN(temp2);
- angle = bn_atan2( (temp2[1]-temp1[1]), (temp2[0]-temp1[0]) );
+ angle = bn_atan2((temp2[1]-temp1[1]), (temp2[0]-temp1[0]));
rewind(stdin);
}
count = 0;
@@ -151,8 +152,7 @@
/*calculate new angle of vehicle*/
VSUB2(temp1, front, back);
angle = bn_atan2(temp1[1], temp1[0]);
- }
- else {
+ } else {
/*first time through */
/*angle is already determined*/
VMOVE(front, point);
@@ -171,8 +171,7 @@
if (!(count%print_int))
printf("%.10g %.10g %.10g 0.0\n", t, factor*RAD2DEG*yaw,
RAD2DEG*roll_ang);
- }
- else {
+ } else {
/* print position and orientation of vehicle */
if (!(count%print_int))
printf("%.10g %.10g %.10g %.10g %.10g 0.0 0.0\n", t, front[0],
front[1], front[2], RAD2DEG * angle);
Modified: brlcad/trunk/src/anim/cattrack.c
===================================================================
--- brlcad/trunk/src/anim/cattrack.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/cattrack.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -19,8 +19,9 @@
*
*/
/** @file cattrack.c
- * Caternary curve routines used by anim_track.c
*
+ * Caternary curve routines used by anim_track.c
+ *
*/
#include "common.h"
@@ -32,22 +33,22 @@
#include "anim.h"
-#define MAX_REACHED 0
-#define SOLVED 1
+#define MAX_REACHED 0
+#define SOLVED 1
/* the total maximum number of lowest level iterations possible is
- * T_MAX_ITS*MAX_OUT_ITS*2*MAX_ITS
+ * T_MAX_ITS*MAX_OUT_ITS*2*MAX_ITS
*/
-#define MAX_ITS 25
-#define MAX_OUT_ITS 25
-#define T_MAX_ITS 50
+#define MAX_ITS 25
+#define MAX_OUT_ITS 25
+#define T_MAX_ITS 50
/* these tolerances are guessed at, except that it seems to be important
* in elastic situations that T_TOL be significantly smaller than the others
*/
-#define T_TOL 1.0e-14
-#define G_TOL 1.0e-12
-#define F_TOL 1.0e-12
+#define T_TOL 1.0e-14
+#define G_TOL 1.0e-12
+#define F_TOL 1.0e-12
fastf_t
@@ -159,8 +160,7 @@
adjust = eff(*pa, *pc, p_zero[X], p_one[X], delta_s);
if ((*pa-adjust)<=0.0) {
*pa *= 0.5;
- }
- else {
+ } else {
*pa -= adjust;
}
if (adjust<F_TOL) {
@@ -215,8 +215,7 @@
(*pa) = 1.0;
*pc = 0.5*(p_one[X]+p_zero[X]);
called_before = 1;
- }
- else {
+ } else {
theta_zero = last_theta_zero;
theta_one = last_theta_one;
*pa = last_a;
Modified: brlcad/trunk/src/anim/chan_add.c
===================================================================
--- brlcad/trunk/src/anim/chan_add.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/chan_add.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,7 +20,7 @@
*/
/** @file chan_add.c
*
- * Add a given value to specified columns of data.
+ * Add a given value to specified columns of data.
*
*/
@@ -68,7 +68,7 @@
else
printf("%.10g\t", temp);
}
- if ( count == (of-1))
+ if (count == (of-1))
printf("\n");
count = (count+1)%of;
}
@@ -77,6 +77,7 @@
return 0;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/anim/chan_mult.c
===================================================================
--- brlcad/trunk/src/anim/chan_mult.c 2010-10-18 21:24:09 UTC (rev 41060)
+++ brlcad/trunk/src/anim/chan_mult.c 2010-10-18 21:45:15 UTC (rev 41061)
@@ -20,7 +20,7 @@
*/
/** @file chan_mult.c
*
- * Multiply specified columns of data by a given factor.
+ * Multiply specified columns of data by a given factor.
*
*/
@@ -66,7 +66,7 @@
else
printf("%.10g\t", temp);
}
- if ( count == (of-1))
+ if (count == (of-1))
printf("\n");
count = (count+1)%of;
}
@@ -75,6 +75,7 @@
return 0;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/anim/chan_permute.c
===================================================================
--- brlcad/trunk/src/anim/chan_permute.c 2010-10-18 21:24:09 UTC (rev
41060)
+++ brlcad/trunk/src/anim/chan_permute.c 2010-10-18 21:45:15 UTC (rev
41061)
@@ -19,17 +19,23 @@
*
*/
/** @file chan_permute.c
- * This program mixes, matches, and merges files organized in
- * channels or columns.
- * It's nothing cut and paste can't do, but sometimes it's nice to
- * be able to do it in one step, especially when working with animation
- * tables.
- *Usage: channel -i infile1 id id id ... [-i infile2 ...] -o outfile1 id id ...
- * [-o outfile2 ...]
- *where infiles are files to be read from, outfiles are files to be written
- *to, and each id is a small positive integer identifying a channel. All of the
- *input id's should be distinct integers, or the results are not guaranteed.
*
+ * This program mixes, matches, and merges files organized in channels
+ * or columns.
+ *
+ * It's nothing cut and paste can't do, but sometimes it's nice to be
+ * able to do it in one step, especially when working with animation
+ * tables. Usage:
+ *
+
+channel -i infile1 id id id ... [-i infile2 ...] -o outfile1 id id ... [-o
outfile2 ...]
+
+ *
+ * where infiles are files to be read from, outfiles are files to be
+ * written to, and each id is a small positive integer identifying a
+ * channel. All of the input id's should be distinct integers, or the
+ * results are not guaranteed.
+ *
*/
#include "common.h"
@@ -57,7 +63,7 @@
char ohead[] = "-o";
int
-main(int argc, char **argv)
+main(int argc, char *argv[])
{
int i, j, maxlength, num_done;
int icount, ocount;
@@ -69,12 +75,10 @@
if ( !strncmp(argv[i], ihead, 2) ) {
j=0;
icount++;
- }
- else if ( !strncmp(argv[i], ohead, 2) ) {
+ } else if ( !strncmp(argv[i], ohead, 2) ) {
j=0;
ocount++;
- }
- else
+ } else
maxlength = (++j>maxlength) ? j : maxlength;
}
@@ -92,21 +96,18 @@
x->file = stdin;
else if ( !(x->file = fopen(argv[i], "rb")) )
fprintf(stderr, "Channel: can't open %s\n", argv[i]);
- }
- else if (argv[i][1] == 'o') {
+ } else if (argv[i][1] == 'o') {
i++;
(x)->i_o = 0;
if ( ! strcmp(argv[i], "stdout") )
x->file = stdout;
else if ( !(x->file = fopen(argv[i], "wb")) )
fprintf(stderr, "Channel: can't write to %s\n", argv[i]);
- }
- else {
+ } else {
fprintf(stderr, "Illegal option %c\n", argv[i][1]);
bu_exit(-1, NULL);
}
- }
- else {
+ } else {
sscanf(argv[i], "%hd", x->list+(j++));
x->channels++;
}
@@ -126,8 +127,7 @@
else
for (j=0;j<x->channels;j++)
fscanf(x->file, "%40s ", arrayd[x->list[j]]);
- }
- else if (x->i_o == 0) {
+ } else if (x->i_o == 0) {
for (j=0;j<x->channels;j++)
fprintf(x->file, "%s\t", arrayd[x->list[j]]);
fprintf(x->file, "\n");
@@ -145,17 +145,7 @@
return 0;
}
-int max(int *m, int n) /*return greatest of n integers, unless one is greater
than n*/
-{
- int i, j;
- j = 0;
- for (i=0;i<n;i++) {
- j = (m[i]>j) ? m[i] : j;
- }
- return (j>n) ? 0 : j;
-}
-
/*
* Local Variables:
* mode: C
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