Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Language Please!! Requirements (Read Carefully) Define a structure data type that holds three double data members (x,y,z). Define an alias for this data type

C Language Please!!

Requirements (Read Carefully)

Define a structure data type that holds three double data members (x,y,z).

Define an alias for this data type named vector (using typedef).

Create a function named initVect that receives three double numbers and returns vector structure initialized with the values passed to the function where the first parameter is the value for data member x and the last one for data member z.

Create a function named invVect that takes a vector structure and returns the inverse of the vector (negative value of each data member: x,y,z).

Create a function named normVect that takes a vector structure and returns the Euclidean norm of the vector defined as:

|v|=x2+y2+z2?????????????|v|=x2+y2+z2

Create a function named addVect that takes two vector structures and returns a vector structure with the sum of both vectors passed to the function.

Create a function named distVect that takes two vector structures and returns the Euclidean distance between the two vectors defined as:

distance=(x2?x1)2+(y2?y1)2+(z2?z1)2??????????????????????????????????distance=(x2?x1)2+(y2?y1)2+(z2?z1)2

Create a function named prodVect that takes two vector structures and returns the scalar product of both vectors defined as:

v1?v2=x1?x2+y1?y2+z1?z2v1?v2=x1?x2+y1?y2+z1?z2

Create a function named projVect that takes two vector structures and returns the scalar projection of the first vector onto the second vector defined below. If the norm of v2 is zero then return 0.

proj=v1?v2|v2|proj=v1?v2|v2|

Create a function named angleVect that takes two vector structures and returns the angle in degrees between the two vectors defined below. For computing the cosine inverse use the function acos. Use PI = 3.14159265. If the norm of any of the two vectors is zero then return 0.

angle=cos?1(v1?v2|v1||v2|)?180?angle=cos?1?(v1?v2|v1||v2|)?180?

Tasks (Read Carefully)

Create a program that reads two vectors from the user as follows:

(10.4, 7.4, 3.0) (1.4, 2.4, 1.3) 

Then have your program output the following (add ' ' after every line):

v1: (10.40, 7.40, 3.00) v2: (1.40, 2.40, 1.30) v2 + v1: (11.80, 9.80, 4.30) v2 - v1: (-9.00, -5.00, -1.70) norm(v1): 13.11 norm(v2): 3.07 dist(v1,v2): 10.44 prod(v1,v2): 36.22 proj(v1,v2): 11.81 proj(v2,v1): 2.76 angle(v2,v1): 25.77 

image text in transcribed

C Language Please!!

Define an alias for this data type named vector (using typedef) Create a function named initVect that receives three double numbers and returns vector structure initialized with the values passed to the function where the first parameter is the value for data member x and the last one for data member z. Create a function named invVect that takes a vector structure and returns the inverse of the vector (negative value of each data member: xyz) . .Create a function named normVect that takes a vector structure and returns the Euclidean norm of the vector defined as Create a function named addVect that takes two vector structures and returns a vector structure with the sum of both vectors passed to the function. . Create a function named distVect that takes two vector structures and returns the Euclidean distance between the two vectors defined as istance - V (2-xl) +02-yl)? +(2-21)2 Create a function named prodVect that takes two vector structures and returns the scalar product of both vectors defined as Create a function named projVect that takes two vector structures and returns the scalar projection of the first vector onto the second vector defined below. If the norm of v2 is zero then return 0 proj = Iv2| Create a function named angleVect that takes two vector structures and returns the angle in degrees between the two vectors defined below. For computing the cosine inverse use the function acos. Use Pl = 3.14159265. If the norm of any of the two vectors is zero then return 0 vl v2 180 angle cos1

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

What is the timeline for each tactic?

Answered: 1 week ago