M2160-1 6^{th} Homework Assignment Due Apr. 7, 2006. |
---|
(Write a program that uses a Monte Carlo procedure to estimate this probability.)
typedef struct{ double x; double y; } point;which represents a point in the plane. Define the structure segment by
typedef struct{ point p1; point p2; } segment;which represents a (closed) line segment in the plane starting at point p1 and ending at point p2. It may happen that the segment degenerates to a point and p1=p2. Define the structure circle by
typedef struct{ point center; double radius; } cicle;which represents a (closed) circle in the plane centered at the point center and with radius radius.
Write a program that asks the user to type in the data for a line segment and for a circle. The program determines whether the segment is inside the circle, intersects the circle but is neither inside nor outside the circle, or is outside the circle. The program should also state the number of points of intersection between the segment and the circle. For example, the segment from (1,2) to (4,3) lies inside the circle with center (0,0) of radius 5 and touches it at exactly one point, the point (4,3). Whereas, the segment from (-3,-399) to (-3,541) neither is inside nor outside the same circle but touches it at exactly two points, the points (-3,-4) and (-3,4).
E-mail your solutions to treiberg@math.utah.edu.