Horizon
|
Represent route directions & corner angles in a 45-degree metric. More...
#include <direction45.h>
Public Types | |
enum | Directions : int { N = 0 , NE = 1 , E = 2 , SE = 3 , S = 4 , SW = 5 , W = 6 , NW = 7 , LAST = 8 , UNDEFINED = -1 } |
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined direction, reserved for traces that don't respect 45-degree routing regime. More... | |
enum | CORNER_MODE { MITERED_45 = 0 , ROUNDED_45 = 1 , MITERED_90 = 2 , ROUNDED_90 = 3 } |
Corner modes. More... | |
enum | AngleType { ANG_OBTUSE = 0x01 , ANG_RIGHT = 0x02 , ANG_ACUTE = 0x04 , ANG_STRAIGHT = 0x08 , ANG_HALF_FULL = 0x10 , ANG_UNDEFINED = 0x20 } |
Represent kind of angle formed by vectors heading in two DIRECTION_45s. | |
Public Member Functions | |
DIRECTION_45 (Directions aDir=UNDEFINED) | |
DIRECTION_45 (const VECTOR2I &aVec, bool a90=false) | |
DIRECTION_45 (const SEG &aSeg, bool a90=false) | |
DIRECTION_45 (const SHAPE_ARC &aArc, bool a90=false) | |
Create a DIRECTION_45 from the endpoints of a given arc. | |
const std::string | Format () const |
Format the direction in a human readable word. | |
DIRECTION_45 | Opposite () const |
Return a direction opposite (180 degree) to (this). | |
AngleType | Angle (const DIRECTION_45 &aOther) const |
Return the type of angle between directions (this) and aOther. | |
bool | IsObtuse (const DIRECTION_45 &aOther) const |
bool | IsDiagonal () const |
Returns true if the direction is diagonal (e.g. | |
bool | IsDefined () const |
const SHAPE_LINE_CHAIN | BuildInitialTrace (const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false, CORNER_MODE aMode=CORNER_MODE::MITERED_45) const |
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime. | |
bool | operator== (const DIRECTION_45 &aOther) const |
bool | operator!= (const DIRECTION_45 &aOther) const |
const DIRECTION_45 | Right () const |
Return the direction on the right side of this (i.e. | |
const DIRECTION_45 | Left () const |
Return the direction on the left side of this (i.e. | |
const VECTOR2I | ToVector () const |
int | Mask () const |
Represent route directions & corner angles in a 45-degree metric.
enum DIRECTION_45::Directions : int |
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined direction, reserved for traces that don't respect 45-degree routing regime.
|
inline |
aVec | vector in world space, whose direction will be translated into a DIRECTION_45. |
|
inline |
aSeg | segment, whose direction will be translated into a DIRECTION_45. |
|
inline |
Create a DIRECTION_45 from the endpoints of a given arc.
aArc | will be translated into the closest DIRECTION_45 |
|
inline |
Return the type of angle between directions (this) and aOther.
aOther | direction to compare angle with |
const SHAPE_LINE_CHAIN DIRECTION_45::BuildInitialTrace | ( | const VECTOR2I & | aP0, |
const VECTOR2I & | aP1, | ||
bool | aStartDiagonal = false , |
||
CORNER_MODE | aMode = CORNER_MODE::MITERED_45 |
||
) | const |
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime.
If aStartDiagonal is true, the trace starts with a diagonal segment.
aP0 | starting point |
aP1 | ending point |
aStartDiagonal | whether the first segment has to be diagonal |
aMode | How the corner is made. If it is a 90° corner, aStartDiagonal means start with the shorter direction first / use arc before the straight segment. |
|
inline |
Format the direction in a human readable word.
|
inline |
Returns true if the direction is diagonal (e.g.
North-West, South-East, etc).
|
inline |
|
inline |
Return the direction on the left side of this (i.e.
turns left by 45 or 90 deg).
|
inline |
Return a direction opposite (180 degree) to (this).
|
inline |
Return the direction on the right side of this (i.e.
turns right by 45 or 90 deg).
|
inline |