Extrapolation

New Message Reply Date view Thread view Subject view Author view

Reed Whittington (reedwhit++at++skips.dseg.ti.com)
Tue, 22 Mar 94 18:36:31 CST


This is an easy way to extrapolate for non uniform position updates.
It works if you know the velocity, accel, and frame rate.

/*
 * vehicle.h - public interface to vehicle.c
 */

#ifndef _VEHICLE_H_
#define _VEHICLE_H_

#include "xformer.h"
#include "ex_comm.h"

#define DEFAULT_MODEL_ID 30

/* vehicle entity object */

typedef struct Vehicle_s {
  Base_vehicle_t dis; /* information in from data pool (DIS) */
  pfDCS *dcs; /* parent dcs */
  pfNode *model_root; /* root to cloned visual model */
  pfCoord coord; /* current position and direction */
  double dt; /* delta time since last frame */
  pfuSmoke *smoke; /* each vehicle will have a smoke model */
  pfuSmoke *fire; /* each vehicle will have a fire model */
} Vehicle_t;

/* vehicle.c */
extern pfGroup* vehLoadLibrary(char *vehicle_dat);
extern void vehCheckIsect(void);
extern void vehProcess(void);
#endif

/*
 * extrapolate a new coord based on the last coord and the
 * current dis entity state.
 */
static void vehExtrapolate( Vehicle_t* veh )
{
   /* extrap xyh hpr */
   veh->coord.xyz[PF_X] = (veh->dis.lin_vel_xyz[PF_X] * veh->dt) +
                               veh->coord.xyz[PF_X];
   veh->coord.xyz[PF_Y] = (veh->dis.lin_vel_xyz[PF_Y] * veh->dt) +
                               veh->coord.xyz[PF_Y];

   veh->coord.hpr[PF_H] = (veh->dis.ang_vel_xyz[PF_Z] * veh->dt) +
                               veh->coord.hpr[PF_H];

   veh->coord.xyz[PF_Z] = (veh->dis.lin_vel_xyz[PF_Z] * veh->dt) +
                               veh->coord.xyz[PF_Z];
   veh->coord.hpr[PF_P] = (veh->dis.ang_vel_xyz[PF_X] * veh->dt) +
                               veh->coord.hpr[PF_P];
   veh->coord.hpr[PF_R] = (veh->dis.ang_vel_xyz[PF_Y] * veh->dt) +
                               veh->coord.hpr[PF_R];
}

********************************
Reed Whittington
Texas Instruments
Visual Simulation Technology Development
MS 8518
6620 Chase Oaks Blvd.
Plano, Texas 75086

(214) 575-6761 off
(214) 575-6771 fax
reedwhit++at++dseg.ti.com
********************************


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:13 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.