00001 #ifndef _MDTKEA_H 00002 #define _MDTKEA_H 00003 /* 00004 Copyright Mathengine 2000 00005 00006 $Name: t-release-0-0-5-msvcrt $ 00007 00008 $Id: MdtKea.h,v 1.55 2000/08/04 15:19:30 williamg Exp $ 00009 */ 00010 00011 /** @file 00012 * 00013 * Kea solver header file. 00014 * 00015 * For explanation of some notation see "Programming From 00016 * Specifications" by Carroll Morgan. 00017 */ 00018 00019 #include "MePrecision.h" 00020 00021 #define MdtKeaBODYVER1 100 00022 00023 /** 00024 * Kea Constraints structure. 00025 * 00026 * To find the total number of @a rows_to_allocate, find the maximum 00027 * number of rows the constraints can add, but allow up to an extra 00028 * three rows padding per partition. 00029 */ 00030 typedef struct 00031 { 00032 /** 00033 * Number of partitions described by this structure. 00034 */ 00035 int num_partitions; 00036 00037 /** 00038 * num_rows_partition[i] is number of rows in partition i. 00039 * 00040 * The size should be one int for each partition. 00041 */ 00042 int *num_rows_partition; 00043 00044 /** 00045 * num_constraints_partition[i] is number of constraints in 00046 * partition i. 00047 * 00048 * The size should be one int for each partition. 00049 */ 00050 int *num_constraints_partition; 00051 00052 /** 00053 * Total number of constraint rows. 00054 * 00055 * (+ | 0<=i<num_partitions . num_rows_partition[i]) 00056 */ 00057 int num_rows; 00058 00059 /** 00060 * Total number of constraints. 00061 * 00062 * (+ | 0<=i<num_partitions . num_constraints_partition[i]) 00063 */ 00064 int num_constraints; 00065 00066 /** 00067 * List of nonzero blocks of jacobian matrix. 00068 * 00069 * The size should be 18 MeReals for 00070 * each rows_to_allocate, initialised to 0. 00071 */ 00072 MeReal *Jstore; 00073 00074 /** 00075 * Constraint error vector. 00076 * 00077 * One MeReal for each rows_to_allocate initialised to 0. 00078 */ 00079 MeReal *xi; 00080 00081 /** 00082 * Vector in the constraint equation m{J*v=c}. 00083 * 00084 * One MeReal for each rows_to_allocate initialised to 0. 00085 */ 00086 MeReal *c; 00087 00088 /** 00089 * Low limit on Lagrange multiplier. 00090 * 00091 * One MeReal for ebach rows_to_allocate initialised to 0. 00092 */ 00093 MeReal *lo; 00094 00095 /** 00096 * High limit on Lagrange multiplier. 00097 * 00098 * One MeReal for each rows_to_allocate initialised to 0. 00099 */ 00100 MeReal *hi; 00101 00102 /** 00103 * Calculated Lagrange multiplier READ ONLY. 00104 * 00105 * One MeReal for each rows_to_allocate initialised to 0. 00106 */ 00107 MeReal *lambda; 00108 00109 /** 00110 * Vector of forces applied to satisfy constraints READ ONLY. 00111 * 00112 * 24 MeReals for each constraint added initialised to 0. 00113 * Currently disabled on PS2. 00114 */ 00115 MeReal *force; 00116 00117 /** 00118 * First order constraint slipping vector. 00119 * 00120 * One MeReal for each rows_to_allocate initialised to 0. 00121 */ 00122 MeReal *slipfactor; 00123 00124 /** 00125 * Projection constants. 00126 * 00127 * One MeReal for each rows_to_allocate initialised to 0. 00128 */ 00129 MeReal *xgamma; 00130 00131 /** 00132 * Jsize[i] is the number of rows in constraint i. 00133 * 00134 * One int for each constraint added. 00135 */ 00136 int *Jsize; 00137 00138 /** 00139 * Offset of constraint i from the start of its partition. 00140 * 00141 * partition_start+Jofs[i] is the offset in the above vectors of the 00142 * first element corresponding to constraint i, where partition_start 00143 * is the offset of the first constraint in the partition which i 00144 * belongs to. One int for each constraint added 00145 */ 00146 int *Jofs; 00147 00148 /** 00149 * Jbody[i*3+0],Jbody[i*3+1],Jbody[i*3+2] are the bodies 00150 * constrained by constraint i. 00151 * 00152 * 3 ints for each constraint added. 00153 */ 00154 int *Jbody; 00155 } 00156 MdtKeaConstraints; 00157 00158 /** 00159 * Kea Parameters structure. 00160 */ 00161 typedef struct 00162 { 00163 /** Amount of time to evolve system by. */ 00164 MeReal stepsize; 00165 00166 /** Numerical tolerance used by matrix solver. Default = 0.01. */ 00167 MeReal epsilon; 00168 00169 /** Constraint relaxation rate. Default = 0.2. */ 00170 MeReal gamma; 00171 00172 /** 00173 * Pointer to some memory that Kea can use. 00174 * 00175 * Kea doesn't malloc, only uses this area. 00176 */ 00177 void *memory_pool; 00178 00179 /** Size of this area in bytes. */ 00180 unsigned int memory_pool_size; 00181 } 00182 MdtKeaParameters; 00183 00184 /** 00185 * Kea Body structure. 00186 * 00187 * After a time step, the contents of 'force' and 'torque' will be the 00188 * total applied forces plus any forces and torques due to constraints. 00189 * These MUST BE RE-ZEROED before accumulating values for the next time 00190 * step. 00191 */ 00192 typedef struct 00193 { 00194 /** Data stucture tag. Should be MdtKeaBODYVER1. */ 00195 int tag; /* 0x00*/ 00196 /** Total length of data structure. */ 00197 int len; 00198 00199 /** 1/Mass of the body. */ 00200 MeReal invmass; 00201 00202 /** Nonzero applies fast rotation hack. */ 00203 int fastSpin; 00204 00205 /** Applied (to centre of mass) force. */ 00206 MeVector4 force; /* 0x10 */ 00207 00208 /** Applied torque. */ 00209 MeVector4 torque; /* 0x20 */ 00210 00211 /** Inverse of 3x3 inertia tensor - row 0. */ 00212 MeVector4 invI0; /* 0x30 */ 00213 /** Inverse of 3x3 inertia tensor - row 1. */ 00214 MeVector4 invI1; /* 0x40 */ 00215 /** Inverse of 3x3 inertia tensor - row 2. */ 00216 MeVector4 invI2; /* 0x50 */ 00217 00218 /** The 3x3 inertia tensor - row 0. */ 00219 MeVector4 I0; /* 0x60 */ 00220 /** The 3x3 inertia tensor - row 1. */ 00221 MeVector4 I1; /* 0x70 */ 00222 /** The 3x3 inertia tensor - row 2. */ 00223 MeVector4 I2; /* 0x80 */ 00224 00225 /** Linear velocity of body. */ 00226 MeVector4 vel; /* 0x90 */ 00227 /** Angular velocity of body. */ 00228 MeVector4 velrot; /* 0xa0 */ 00229 /** Body orientation quaternion. */ 00230 MeVector4 qrot; /* 0xb0 */ 00231 00232 /** Linearl Acceleration of body (READ ONLY). */ 00233 MeVector4 accel; /* 0xc0 */ 00234 /** Angular acceleration of body (READ ONLY). */ 00235 MeVector4 accelrot; /* 0xd0 */ 00236 00237 /** Axis of assumed fast rotation (unit length). */ 00238 MeVector4 fastSpinAxis; /* 0xe0 */ 00239 } 00240 MdtKeaBody; 00241 00242 /** 00243 * Kea 4x4 Transformation Matrix. 00244 */ 00245 typedef struct 00246 { 00247 /** Rotation matrix row 0 (last element 0). */ 00248 MeVector4 R0; 00249 /** Rotation matrix row 1 (last element 0). */ 00250 MeVector4 R1; 00251 /** Rotation matrix row 2 (last element 0). */ 00252 MeVector4 R2; 00253 /** Position vector (last element 1). */ 00254 MeVector4 pos; 00255 } 00256 MdtKeaTransformation 00257 #ifdef PS2 00258 __attribute__((aligned(16))) 00259 #endif 00260 ; 00261 00262 #ifdef __cplusplus 00263 extern "C" 00264 { 00265 #endif 00266 00267 /** 00268 * Utility function for calculating the size of the workspace needed by 00269 * Kea. 00270 * 00271 * This memory is passed into Kea in the MdtKeaParameters structure. 00272 */ 00273 int MdtKeaMemoryRequired(int *num_rows_partition, int num_partitions); 00274 00275 /** 00276 * Kea solver function. 00277 * 00278 * Takes an array of bodies and a MdtKeaConstraints struct (which 00279 * defines the constraints as defined above), as well as an array 00280 * indicating which constraints are to be solved together as one 00281 * partition. It solves each partition and evolves the system. 00282 * 00283 * @param constraints A MdtKeaConstraints struct containing constraint 00284 * rows generated by MdtBcl functions. 00285 * @param blist Array of MdtKeaBody structs to be simulated. 00286 * @param tlist Array of MdtKeaTransformation structs that correspond to 00287 * blist. 00288 * @param num_bodies Number of bodies/transformations in blist/tlist 00289 * @param parameters A MdtKeaParameters structure containing stepsize, 00290 * memory pool etc. 00291 */ 00292 void MdtKeaStep(MdtKeaConstraints constraints, 00293 MdtKeaBody *blist, 00294 MdtKeaTransformation *tlist, 00295 int num_bodies, 00296 MdtKeaParameters parameters); 00297 00298 #ifdef __cplusplus 00299 } 00300 #endif 00301 00302 #endif
Copyright MathEngine PLC 2000, all rights reserved.