cpp2_code_f07 - USERNAME NAME_E2 1(15 pts This refers to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: USERNAME ___________________ NAME ________________________________E2 1.(15 pts) This refers to pro6. Add a new method called Perpendicular2D() to the Vector class. Here is an example. Vector v1(1,1,0); Vector v2; v2 = v1.Perpendicular2D(); This method returns a vector that is perpendicular to vector v1. We will only consider the 2-dimensional case (z-component is 0). If v1 was 3- dimensional, then the method would return a zero vector (all components are zero). For the sake of simplicity, we will assume that the calling vector (v1 in the above example) is on the first quadrant ( , > ≥ y x ). To find the perpendicular vector: rotate the original vector 90 in counter-clockwise direction, as shown in the figure. Hint: In your solution, you can use the constructor that takes a magnitude and an angle as arguments. Sample Run: Vector v1(1,1,0), v3(1,1,2); Vector v2; v2 = v1.Perpendicular2D(); // v2 will be ( -1, 1, 0) v2 = v3.Perpendicular2D(); // v2 will be (0,0,0) --------------------------------------------- Your Solution --------------------------------------------...
View Full Document

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 3

cpp2_code_f07 - USERNAME NAME_E2 1(15 pts This refers to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online