hw4sp01 - COP3530C.01, Spring 2001 S. Lang Assignment #4...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COP3530C.01, Spring 2001 Assigned: March 5, 2001 S. Lang Assignment #4 Due: March 22, within10 min. of the lecture at 11:30 am (Note added 3/07/01: the method signedArea( ) is slightly modified so it uses two parameters. Two additional remarks added 3/08/01.) You are to write a program in C++ or in Java that implements a few functions related to polygons in 2-dimensional plane consisting of points with positive integer coordinates. (In principle, algorithms and techniques described in the following can be applied to points of arbitrary real number coordinates.) There are several terms and facts you need to understand first. The 2-dimensional plane is specified by a coordinate system, in which a horizontal axis (known as the x -axis) and a vertical axis (the y -axis) intersect at the point called the origin. Each point p in the plane is then identified with a pair of real numbers ( x , y ), known as the x- and y-coordinates, respectively, in which x = (+ or –) distance from p to the y axis, and y = (+ or –) distance from p to the x axis. The signs of the coordinates are determined so that the points to the right (left) of the y axis have positive (negative) x coordinates; points above (below) the x axis have positive (negative) y coordinates. The area in which both x and y coordinates are positive is called the first quadrant, which is where your program is concerned with. (See Fig. 1.) From geometry, we know two distinct points p , q determine a unique line. We use the notation pq to denote the line segment (the portion of the line) from point p to point q . (Be aware of the direction of a segment.) A sequence of n distinct points p 1 , p 2 , …, p n , n 3, determine a polygon consisting of the region enclosed by line segments . and , ..., , , 1 1 3 2 2 1 p p p p p p p p n n n - The points p 1 , p 2 , …, p n are called the vertices of the polygon. A region is called convex if for every two points p , q inside the region, the line segment pq is entirely contained inside the region. (See Fig. 2.) The convex hull of a polygon is the smallest convex region that contains the given polygon. It is a simple fact to see that the convex hull of a polygon is determined by identifying a subset of the vertices that enclose a smallest convex region containing the given polygon; these vertices are called the extreme points of the polygon. (See Fig. 2.) The purpose of this assignment is to compute the convex hull for any given polygon. A class named PolyPoint will be provided for the abstraction of 2-dimensional points (of integer
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 06/13/2011.

Page1 / 3

hw4sp01 - COP3530C.01, Spring 2001 S. Lang Assignment #4...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online