Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the earlier team project (Lab 02), your team created a program that interpolated between two values. This was a one dimensional (1D) interpolation, since

In the earlier team project (Lab 02), your team created a program that interpolated between two values. 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 linearly interpolate between two points in 3D. Let's 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) Write a program that takes two observed 3D positions at two points in time, and then calculates the 3D position at a third point in time. 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. Save this as Program2a. For this initial program, store the following data values as variables: At time 13, the observed position was (1, 3, 7) At time 84, the observed position was (23, -5, 10) Find the position at time 50 Example output (yours does not have to look identical): Time of interest = 50 seconds x0 = 12.464788732394366 m y0 = -1.169014084507042 m z0 = 8.56338028169014 m b) Now, copy Program2a into a new program, Program2b. Modify the program as follows: When outputting the position, follow the output by a line of dashes ("------------------"). Instead of computing the interpolation at one point and printing the result, compute it at 5 points. Copy the portion of the code (cut and paste the code) that is needed to recompute the interpolation 5 times. You should now interpolate at the times in increments of 1 unit, starting at time 50 (i.e. at times 50, 51, 52, 53, 54), outputting the result each time. The line of dashes will separate each computation. Note: later we will see how we can do this more efficiently, without cutting-and-pasting code, but for now, cut-and-paste is fine. Example output, first two times only (yours does not have to look identical): 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 ------------------------------ (continued, next page) c) Finally, copy Program2b into a new program, Program2c. Modify the program as follows: Create a variable for the starting time of interpolation, and another for the ending time of interpolation. Display the results from interpolation at 6 points, evenly spaced from the beginning time to the ending time, inclusive. Experiment on your own with assigning different values to those variables and verify that you are in fact interpolating correctly from one point to another. For the version you save and turn in, use variable values that show an interpolation from time 20 to 60. Example output, first two times only (yours does not have to look identical): 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 ------------------------------. No idea how to do this? can I get some help?

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions