Class Segment - Segment.h, Segment.cc
Definition:
A segment is a holder for two points.
Typedefs:
None
Included:
#include "Point.h"
Point
one
The first point.
Point
two
The second point.
Segment()
Default constructor. Sets both points to have position (0,0).
Segment(int
x1,int y1,int x2,int y2)
Sets Point one to position (x1,y1) and Point two
to position (x2,y2).
~Segment()
Destructor.
void setPointOne(int
x, int y)
Sets Point one to position (x,y).
void setPointTwo(int
x, int y)
Sets Point two to position (x,y).
void setPointOne(Point
x)
Sets Point one as specified by point 'x'
void setPointTwo(Point
x)
Sets Point two as specified by point 'x'
void setPoints(Point
x, Point y)
Sets Point one and two as specified
by points 'x' and 'y', respectively.
Point * getPointOne()
Returns a pointer to one.
Point * getPointTwo()
Returns a pointer to two.
bool isHorizontal()
Determines if the segment is horizontal. If horizontal, function
returns 'true'.
bool isVertical()
Determines if the segment is vertical. If vertical, the function
returns 'false'.
bool isSamePoint()
Determines if point one has the same location as point
two. If they are the same, function returns 'true'.
Equivalent to determining if the segment has a length of 0.
bool overlap(Segment
* seg)
Determines if this segment overlaps with the passed segment 'seg'.
If they overlap, function returns true.
double getLength()
Returns the length of the segment. NOTE: the actual length, not the
Manhattan length.
void print()
Debugging function. Prints the specifics of this instance to cout.