You will write three functions that tell how two circles lie, count their common tangents and find the lengths of their common tangents. The checker uses the circles of the lesson.
The idea. Let be the distance of the centres. The number of common tangents is , , , or as is more than , equal to it, between and , equal to , or less than it. A direct tangent has length and a transverse tangent has length .
Your tasks.
count_tangents(d, r1, r2). Return the number of common tangents. Compare with a small tolerance, because the numbers are decimals.direct_length(d, r1, r2). Return the length of a direct tangent, or None if there is none.transverse_length(d, r1, r2). Return the length of a transverse tangent, or None if there is none.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…