Class Reference point

Stores a single point. More...

Member

point( )
point( point p )
point(int x,int y)
double distanceTo(point p2)
double distanceToLine(point p1, point p2)
double distanceToLineAbs(point p1, point p2)
double length()
void set(int x, int y)
void setX(int x)
void setY(int y)
int x()
int y()

Detailed Description

graph LR ce(cell)--addBox-->e(element) e--getPoints-->pa(pointArray) pa--point-->p(point) la(layout)--getMousePoint-->p click ce "/layoutscript/api/cell" click e "/layoutscript/api/element" click pa "/layoutscript/api/pointarray" click p "/layoutscript/api/point" click la "/layoutscript/api/layout" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class p thisClas class ce,e,pa,la clas

A point is a value type for one coordinate: two 32-bit integers x and y in database units. Multiply by databaseunits on drawingField to convert to metres. The usual path from geometry is cell addBox (or another add method) to an element, then getPoints to a pointArray, then point(i) for a vertex. Interactive macros can also wait with getMousePoint on layout; drawingField::point records coordinates for later box, path, or polygon. Distances (distanceTo, distanceToLine, length) are double. Copy, pass, and store a point like a small struct; it is not a window object and has no parent pointer.

Example:

point p(10000, 20000);
p.setX(15000);
int x = p.x();
int y = p.y();
double d = p.distanceTo(point(0, 0));

Member Function Documentation


point::point( )

Creates a point at the origin (0, 0).


point::point( point p )

Creates a point containing a copy of p.


point::point(int x,int y)

Constructs a point with coordinates x and y.


double point::distanceTo(point p2)

Returns: the Euclidean distance to p2, in database units.


double point::distanceToLine(point p1, point p2)

Returns: the shortest distance to the infinite line through p1 and p2. The value is negative if this point is to the left of the directed segment from p1 to p2.

Parameter:
p1 p1
p2 p2

double point::distanceToLineAbs(point p1, point p2)

Returns: the shortest distance to the line through p1 and p2. The value is always positive or zero.

Parameter:
p1 p1
p2 p2

double point::length()

Returns: the distance from this point to the origin.


void point::set(int x, int y)

Sets both the x and y coordinates.


void point::setX(int x)

Sets the x coordinate.


void point::setY(int y)

Sets the y coordinate.


int point::x()

Returns: the x coordinate of the point.


int point::y()

Returns: the y coordinate of the point.