Question: 6 0 - 8 0 : Extending the previous work with spring based ( Hooke s Law ) real - time dynamic simulation to self
: Extending the previous work with spring based Hookes
Law realtime dynamic simulation to selfsort the data
representations, thereby showing trading groups and relationships
as part of a resolved undirected graph. Spring Based Simulation
The simulation defined within this assignment
is a simple network of springs; evaluated once
for each of the simulation progressions.
These use the basic principles of Hookes law
spring force derived from extension and
Newtons Laws of Motion. Spring Algorithm
For each body loop through the nodes Reset
the resultant force f to zero
Spring Algorithm
Loop through each of the arcs.
Calculate the direction vector between the two nodes forming the arc
d as a normalised direction vector and the distance between the two
nodes l
Calculate the spring force Hookes Law
as a vector and accumulate these within the
nodes affected countries at either end
Calculate the vector force f for each node remember one of the
nodes will have a positive force and the other will have a negative
force according Newtons rd law of motion but multiplying the force
scalarf by the direction vector d
Add the calculated for vectors to their resultant force vectors for each
respective node.
Spring Algorithm
Loop through each of the nodes countries to:
Calculate the acceleration due to the spring force vector: Newtons
Second Law of Motion where f is the nodes resultant force
vector calculated in the previous loop through the arcs.
Calculate the motion of the body based on its velocity, the time frame
for the motion and the acceleration: General Equation of Motion
newtons st law of motion
Add the motion to the current body position:
Calculate the new velocity of the body
Apply damping
Calculate kinetic energy for body and accumulate to global record
optional: write the easy coding for c #include #include #include #include #include #include #include #include #include #include #include #include #include #include "raaConstants.h #include "raaParse.h #include "raaControl.h NOTES look should look through the libraries and additional files I have provided to familarise yourselves with the functionallity and code. The data is loaded into the data structure, managed by the linked list library, and defined in the raaSystem library. You will need to expand the definitions for raaNode and raaArc in the raaSystem library to include additional attributes for the siumulation process If you wish to implement the mouse selection part of the assignment you may find the camProject and camUnProject functions usefull core system global data raaCameraInput gInput; structure to hadle input to the camera comming from mousekeyboard events raaCamera gCamera; structure holding the camera position and orientation attributes raaSystem gSystem; data structure holding the imported graph of data you may need to modify and extend this to support your functionallity raaControl gControl; set of flag controls used in my implmentation to retain state of key actions int layoutView ; float cvYf cvYf cvYf cvYf cvYf cvYf; Stores the Y value of continents float wvYf wvYf wvYf; Stores the Y value of the worlds float upperNode ; A value assigned to a variable to structure the nodes aboev each other float newPosition; An array to store the new node position int countTimes ; global var: parameter name for the file to load const static char csgacFileParaminput"; global var: file to load data from char gacFile; core functions reduce to just the ones needed by glut as pointers to functions to fulfill tasks void display; The rendering function. This is called once for each frame and you should put rendering code here void idle; The idle function is called at least once per frame and is where all simulation and operational code should be placed void reshapeint iWidth, int iHeight; called each time the window is moved or resived void keyboardunsigned char c int iXPos, int iYPos; called for each keyboard press with a standard ascii key void keyboardUpunsigned char c int iXPos, int iYPos; called for each keyboard release with a standard ascii key void sKeyboardint iC int iXPos, int iYPos; called for each keyboard press with a non ascii key eg shift void sKeyboardUpint iC int iXPos, int iYPos; must be incldue in this coding. please give me the easy solution?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
