Horizon
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
DIRECTION_45 Class Reference

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
 

Detailed Description

Represent route directions & corner angles in a 45-degree metric.

Member Enumeration Documentation

◆ CORNER_MODE

Corner modes.

A corner can either be 45° or 90° and can be fillet/rounded or mitered

Enumerator
MITERED_45 

H/V/45 with mitered corners (default)

ROUNDED_45 

H/V/45 with filleted corners.

MITERED_90 

H/V only (90-degree corners)

ROUNDED_90 

H/V with filleted corners.

◆ Directions

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.

Note
North represents "up" to the user looking at the application, which is the negative-y direction in the world coordinate space!

Constructor & Destructor Documentation

◆ DIRECTION_45() [1/3]

DIRECTION_45::DIRECTION_45 ( const VECTOR2I aVec,
bool  a90 = false 
)
inline
Parameters
aVecvector in world space, whose direction will be translated into a DIRECTION_45.

◆ DIRECTION_45() [2/3]

DIRECTION_45::DIRECTION_45 ( const SEG aSeg,
bool  a90 = false 
)
inline
Parameters
aSegsegment, whose direction will be translated into a DIRECTION_45.

◆ DIRECTION_45() [3/3]

DIRECTION_45::DIRECTION_45 ( const SHAPE_ARC aArc,
bool  a90 = false 
)
inline

Create a DIRECTION_45 from the endpoints of a given arc.

Parameters
aArcwill be translated into the closest DIRECTION_45

Member Function Documentation

◆ Angle()

AngleType DIRECTION_45::Angle ( const DIRECTION_45 aOther) const
inline

Return the type of angle between directions (this) and aOther.

Parameters
aOtherdirection to compare angle with

◆ BuildInitialTrace()

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.

Parameters
aP0starting point
aP1ending point
aStartDiagonalwhether the first segment has to be diagonal
aModeHow the corner is made. If it is a 90° corner, aStartDiagonal means start with the shorter direction first / use arc before the straight segment.
Returns
the trace

◆ Format()

const std::string DIRECTION_45::Format ( ) const
inline

Format the direction in a human readable word.

Returns
name of the direction

◆ IsDiagonal()

bool DIRECTION_45::IsDiagonal ( ) const
inline

Returns true if the direction is diagonal (e.g.

North-West, South-East, etc).

Returns
true, when diagonal.

◆ IsObtuse()

bool DIRECTION_45::IsObtuse ( const DIRECTION_45 aOther) const
inline
Returns
true, when (this) forms an obtuse angle with aOther.

◆ Left()

const DIRECTION_45 DIRECTION_45::Left ( ) const
inline

Return the direction on the left side of this (i.e.

turns left by 45 or 90 deg).

◆ Opposite()

DIRECTION_45 DIRECTION_45::Opposite ( ) const
inline

Return a direction opposite (180 degree) to (this).

Returns
opposite direction

◆ Right()

const DIRECTION_45 DIRECTION_45::Right ( ) const
inline

Return the direction on the right side of this (i.e.

turns right by 45 or 90 deg).

◆ ToVector()

const VECTOR2I DIRECTION_45::ToVector ( ) const
inline
Returns
a unit vector in world coordinate system corresponding to our direction.

The documentation for this class was generated from the following files: