PLEASE MAKE SURE THAT THE PROGRAM IS COMPILABLE BEFORE YOU SUBMIT YOUR ANSWER AN
ID: 3532606 • Letter: P
Question
PLEASE MAKE SURE THAT THE PROGRAM IS COMPILABLE BEFORE YOU SUBMIT YOUR ANSWER AND ALSO IF YOU COULD INCLUDE SAMPLE RUNS THAT WOULD BE GREAT!!!!!
IT LOOKS LONG BUT IT WILL BE PRETTY EASY FOR DECENT COMPUTER PROGRAMMERS!!!
Vector Operations. Vectors are often represented as one-dimensional arrays of three elements each.For example, the vectors a and b can be written in terms of their components:
a=(a1, a2, a3) and b=(b1, b2, b3)
There are a number of useful operations that can be performed on vectors.
(YOU SHOULD ASSUME THROUGHOUT THAT ALL QUANTITIES ARE DOUBLES)
a.) Vector Equality.
a = b (a1=b1,a2=b2,a3=b3)
Write an int function vector_equality() that takes two vectors as arguments and returns 1 if the vectors are equal, 0 otherwise.
b.) Multiplication by a scalar. If a is a vector and s is a scalar (constant), the product of a and s is a vector given by:
sa=(sa1, sa2, sa3)
Write a function mult_by_scalar() that returns the scalar product of the vector.
c.) Vector Addition. The sum of two vectors a and b is another vector given by:
a+b=(a1+b1,a2+b2,a3+b3)
Write a function vector_sum() that adds two vectors and puts the result into a third vector.
d.)Vector Magnitude. The magnitude or length of the vector a, denoted |a|, is given by:
|a|=sqrt(a1^2 + a2^2 + a3^2)
Write a double function vector_mag() that returns the magnitude of the vector.
e.) Vector dot product. The dot product of two vectors a and b is the sum of the products of the corresponding components of the vectors:
a * b=a1*b1,a2*b2,a3*b3
Write a double function dot_prod() that returns the dot product of two vectors.
f.)Vector cross product. The cross product of two vectors a and b is another vector:
a*b=((a2*b3)-(a3*b2),(a3*b1)-(a1*b3),(a1*b2)-(a2*b1))
Write a double function cross_prod() that returns the cross product of two vectors.
Explanation / Answer
//here you go
http://ideone.com/11mgFv
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.