Horizon
Public Types | Public Member Functions | List of all members
DIRECTION_45 Class Reference

Class DIRECTION_45. More...

#include <direction45.h>

Public Types

enum  Directions {
  N = 0, NE = 1, E = 2, SE = 3,
  S = 4, SW = 5, W = 6, NW = 7,
  UNDEFINED = -1
}
 Enum Directions Represents 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.
 
enum  AngleType {
  ANG_OBTUSE = 0x01, ANG_RIGHT = 0x02, ANG_ACUTE = 0x04, ANG_STRAIGHT = 0x08,
  ANG_HALF_FULL = 0x10, ANG_UNDEFINED = 0x20
}
 Enum AngleType Represents kind of angle formed by vectors heading in two DIRECTION_45s.
 

Public Member Functions

 DIRECTION_45 (Directions aDir=UNDEFINED)
 
 DIRECTION_45 (const VECTOR2I &aVec)
 Constructor. More...
 
 DIRECTION_45 (const SEG &aSeg)
 Constructor. More...
 
const std::string Format () const
 Function Format() Formats the direction in a human readable word. More...
 
DIRECTION_45 Opposite () const
 Function Opposite() Returns a direction opposite (180 degree) to (this) More...
 
AngleType Angle (const DIRECTION_45 &aOther) const
 Function Angle() Returns the type of angle between directions (this) and aOther. More...
 
bool IsObtuse (const DIRECTION_45 &aOther) const
 Function IsObtuse() More...
 
bool IsDiagonal () const
 Function IsDiagonal() Returns true if the direction is diagonal (e.g. More...
 
bool IsDefined () const
 
const SHAPE_LINE_CHAIN BuildInitialTrace (const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false) const
 Function BuildInitialTrace() More...
 
bool operator== (const DIRECTION_45 &aOther) const
 
bool operator!= (const DIRECTION_45 &aOther) const
 
const DIRECTION_45 Right () const
 Function Right() More...
 
const DIRECTION_45 Left () const
 Function Left() More...
 
const VECTOR2I ToVector () const
 Function ToVector() More...
 
int Mask () const
 

Detailed Description

Class DIRECTION_45.

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

Constructor & Destructor Documentation

◆ DIRECTION_45() [1/2]

DIRECTION_45::DIRECTION_45 ( const VECTOR2I aVec)
inline

Constructor.

Parameters
aVecvector, whose direction will be translated into a DIRECTION_45.

◆ DIRECTION_45() [2/2]

DIRECTION_45::DIRECTION_45 ( const SEG aSeg)
inline

Constructor.

Parameters
aSegsegment, whose direction will be translated into a DIRECTION_45.

Member Function Documentation

◆ Angle()

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

Function Angle() Returns 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 
) const
inline

Function BuildInitialTrace()

Builds 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
Returns
the trace

◆ Format()

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

Function Format() Formats the direction in a human readable word.

Returns
name of the direction

◆ IsDiagonal()

bool DIRECTION_45::IsDiagonal ( ) const
inline

Function IsDiagonal() 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

Function IsObtuse()

Returns
true, when (this) forms an obtuse angle with aOther

◆ Left()

const DIRECTION_45 DIRECTION_45::Left ( ) const
inline

Function Left()

Returns the direction on the left side of this (i.e. turns left by 45 deg)

◆ Opposite()

DIRECTION_45 DIRECTION_45::Opposite ( ) const
inline

Function Opposite() Returns a direction opposite (180 degree) to (this)

Returns
opposite direction

◆ Right()

const DIRECTION_45 DIRECTION_45::Right ( ) const
inline

Function Right()

Returns the direction on the right side of this (i.e. turns right by 45 deg)

◆ ToVector()

const VECTOR2I DIRECTION_45::ToVector ( ) const
inline

Function ToVector()

Returns a unit vector corresponding to our direction.


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