Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the earlier team project, your team put together a program that interpolated between two position values based on the time values when each positon

In the earlier team project, your team put together a program that interpolated between two position values based on the time values when each positon was observed. This was a one dimensional (1D) interpolation, since you were interpolating only a single value, the distance on the track. You are now going to extend that program to one that will linearly interpolate between two points in 3D. Lets say we are tracking the change of a particles position with time. So, at time t1 position is (x1, y1, z1) and at time t2 position is (x2, y2, z2). The question is what is the position (x0, y0, z0) at some time t0 between t1 and t2? Refer again to the Linear Interpolation material associated with LabAssignment2. That material describes the development of equation representing linear interpolation of a dependent variable y versus an independent variable x. For the current problem, what varies linearly with what? What are the dependent variable(s)? What are the independent variable(s)? Lets assume that each of the position variables (x, y, z) varies linearly with time (t). Therefore, time (t) is the independent variable in each case. This means we can perform linear interpolation three separate times to get what we need. This can be done in three steps: 1) linearly interpolate between (t1, x1) and (t2, x2) for t0 with x0 as the result; 2) repeat for (t1, y1) and (t2, y2) for t0 with y0 as the result; 3) repeat for (t1, z1) and (t2, z2) for t0 with z0 as the result. The result will be (x0, y0, z0) associated with time t0. a) (Please name this program Lab2b_Prog2a.py.) Write a program that will take two observed 3D positions at two points in time, and then will calculate the 3D position at a third point in time. Lets consider only times between the two observed times. You should output the x, y, and z values for that position on separate lines. Begin by identifying the variables you will use, the names for those variables, and the computations that should occur for those variables. Then, write a program that will output the 3D position of the interpolated point on 3 separate lines. For this initial program, you can use the following data values: At time 13, observed position was (1, 3, 7) meters At time 84, observed position was (23, -5, 10) meters You want to find the position at time 50 seconds As for Program 1 above, please document your code using comments and print data labels and units to the screen to identify your output. Sample output: time of interest = 50 seconds x0 = 12.464788732394366 m y0 = -1.169014084507042 m z0 = 8.56338028169014 m b) Now, copy Lab2b_Prog2a.py from above into a new program, Lab2b_Prog2b.py (please make a copy of the original file with a new name). You are going to modify the program in the following ways: a. When outputting the position, follow the output by a line of dashes (------------------). b. Instead of just computing the interpolation at one point and printing the result, you will now compute it at 5 points. Copy the portion of the code (cut and paste the code) that is needed to recompute interpolation 5 times. You should now interpolate at the times Lab Assignment #2b Based upon Dr. Keysers Original 4 Revised Summer 2019 TLF in increments of 1 second, starting at time 50 seconds (i.e. at times 50, 51, 52, 53, 54), outputting the result each time. The line of dashes will separate each computation. i. Note: later we will see how we can do this more efficiently, without cutting-andpasting code, but for now, cut-and-paste is fine. Sample output (first two times only): time of interest = 50 seconds x0 = 12.464788732394366 m y0 = -1.169014084507042 m z0 = 8.56338028169014 m --------------------- time of interest = 51 seconds x0 = 12.774647887323942 m y0 = -1.281690140845071 m z0 = 8.605633802816902 m --------------------- c) Finally, copy Lab2b_Prog2b.py into a new program, Lab2b_Prog2c.py (please make a copy of the original file with a new name). Modify the program in the following way: a. Create variables for the starting time of interpolation, and the ending time of interpolation. b. You should display the results from interpolating at 5 points, evenly spaced from the beginning time to the ending time, inclusive. c. Experiment on your own with assigning different values to those variables verify that you are in fact interpolating correctly from one point to another. d. For the version you save and turn in, show an interpolation from time 20 to 50 seconds. Sample output (first two times only): time of interest = 20 seconds x0 = 3.169014084507042 m y0 = 2.211267605633803 m z0 = 7.295774647887324 m --------------------- time of interest = 27.5 seconds x0 = 5.492957746478873 m y0 = 1.3661971830985915 m z0 = 7.612676056338028 m ---------------------

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

Students also viewed these Databases questions

Question

If x1 2, show that (xn) is convergent. What is its limit?

Answered: 1 week ago

Question

2. Identify the purpose of your speech

Answered: 1 week ago