You will write functions that say where a point is against a circle, find the length of a chord cut by a line, and find the length of a tangent. The checker uses the circles of the lessons.
The idea. For the circle with centre and radius , the number is negative inside, zero on the circle and positive outside. The distance of the centre from a line is . The chord is , and the tangent is .
Your tasks.
power(px, py, h, k, r) to return .chord_length(a, b, c, h, k, r) to return the length of the chord that the line cuts, or 0 if the line does not cut the circle.tangent_length(px, py, h, k, r) to return the length of the tangent from the point, or None if the point is not outside.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…