Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ qustions! Ask the user to input a number n. This will be the number of interpolation vectors to compute, as explained below. The value

C++ qustions!

image text in transcribedimage text in transcribedimage text in transcribed

Ask the user to input a number n. This will be the number of "interpolation vectors" to compute, as explained below. The value n should be a positive integer that is at least 2, but you do not need to validate this input Then call interpolateVectors n times with (ui, vi, /i) and (u2, v2, /2) always being the normalized user-input vectors, and a taking on successive, equally spaced values between 0.0 and 1.0, inclusive. For example, if n is 5, then interpolateVectors should be called 5 times with a being 0.0, .25, .5, .75, and 1.0. Each call to interpolateVectors will pass back a vector through the pass-by-reference variables. Your program should print these vectors as shown in the example below: with each value having four digits to the right of the dec- imal point (use cout.setf (ios: :fixed) etc.), and in a field of width 8 (use setw (8)) Here is an example showing the input and output text and formatting. As usual, follow it exactly, and all spaces are single-spaces. Input the first vector u1 v1 w1: 1.01.00.0 Input the second vector u2 v2 w2: 2.0-1.0 2.0 Enter the number of interpolation vectors to compute: 5 Interpolation vectors Input the first vector ul vl w1: 1.0 1.0 0.0 Input the second vector u2 v2 w2: 2.0 -1.0 2.0 Enter the number of interpolation vectors to compute: 5 Interpolation vectors 0.7071 0.7071 0.0000 0.8252 0.5292 0.1973 0.8739 0.2378 0.4241 0.8013-0.0867 0.5920 0.6667-0.3333 0.6667 Here's an example of the output when the input validation fails: Input the first vector u1 v1 w1: 1.01.01.0 Input the second vector u2 v2 w2: 0.0 0.00.0 Vectors must be non-zero Comments None of the functions should be especially long. If you find yourself writing large amounts of code, think about whether you are writing the functions efficiently. Implement your solution incrementally, for example, make sure you get the length function working before beginning to write the normalize function. Then get the normalize function working before writing the interpolate function. (This program has a large number of parts, but should not be extremely difficult if you break the problem up into these subparts, and implement the subparts incrementally.) Some functions (in particular vectorLength) are very simple. However, make sure you follow the problem instructions here; for example, do not skip writing the length function by doing the length calculation directly in the normalize function

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions