You will write three functions for a vector given as a tuple of three numbers: its magnitude, its unit vector and its direction angles. The checker tests them on several vectors, including ones with negative components.
The idea. The magnitude is the square root of the sum of the squares of the components. The unit vector divides every component by the magnitude. The angle with an axis is the inverse cosine of the matching direction cosine.
Your tasks.
magnitude(v). Return .unit_vector(v). Return a tuple of three numbers.direction_angles(v). Return the three angles in degrees, as a tuple.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…