GSegment Class Reference

[libgfc Index] [libgfc Hierarchy] [Headers]


The ADT of Segments More...

#include <src/gadt_segment.h>

Inherits: GSpatial

Public Members


Detailed Description

The ADT of Segments.

A Segment is a straight line with two ends and no direction.


void set(Coord _x1, Coord _y1, Coord _x2, Coord _y2) [public]

set the two ends of the segment

inline Coord getX1() const [public]

retrieve the coordinates of the two ends.

double distance(const GPoint& pnt) const [public]

calculate the vertical distance from the point to the segment. uses the more advanced distance calculating method below.

double distance(const GPoint& pnt, int& flag) const [public]

calculate the vertical distance from the point to the segment. also indicates whether the point' projection falls on the segments.

Returns the vertical distance. the 'flag' indicates whether the point's perpendicular projection is on the segment (1) or not (0).

Result bufferzone(double size, Coord* xcoords, Coord* ycoords) const [public]

generates a rectangular bufferzone along this segement. Two opposite sides of the rectangle are in right angle with the segment, while the other two are parallel along the segment. In other words, this segement is the central line that splits the rectangle into two equal parts. The size of of cushion along each side of the segment is given by the first parameter. The four coordinates are stored into xcoords and ycoords. The first corner is repeated at the end (to make the zone closed), so you need to provide space for at least five doubles in each array.

double length() const [public]

get the length of the segment

int covers(const GSpatial&) const [public virtual]

this function is not defined.

int intersects(const GSpatial& a) const [public virtual]

intesecting a segment with other ADTs.

int isInside(const GRect& other) const [public]

check if this segment is inside a rectangle. simply use the bounding rectangle and call covers() method of incoming rectangle.

int isInside(const GCircle& other) const [public]

check if the segment is inside a circle.


Documentation generated by lqian@lqian-sun on Wed Jul 14 09:36:10 EDT 1999
Kdoc