Animation
[libbn (numerical functions)]

Collaboration diagram for Animation:


Files

file  anim.h
file  anim.c
 Routines useful in animation programs.
file  tabdata.c
 Routines for processing tables (curves) of data with one independent parameter which is common to many sets of dependent data values.

Defines

#define ANIM_STEER_NEW   0
#define ANIM_STEER_END   1
#define DTOR   M_PI/180.0
#define RTOD   180.0/M_PI
#define VSUBUNIT(a, b, c)
#define FVSCAN(f, a)   fscanf(f,"%lf %lf %lf", (a),(a)+1,(a)+2)
#define FMATSCAN(f, m)
#define VSCAN(a)   scanf("%lf %lf %lf", (a),(a)+1,(a)+2)
#define VPRINTS(t, a)   printf("%s %f %f %f ",t,(a)[0],(a)[1],(a)[2])
#define VPRINTN(t, a)   printf("%s %f %f %f\n",t,(a)[0],(a)[1],(a)[2])
#define MAT_MOVE(m, n)   MAT_COPY(m,n)
#define MAT3ZERO(m)
#define MAT3IDN(m)
#define MAT3MUL(o, a, b)
#define MAT3SUM(o, a, b)
#define MAT3DIF(o, a, b)
#define MAT3SCALE(o, a, s)
#define MAT3MOVE(o, a)
#define MAT3XVEC(u, m, v)
#define MAT3TO4(o, i)
#define MAT4TO3(o, i)
#define MAKE_TILDE(m, v)
#define INERTIAL_MAT3(m, a, b)
#define M_PI   3.14159265358979323846
#define NORMAL   0
#define ERROR1   1
#define ERROR2   2
#define ASM_EMPTY   0
#define ASM_FIRST   1
#define ASM_FULL   2

Typedefs

typedef fastf_t mat3_t [9]

Functions

void anim_v_permute (mat_t m)
 Pre-multiply a rotation matrix by a matrix which maps the z-axis to the negative x-axis, the y-axis to the z-axis and the x-axis to the negative y-axis.
void anim_v_unpermute (mat_t m)
 Undo the mapping done by anim_v_permute().
void anim_tran (mat_t m)
 Transpose matrix in place.
int anim_mat2zyx (const mat_t viewrot, vect_t angle)
 Convert the rotational part of a 4x4 transformation matrix to zyx form, that is to say, rotations carried out in the order z, y, and then x. The angles are stored in radians as a vector in the order x,y,z. A return value of ERROR1 means that arbitrary assumptions were necessary. ERROR2 means that the conversion failed.
int anim_mat2ypr (mat_t viewrot, vect_t angle)
 Convert the rotational part of a 4x4 transformation matrix to yaw-pitch-roll form, that is to say, +roll degrees about the x-axis, -pitch degrees about the y-axis, and +yaw degrees about the z-axis. The angles are stored in radians as a vector in the order y,p,r. A return of ERROR1 means that arbitrary assumptions were necessary. ERROR2 means that the conversion failed.
int anim_mat2quat (hvect_t quat, const mat_t viewrot)
void anim_ypr2mat (mat_t m, const vect_t a)
 Create a premultiplication rotation matrix to turn the front of an object (its x-axis) to the given yaw, pitch, and roll, which is stored in radians in the vector a.
void anim_ypr2vmat (mat_t m, const vect_t a)
 Create a post-multiplication rotation matrix ,which could be used to move the virtual camera to the given yaw, pitch, and roll, which are stored in radians in the given vector a. The following are equivalent sets of commands: ypr2vmat(matrix,a); or ypr2mat(matrix,a); v_permute(matrix); transpose(matrix;.
void anim_y_p_r2mat (mat_t m, double y, double p, double r)
 Make matrix to rotate an object to the given yaw, pitch, and roll. (Specified in radians.).
void anim_dy_p_r2mat (mat_t m, double y, double p, double r)
 Make matrix to rotate an object to the given yaw, pitch, and roll. (Specified in degrees.).
void anim_dy_p_r2vmat (mat_t m, double yaw, double pch, double rll)
 Make a view rotation matrix, given desired yaw, pitch and roll. (Note that the matrix is a permutation of the object rotation matrix).
void anim_x_y_z2mat (mat_t m, double x, double y, double z)
 Make a rotation matrix corresponding to a rotation of "x" radians about the x-axis, "y" radians about the y-axis, and then "z" radians about the z-axis.
void anim_dx_y_z2mat (mat_t m, double x, double y, double z)
 Make a rotation matrix corresponding to a rotation of "x" degrees about the x-axis, "y" degrees about the y-axis, and then "z" degrees about the z-axis.
void anim_zyx2mat (mat_t m, const vect_t a)
void anim_z_y_x2mat (mat_t m, double x, double y, double z)
 Make a rotation matrix corresponding to a rotation of "z" radians about the z-axis, "y" radians about the y-axis, and then "x" radians about the x-axis.
void anim_dz_y_x2mat (mat_t m, double x, double y, double z)
 Make a rotation matrix corresponding to a rotation of "z" degrees about the z-axis, "y" degrees about the y-axis, and then "x" degrees about the x-axis.
void anim_quat2mat (mat_t m, const hvect_t qq)
void anim_dir2mat (mat_t m, const vect_t d, const vect_t d2)
void anim_dirn2mat (mat_t m, const vect_t dx, const vect_t dn)
int anim_steer_mat (mat_t mat, vect_t point, int end)
void anim_add_trans (mat_t m, const vect_t post, const vect_t pre)
void anim_rotatez (fastf_t a, vect_t d)
void anim_mat_print (FILE *fp, const mat_t m, int s_colon)
void anim_mat_printf (FILE *fp, const mat_t m, const char *formstr, const char *linestr, const char *endstr)
void anim_view_rev (mat_t m)
int bn_decode_mat (mat_t m, const char *str)
int bn_decode_quat (hvect_t q, const char *str)
int bn_decode_vect (vect_t v, const char *str)
int bn_decode_hvect (hvect_t v, const char *str)
void bn_encode_mat (struct bu_vls *vp, const mat_t m)
void bn_encode_quat (struct bu_vls *vp, const hvect_t q)
void bn_encode_vect (struct bu_vls *vp, const vect_t v)
void bn_encode_hvect (struct bu_vls *vp, const hvect_t v)
void bn_tcl_setup ()
int Bn_Init ()
void bn_tcl_mat_print ()
int anim_mat2quat (quat_t quat, const mat_t viewrot)
 This interprets the rotational part of a 4x4 transformation matrix in terms of unit quaternions. The result is stored as a vector in the order x,y,z,w. The algorithm is from Ken Shoemake, Animating Rotation with Quaternion Curves, 1985 SIGGraph Conference Proceeding, p.245.
void anim_quat2mat (mat_t m, const quat_t qq)

Define Documentation

#define ANIM_STEER_NEW   0
 

Definition at line 37 of file anim.h.

#define ANIM_STEER_END   1
 

Definition at line 38 of file anim.h.

#define DTOR   M_PI/180.0
 

Definition at line 40 of file anim.h.

#define RTOD   180.0/M_PI
 

Definition at line 41 of file anim.h.

#define VSUBUNIT a,
b,
 ) 
 

Value:

{VSUB2(a,b,c);\
                        VUNITIZE(a);}

Definition at line 43 of file anim.h.

Referenced by anim_steer_mat().

#define FVSCAN f,
 )     fscanf(f,"%lf %lf %lf", (a),(a)+1,(a)+2)
 

Definition at line 45 of file anim.h.

#define FMATSCAN f,
 ) 
 

Value:

{FVSCAN(f,(m)); FVSCAN(f,(m)+4);\
                         FVSCAN(f,(m)+8); FVSCAN(f,(m)+12);}

Definition at line 46 of file anim.h.

#define VSCAN  )     scanf("%lf %lf %lf", (a),(a)+1,(a)+2)
 

Definition at line 48 of file anim.h.

#define VPRINTS t,
 )     printf("%s %f %f %f ",t,(a)[0],(a)[1],(a)[2])
 

Definition at line 49 of file anim.h.

#define VPRINTN t,
 )     printf("%s %f %f %f\n",t,(a)[0],(a)[1],(a)[2])
 

Definition at line 50 of file anim.h.

#define MAT_MOVE m,
 )     MAT_COPY(m,n)
 

Definition at line 52 of file anim.h.

#define MAT3ZERO  ) 
 

Value:

{\
        int _j; for(_j=0;_j<9;_j++) m[_j]=0.0;}

Definition at line 58 of file anim.h.

#define MAT3IDN  ) 
 

Value:

{\
        int _j; for(_j=0;_j<9;_j++) m[_j]=0.0;\
        m[0] = m[4] = m[8] = 1.0;}

Definition at line 61 of file anim.h.

#define MAT3MUL o,
a,
 ) 
 

Value:

{\
        (o)[0] = (a)[0]*(b)[0] + (a)[1]*(b)[3] + (a)[2]*(b)[6];\
        (o)[1] = (a)[0]*(b)[1] + (a)[1]*(b)[4] + (a)[2]*(b)[7];\
        (o)[2] = (a)[0]*(b)[2] + (a)[1]*(b)[5] + (a)[2]*(b)[8];\
        (o)[3] = (a)[3]*(b)[0] + (a)[4]*(b)[3] + (a)[5]*(b)[6];\
        (o)[4] = (a)[3]*(b)[1] + (a)[4]*(b)[4] + (a)[5]*(b)[7];\
        (o)[5] = (a)[3]*(b)[2] + (a)[4]*(b)[5] + (a)[5]*(b)[8];\
        (o)[6] = (a)[6]*(b)[0] + (a)[7]*(b)[3] + (a)[8]*(b)[6];\
        (o)[7] = (a)[6]*(b)[1] + (a)[7]*(b)[4] + (a)[8]*(b)[7];\
        (o)[8] = (a)[6]*(b)[2] + (a)[7]*(b)[5] + (a)[8]*(b)[8];}

Definition at line 65 of file anim.h.

#define MAT3SUM o,
a,
 ) 
 

Value:

{\
        int _j; for(_j=0;_j<9;_j++) (o)[_j]=(a)[_j]+(b)[_j];}

Definition at line 76 of file anim.h.

#define MAT3DIF o,
a,
 ) 
 

Value:

{\
        int _j; for(_j=0;_j<9;_j++) (o)[_j]=(a)[_j]-(b)[_j];}

Definition at line 79 of file anim.h.

#define MAT3SCALE o,
a,
 ) 
 

Value:

{\
        int _j; for(_j=0;_j<9;_j++) (o)[_j]=(a)[_j] * (s);}

Definition at line 82 of file anim.h.

#define MAT3MOVE o,
 ) 
 

Value:

{\
        int _j; for(_j=0;_j<9;_j++) (o)[_j] = (a)[_j];}

Definition at line 85 of file anim.h.

#define MAT3XVEC u,
m,
 ) 
 

Value:

{\
        (u)[0] = (m)[0]*(v)[0] + (m)[1]*(v)[1] + (m)[2]*(v)[2];\
        (u)[1] = (m)[3]*(v)[0] + (m)[4]*(v)[1] + (m)[5]*(v)[2];\
        (u)[2] = (m)[6]*(v)[0] + (m)[7]*(v)[1] + (m)[8]*(v)[2];}

Definition at line 88 of file anim.h.

#define MAT3TO4 o,
 ) 
 

Value:

{\
        (o)[0] = (i)[0];\
        (o)[1] = (i)[1];\
        (o)[2] = (i)[2];\
        (o)[4] = (i)[3];\
        (o)[5] = (i)[4];\
        (o)[6] = (i)[5];\
        (o)[8] = (i)[6];\
        (o)[9] = (i)[7];\
        (o)[10] = (i)[8];\
        (o)[3]=(o)[7]=(o)[11]=(o)[12]=(o)[13]=(o)[14]=0.0;\
        (o)[15]=1.0;}

Definition at line 93 of file anim.h.

#define MAT4TO3 o,
 ) 
 

Value:

{\
        (o)[0] = (i)[0];\
        (o)[1] = (i)[1];\
        (o)[2] = (i)[2];\
        (o)[3] = (i)[4];\
        (o)[4] = (i)[5];\
        (o)[5] = (i)[6];\
        (o)[6] = (i)[8];\
        (o)[7] = (i)[9];\
        (o)[8] = (i)[10];}

Definition at line 106 of file anim.h.

#define MAKE_TILDE m,
 ) 
 

Value:

{\
        MAT3ZERO(m);\
        m[1]= -v[2];    m[2]=v[1];      m[3]= v[2];\
        m[5]= -v[0];    m[6]= -v[1];    m[7]= v[0];}

Definition at line 119 of file anim.h.

#define INERTIAL_MAT3 m,
a,
 ) 
 

Value:

{\
        (m)[0] =  (a)[0]; (m)[1] = -(b)[0]; (m)[2] = -(b)[1];\
        (m)[3] = -(b)[0]; (m)[4] =  (a)[1]; (m)[5] = -(b)[2];\
        (m)[6] = -(b)[1]; (m)[7] = -(b)[2]; (m)[8]=  (a)[2];}

Definition at line 125 of file anim.h.

#define M_PI   3.14159265358979323846
 

Definition at line 77 of file anim.c.

#define NORMAL   0
 

Definition at line 80 of file anim.c.

Referenced by anim_mat2ypr(), and anim_mat2zyx().

#define ERROR1   1
 

Definition at line 81 of file anim.c.

Referenced by anim_mat2ypr(), and anim_mat2zyx().

#define ERROR2   2
 

Definition at line 82 of file anim.c.

Referenced by anim_mat2ypr(), and anim_mat2zyx().

#define ASM_EMPTY   0
 

Definition at line 873 of file anim.c.

Referenced by anim_steer_mat().

#define ASM_FIRST   1
 

Definition at line 874 of file anim.c.

Referenced by anim_steer_mat().

#define ASM_FULL   2
 

Definition at line 875 of file anim.c.

Referenced by anim_steer_mat().


Typedef Documentation

typedef fastf_t mat3_t[9]
 

Definition at line 56 of file anim.h.


Function Documentation

void anim_v_permute mat_t  m  ) 
 

Pre-multiply a rotation matrix by a matrix which maps the z-axis to the negative x-axis, the y-axis to the z-axis and the x-axis to the negative y-axis.

ANIM_V_PERMUTE

This has the effect of twisting an object in the default view orientation into the default object orientation before applying the matrix. Given a matrix designed to operate on an object, yield a matrix which operates on the view.

Definition at line 106 of file anim.c.

void anim_v_unpermute mat_t  m  ) 
 

Undo the mapping done by anim_v_permute().

ANIM_V_UNPERMUTE

This has the effect of twisting an object in the default object orientation into the default view orientation before applying the matrix. Given a matrix designed to operate on the view, yield a matrix which operates on an object.

Definition at line 129 of file anim.c.

void anim_tran mat_t  m  ) 
 

Transpose matrix in place.

Definition at line 143 of file anim.c.

int anim_mat2zyx const mat_t  viewrot,
vect_t  angle
 

Convert the rotational part of a 4x4 transformation matrix to zyx form, that is to say, rotations carried out in the order z, y, and then x. The angles are stored in radians as a vector in the order x,y,z. A return value of ERROR1 means that arbitrary assumptions were necessary. ERROR2 means that the conversion failed.

ANIM_MAT2ZYX

Definition at line 191 of file anim.c.

References ERROR1, ERROR2, M_PI, NORMAL, and VDIVIDE_TOL.

int anim_mat2ypr mat_t  viewrot,
vect_t  angle
 

Convert the rotational part of a 4x4 transformation matrix to yaw-pitch-roll form, that is to say, +roll degrees about the x-axis, -pitch degrees about the y-axis, and +yaw degrees about the z-axis. The angles are stored in radians as a vector in the order y,p,r. A return of ERROR1 means that arbitrary assumptions were necessary. ERROR2 means that the conversion failed.

ANIM_MAT2YPR

Definition at line 260 of file anim.c.

References ERROR1, ERROR2, M_PI, NORMAL, and VDIVIDE_TOL.

int anim_mat2quat hvect_t  quat,
const mat_t  viewrot
 

void anim_ypr2mat mat_t  m,
const vect_t  a
 

Create a premultiplication rotation matrix to turn the front of an object (its x-axis) to the given yaw, pitch, and roll, which is stored in radians in the vector a.

ANIM_YPR2MAT

Definition at line 392 of file anim.c.

void anim_ypr2vmat mat_t  m,
const vect_t  a
 

Create a post-multiplication rotation matrix ,which could be used to move the virtual camera to the given yaw, pitch, and roll, which are stored in radians in the given vector a. The following are equivalent sets of commands: ypr2vmat(matrix,a); or ypr2mat(matrix,a); v_permute(matrix); transpose(matrix;.

ANIM_YPR2VMAT

Definition at line 432 of file anim.c.

void anim_y_p_r2mat mat_t  m,
double  y,
double  p,
double  r
 

Make matrix to rotate an object to the given yaw, pitch, and roll. (Specified in radians.).

ANIM_Y_P_R2MAT

Definition at line 466 of file anim.c.

void anim_dy_p_r2mat mat_t  m,
double  y,
double  p,
double  r
 

Make matrix to rotate an object to the given yaw, pitch, and roll. (Specified in degrees.).

ANIM_DY_P_R2MAT

Definition at line 495 of file anim.c.

References M_PI.

void anim_dy_p_r2vmat mat_t  m,
double  yaw,
double  pch,
double  rll
 

Make a view rotation matrix, given desired yaw, pitch and roll. (Note that the matrix is a permutation of the object rotation matrix).

ANIM_DY_P_R2VMAT

Definition at line 527 of file anim.c.

References M_PI.

void anim_x_y_z2mat mat_t  m,
double  x,
double  y,
double  z
 

Make a rotation matrix corresponding to a rotation of "x" radians about the x-axis, "y" radians about the y-axis, and then "z" radians about the z-axis.

ANIM_X_Y_Z2MAT

Definition at line 561 of file anim.c.

void anim_dx_y_z2mat mat_t  m,
double  x,
double  y,
double  z
 

Make a rotation matrix corresponding to a rotation of "x" degrees about the x-axis, "y" degrees about the y-axis, and then "z" degrees about the z-axis.

ANIM_DX_Y_Z2MAT

Definition at line 590 of file anim.c.

References M_PI.

void anim_zyx2mat mat_t  m,
const vect_t  a
 

Definition at line 622 of file anim.c.

void anim_z_y_x2mat mat_t  m,
double  x,
double  y,
double  z
 

Make a rotation matrix corresponding to a rotation of "z" radians about the z-axis, "y" radians about the y-axis, and then "x" radians about the x-axis.

ANIM_Z_Y_X2MAT

Definition at line 656 of file anim.c.

void anim_dz_y_x2mat mat_t  m,
double  x,
double  y,
double  z
 

Make a rotation matrix corresponding to a rotation of "z" degrees about the z-axis, "y" degrees about the y-axis, and then "x" degrees about the x-axis.

ANIM_DZ_Y_X2MAT

Definition at line 685 of file anim.c.

References M_PI.

void anim_quat2mat mat_t  m,
const hvect_t  qq
 

void anim_dir2mat mat_t  m,
const vect_t  d,
const vect_t  d2
 

Definition at line 759 of file anim.c.

References VDIVIDE_TOL, VMOVE, and VSET.

void anim_dirn2mat mat_t  m,
const vect_t  dx,
const vect_t  dn
 

Definition at line 809 of file anim.c.

References bu_log(), MAGNITUDE, VDIVIDE_TOL, VMOVE, and VSET.

Referenced by anim_steer_mat().

Here is the call graph for this function:

int anim_steer_mat mat_t  mat,
vect_t  point,
int  end
 

Definition at line 885 of file anim.c.

References anim_dirn2mat(), ASM_EMPTY, ASM_FIRST, ASM_FULL, state, VMOVE, VSET, and VSUBUNIT.

Here is the call graph for this function:

void anim_add_trans mat_t  m,
const vect_t  post,
const vect_t  pre
 

Definition at line 947 of file anim.c.

void anim_rotatez fastf_t  a,
vect_t  d
 

Definition at line 959 of file anim.c.

void anim_mat_print FILE *  fp,
const mat_t  m,
int  s_colon
 

Definition at line 974 of file anim.c.

References bu_flog().

Here is the call graph for this function:

void anim_mat_printf FILE *  fp,
const mat_t  m,
const char *  formstr,
const char *  linestr,
const char *  endstr
 

Definition at line 992 of file anim.c.

References bu_flog().

Here is the call graph for this function:

void anim_view_rev mat_t  m  ) 
 

Definition at line 1012 of file anim.c.

int bn_decode_mat mat_t  m,
const char *  str
 

Referenced by bn_math_cmd(), db_tcl_tree_parse(), and vo_rmat_cmd().

int bn_decode_quat hvect_t  q,
const char *  str
 

Referenced by bn_math_cmd(), vo_orientation_cmd(), and vo_pov_cmd().

int bn_decode_vect vect_t  v,
const char *  str
 

Referenced by bn_math_cmd(), rt_tcl_parse_ray(), vo_aet_cmd(), vo_center_cmd(), vo_eye_cmd(), vo_eye_pos_cmd(), vo_keypoint_cmd(), vo_lookat_cmd(), vo_m2vPoint_cmd(), vo_mrot_cmd(), vo_mrotPoint_cmd(), vo_pov_cmd(), vo_rot_cmd(), vo_setview_cmd(), vo_slew_cmd(), vo_tra_cmd(), vo_v2mPoint_cmd(), and vo_vrot_cmd().

int bn_decode_hvect hvect_t  v,
const char *  str
 

Referenced by bn_math_cmd().

void bn_encode_mat struct bu_vls vp,
const mat_t  m
 

Definition at line 102 of file bn_tcl.c.

References bu_vls_printf(), bu_vls_putc(), and NULL.

Referenced by bn_math_cmd(), db_tcl_tree_describe(), vo_model2view_cmd(), vo_pmat_cmd(), vo_pmodel2view_cmd(), vo_rmat_cmd(), and vo_view2model_cmd().

Here is the call graph for this function:

void bn_encode_quat struct bu_vls vp,
const hvect_t  q
 

Definition at line 115 of file bn_tcl.c.

References bu_vls_printf(), and V4ARGS.

Referenced by bn_math_cmd().

Here is the call graph for this function:

void bn_encode_vect struct bu_vls vp,
const vect_t  v
 

Definition at line 121 of file bn_tcl.c.

References bu_vls_printf(), and V3ARGS.

Referenced by bn_math_cmd(), rt_tcl_pr_hit(), vo_aet_cmd(), vo_center_cmd(), vo_eye_cmd(), vo_keypoint_cmd(), vo_m2vPoint_cmd(), vo_mrotPoint_cmd(), vo_v2mPoint_cmd(), vo_viewDir_cmd(), and wdb_ocenter_cmd().

Here is the call graph for this function:

void bn_encode_hvect struct bu_vls vp,
const hvect_t  v
 

Definition at line 127 of file bn_tcl.c.

References bu_vls_printf(), and V4ARGS.

Referenced by bn_math_cmd().

Here is the call graph for this function:

void bn_tcl_setup  ) 
 

Referenced by Bn_Init().

int Bn_Init  ) 
 

void bn_tcl_mat_print  ) 
 

Referenced by wdb_showmats_cmd().

int anim_mat2quat quat_t  quat,
const mat_t  viewrot
 

This interprets the rotational part of a 4x4 transformation matrix in terms of unit quaternions. The result is stored as a vector in the order x,y,z,w. The algorithm is from Ken Shoemake, Animating Rotation with Quaternion Curves, 1985 SIGGraph Conference Proceeding, p.245.

ANIM_MAT2QUAT

Definition at line 328 of file anim.c.

References QMAGSQ, W, X, Y, and Z.

void anim_quat2mat mat_t  m,
const quat_t  qq
 

Definition at line 721 of file anim.c.

References QMOVE, quat_t, QUNITIZE, VADD2N, W, X, Y, and Z.


Generated on Mon Sep 18 01:25:22 2006 for BRL-CAD by  doxygen 1.4.6