Thursday, July 30, 2009

How do i simulate a Nasa space shuttle based on debris impact in C++?

The program will define a two dimensional incident zones, one for the shuttle’s wing section and the body. These 2-D incident zones provide a coordinate system that identifies the location of random debris in the shuttle’s forward path. The identifying locations within a zone are called cells, as illustrated in the diagram below, and is identified by two coordinates for the x and y dimensions.





Each cell has an associated “impact resistance factors” (IRF) for tiles located in the shuttle’s body and wing sections. The IRF is a hardness measure of the various tiles, and a higher IRF indicates a harder tile. An IRF %26lt; 0 indicates that a particle cannot make contact with the shuttle in the corresponding cell and zone. Important: Assume that a particle passing through a cell will strike the shuttle if any part of that cell contains part of the shuttle.


program will perform the following actions for each simulated particle:


a) Randomly select whether the particle is incident on the wing or body. A given particle can only be incident on one. Keep track of the total particle incidents for each incident zone during the simulation.


b) Randomly generate valid x and y coordinates for the incident zone which indicate that the current debris particle in the simulation is incident in the (x, y) cell of the body or wing zone (randomly selected in the previous step).


c) Keep a count Cx,y of the total debris incidents for each body and wing cell.


d) Generate a random force F, where 0 %26lt; F %26lt; 0.50 for each particle incident. F is the force of impact if the particle collides with the shuttle’s ceramic tile.


e) Maintain the average force, (FAVG)x,y in per-cell detail of particles that impact the shuttle

How do i simulate a Nasa space shuttle based on debris impact in C++?
Correlate each of these points with the specific portions of the question based on the numbering.


a) Fix the number of tiles you have in a shuttle (say N). Generate a random number using a pseudo Random number generator (lets call it R1). If the random number generated is between 0-1/N then the particle strikes tile 1, between 1/N-2/N it strikes tile 2 and so on... (that answers both a and b)


b) Maintain a counter per tile to record the number of hits.


c) Use another random number generator (R2) to generate the force of the particle hitting the tile.





So you need a tile structure which looks like this:


class Tile


{


private:


int x, y; //location


int hitCount;


double averageForce;


public:


Tile(int x = 0, int y = 0) : x(x), y(y) {}


~Tile () {}


void setLocation (int x, int y); // to set the co-ordinates


void hit (double force); // this should recompute average force


};





main()


{


Tile tiles[1000]; //how many ever you want.


for (int i = 0; i %26lt; 1000; i++)


//set location of all tiles





while (...)


{


double r1 = random ();


double force = drand48(); // use appropriate seeds


if (r1 %26lt; 1/1000)


tiles[0].hit (force);


}


}


No comments:

Post a Comment