Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A polygon is a closed loop made up of straight line segments. When the loop does not intersect itself, the polygon is said to

3. rotate: Rotates the point by an angle 9. The instance is modified after this method is called 4. distance: Returns the dis    

A polygon is a closed loop made up of straight line segments. When the loop does not intersect itself, the polygon is said to be a simple polygon. We can think of a simple polygon as a sequence of vertices specified in counter-clockwise order. Each vertex is a point with an (z,y) coordinate. For example, the simple polygon Q = {w, v1, 22, 23, 24, 25, U6) in Figure 1(a) has 7 vertices and 7 edges. No V DV4 V NO P V (a) (b) Figure 1: (a) Q is a simple polygon. (b) P is a convex polygon. A conver polygon is a simple polygon whose shape satisfies the property that as we walk around the boundary of the polygon in counter-clockwise order, we always turn left at each vertex. (Another way to define a convex polygon is that for any two points on or within the polygon, the straight line segment connecting those points lies entirely within the polygon.) See Figure 1(b) for an example of a convex polygon P = {0, 1, 12, 13, 14, 15, 16, 17) with 8 vertices. In this problem, you are asked to implement a Point class, a SimplePoly class, a ConvPoly class, an EquiTriangle class, a Rectangle class, and a Square class. Instances of the SimplePoly class contain a collection of Point instances. The ConvPoly class is a sub- class of SimplePoly, the EquiTriangle and Rectangle classes are sub-classes of ConvPoly, and the Square class is a sub-class of Rectangle. Create a module called problem1.py to contain all these classes. Further details are provided below. Point class (12 points). Instances of this class are points in two-dimensional space. Hence, each instance has an z coordinate and a y coordinate. We first state a few definitions. See Figure 2 for illustrations. Translation: If a point (r, y) is translated (moved) by an amounts in the r direction and an amount t in the y direction, its new coordinates are (z+s,y+t). Rotation: If a point (x, y) is rotated by angle about the origin, its new coordinates are (z cos 0-ysine, zsin 0 + y cos 0). Distance: The distance between two points (21.91) and (12, 9/2) is (1-22) + (31-32). Sidedness: Let p = (Pr.Py), q= (gr. gy), and r = (Tr.ry) be three points. We say that p lies to the left of qr (that is, the points < q, r,p> make a left turn) if and only if (rapy - Pary) + (9zry-9xPy) + (qPzqyra)>0. We say that p lies to the right of gr (that is, the points < q, r,p> make a right turn) if and only if (TzPy-Pry)+(9zry-qzPy)+(9yPs-qyrz)

Step by Step Solution

3.38 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

import math class Point def initself x y selfx x selfy y def rotateself angle anglerad mathradiansan... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals of Cost Accounting

Authors: William Lanen, Shannon Anderson, Michael Maher

3rd Edition

9780078025525, 9780077517359, 77517350, 978-0077398194

More Books

Students also viewed these Programming questions