Glade Reference


Edge class

The Edge class represents an edge, i.e a connected pair of vertices.

 

Edge *e   = Edge

Creates and edge object. The endpoints are undefined.

 

Edge *e = Edge(Point p0, Point p1)

Creates and Edge object and initialises the endpoints.

 

Edge *e = Edge(x0, y0, x1, y1)

Creates and Edge object and initialises the endpoints.

 

Point p = e.getP0()

Gets one endpoint P0.

 

Point p = e.getP1()

Gets the other endpoint P1.

 

e.setP0(Point p)

sets endpoint P0 to p.

 

e.setP1(Point p)

sets endpoint P1 to p.

 

e.offset(int dx, int dy)

Transposes the edge by the distance specified by dx, dy.

 

bool operator ==

Returns True (1) if the edges are the same i.e. endpoints P0 and P1 are identical.

 

bool operator !=

Returns True (1) if of the edges are not the same i.e. endpoints P0 and P1 are not identical.

 

int i = e.length()

Returns the Euclidian length of the edge e.

 

bool b = e.isHorizontal()

Returns true if the edge is horizontal.

 

bool b = e.isVertical()

Returns true if the edge is vertical.

 

bool b = e.isDiagonal()

Returns true if the edge is diagonal.

 

bool b = e.isOrthogonal()

Returns true if the edge is either horizontal or vertical.

 

int e.deltax()

Returns the horizontal distance between the edges endpoints i.e. P1-P0.

 

int e.deltay()

Returns the vertical distance between the edges endpoints i.e. P1-P0.

 

bool b = e.contains(const Point &p, bool includeEnds=True)

Returns True if the point p lies on the edge e. If includeEnds is true, the point p can lie on the endpoints of the edge and be considered 'contained'.

 

bool b = e.crosses(const Rect &r, bool touch = True)

Returns True if the edge crosses the Rect r, i.e. if the edge intersects one of the Rect's edges. If touch is True, this includes the endpoint of the edge touching an edge of the Rect.

 

bool b = e.crosses(Point *pts, int numPoints, bool touch = True)

Returns True if the edge crosses the polygon given by pts, i.e. if the edge intersects one of the polygon's edges. If touch is True, this includes the endpoint of the edge touching an edge of the polygon.

 

int dist = e.pointToEdge(const Point &p)

Returns the shortest distance of a point p to the edge.

 

bool b = e.intersects(const Edge &other, bool includeEnds=True)

Returns true if the edges intersect at some point. If includeEnds is true, returns true if the edges intersect at endpoint(s).

 

Point p = e.interSectsAt(const Edge &other)

Returns the point of intersection of two edges. The result is only valid if the edges intersect.

 

bool b = e.isColinear(const Edge other)

Returns true if the edges are colinear, i.e. the edges are parallel and a point of one edge is on the other edge.

 

bool b = e.parallel(const Edge &other)

Returns true if this edge is parallel to another edge.

 

bool b = e.left(const Point &p)

Returns true if point p is to the left of edge e, i.e. 'inside'. Note this assumes the direction of the Edge is from endpoint P0 to endpoint P1.

 

bool b = e.projects(Edge e1, Edge e2, Edge &e3, Edge &e4)

Returns true if the edges are parallel and project onto each other. Edges e3 and e4 are the projecting edges.

 

Point p = e.nearestPoint(const Point &pt)

Returns the point on the edge that is nearest the Point pt. The point p is either on a line perpendicular to the edge, or if no such line exists, is the nearest endpoint of the edge.

 

Vector v = e.normalTo(const Point &pt)

Returns a Vector that is the perpendicular distance from the Point pt to the edge.

 

bool b = e.projects(const Edge &e1, const Edge &e2, Edge &e3, Edge &e4)

Returns true if edges E1 and E2 are parallel and project. e3 and e4 are the projecting edges.

 

Contents|Index

Copyright © Peardrop Design  Systems Ltd 2017.