Glade Reference


Edge class

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

 

Edge::Edge

Creates and edge object. The endpoints are undefined.

 

Edge::Edge(Point p0, Point p1)

Creates and Edge object and initialises the endpoints to the two points.

 

Edge::Edge(int32_t x0, int32_t y0, int32_t x1, int32_t y1)

Creates and Edge object and initialises the endpoints.

 

Point Edge::getP0()

Gets one endpoint P0.

 

Point Edge::getP1()

Gets the other endpoint P1.

 

Edge::setP0(Point p)

sets endpoint P0 to p.

 

Edge::setP1(Point p)

sets endpoint P1 to p.

 

Edge::offset(int dx, int dy)

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

 

bool Edge::operator ==

Returns true if the edges are the same i.e. endpoints P0 and P1 are identical.

 

bool Edge::operator !=

Returns true if of the edges are not the same i.e. endpoints P0 and P1 are not identical.

 

int32_t Edge::length()

Returns the Euclidian length of the edge e.

 

bool Edge::isHorizontal()

Returns true if the edge is horizontal.

 

bool Edge::isVertical()

Returns true if the edge is vertical.

 

bool Edge::isDiagonal()

Returns true if the edge is diagonal.

 

bool Edge::isOrthogonal()

Returns true if the edge is either horizontal or vertical.

 

int Edge::deltax()

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

 

int Edge::deltay()

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

 

bool Edge::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 Edge::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 Edge::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 Edge::pointToEdge(const Point &p)

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

 

int Edge::distance(const Edge &e)

Returns the shortest distance of the edge to another edge.

 

bool Edge::.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 Edge::interSectsAt(const Edge &other)

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

 

bool Edge::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 Edge::parallel(const Edge &other)

Returns true if this edge is parallel to the other edge.

 

bool Edge::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.

 

Point Edge::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 Edge::normalTo(const Point &pt)

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

 

bool Edge::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 resulting projecting edges.

 

 

Contents|Index

Copyright © Peardrop Design 2024.