Question: For python E1.6 Programming: Lines and segments (30 points) In this exercise you are asked to begin implementing a number of basic algorithms that perform
For python

E1.6 Programming: Lines and segments (30 points) In this exercise you are asked to begin implementing a number of basic algorithms that perform geometric computa tions. Consider the following planar geometry functions: computeLineThroughTwoPoints (10 points) Input: two distinct points pi - (x1, yi) and p2- (x2, y2) on the plane. Output: parameters (a, b, c) defining the line {(x, y) | ar +by +c 0 that passes through both pi and p2 Normalize the parameters so that a2 +b2-1. computeDistancePointToLine (10 points) Input: a point q and two distinct points pi - (xi,/i) and p2 -(x2, 32) defining a line Output: the distance from q to the line defined by Pi and p2 computeDistancePointToSegment (10 points) Input: a point q and a segment defined by two distinct points (P1,P2) utput: the distance from q to the segment with extreme points (Pi, P2 For each function, do the following (i) explain how to implement the function, possibly deriving analytic formulas, and characterize special cases, (ii) program the function, including correctness checks on the input data and appropriate error messages, and (iii) verify your function is correct on a broad range of test inputs Hints: To check two points are distinct, use a tolerance equal to 0.18. Regarding computeDistancePointToLine, compute the orthogonal projection of q onto the line. Regarding computeDistancePointToSegment, the distance depends on whether or not the orthogonal projection ofq onto the line defined by p andp2 belongs or not to the segment between p and p2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
