Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6.11. Function accelerateBody Summary This function will determine the acceleration of a single body from all the resultant gravitational forces acting on it from the

image text in transcribed

6.11. Function accelerateBody Summary This function will determine the acceleration of a single body from all the resultant gravitational forces acting on it from the other bodies. This will cause the body to change its direction by being drawn toward bodies with a higher mass, and therefore a higher gravitational pull Since force = mass x acceleration,then acceleration = force / mass. Note that acceleration generally means a change in velocity Even a negative acceleration can be called acceleratiorn Do this Add an accelerateBody function with a single parameter: the body numbeir. To calculate the total force on a body, you must add up all the separate forces on a body by all bodies other than itseltA Start a for loop that does this For each body number in the range NBodies If that body number is not equal to the body number parameter: Calculate the force on the body by calling calculateForce. That function returns two values. You can capture them in variables like this c, d-calculateForce(a, b) but don't use those variable names literally. That's just an example of how to do it. Calculate the x & y accelerations. Create new variables for this. Thex acceleration is the force in the x direction divided by the mass of the body (the body is the one specified by the body number parameter). Do the same for the y acceleration -Add the x & y accelerations to the x and y velocities of the body (You know where to find those, right?) The bodyis the one specified by the body number parameter. And don't just add the accelerations to the velocities, you must add and then store the sums back into the respective lists 6.11. Function accelerateBody Summary This function will determine the acceleration of a single body from all the resultant gravitational forces acting on it from the other bodies. This will cause the body to change its direction by being drawn toward bodies with a higher mass, and therefore a higher gravitational pull Since force = mass x acceleration,then acceleration = force / mass. Note that acceleration generally means a change in velocity Even a negative acceleration can be called acceleratiorn Do this Add an accelerateBody function with a single parameter: the body numbeir. To calculate the total force on a body, you must add up all the separate forces on a body by all bodies other than itseltA Start a for loop that does this For each body number in the range NBodies If that body number is not equal to the body number parameter: Calculate the force on the body by calling calculateForce. That function returns two values. You can capture them in variables like this c, d-calculateForce(a, b) but don't use those variable names literally. That's just an example of how to do it. Calculate the x & y accelerations. Create new variables for this. Thex acceleration is the force in the x direction divided by the mass of the body (the body is the one specified by the body number parameter). Do the same for the y acceleration -Add the x & y accelerations to the x and y velocities of the body (You know where to find those, right?) The bodyis the one specified by the body number parameter. And don't just add the accelerations to the velocities, you must add and then store the sums back into the respective lists

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

Define present value of an ordinary annuity.

Answered: 1 week ago