#| Quiz 3 |# ;; #1 (message " Finding a norm of a difference: ") (def v (vector 4 -7)) (def w (vector -2 9)) (norm (calc v - w)) ;; #2 (message " Ahoy Mates! Cap'n Flint wants to know: where did I put that treasure? ") (def v (vector 0 30)) (def w (vector 25 25)) ;; 45 degree angle! (def x (vector 0 -10)) (norm (calc v + w + x)) ;; #3 (message " Planes, and vectors perpendicular and parallel to them: ") (message " Strategy: Rewrite the equation of the plane as 3*(x - 0) + -1*(y - 0) + -1*(z - 2) = 0 Thus (0,0,2) is a point in the plane, and form a vector of any point in the plane, e.g. (x,y,z), and (0,0,2), which is perpendicular to (3,-1,-1) and hence parallel to the plane. So, for example, setting z=2 and x=1 gives y=3, so (1,3,0) is a vector parallel to the plane. ") (def perp (vector 3 -1 -1)) (def para (vector 1 3 0)) (dot para perp) (message " Here's another way of getting at it: by finding the zero of a function: ") (def x 1) (def y 1) (func f(z) 3 * (x - 0) + -1 * (y - 0) + -1 * (z - 2)) (roots f 0) (message " I tested your parallel vectors using this function: ") (defun vec-tester (x y z) (print (vector x y z)) (dot perp (vector x y z)) ) (alias3 vt vec-tester) (vt 1 3 3) (vt 1 0 3) (vt 2 3 3) (vt 1 3 -1) (vt 1 2 1) (vt 4 4 2) (message " Some of you looked for other points in the plane: I tested those with a plane function: ") (func plane(x y z) 3 * (x - 0) + -1 * (y - 0) + -1 * (z - 2)) ;; (plane 1 -1 6) (plane -1 -3 0) ;; (plane 1 1 5) (plane 2 4 4) ;; (plane 1 2 3)