KiCad PCB EDA Suite
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  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. More...
 

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. More...
 
const std::string Format () const
 Format the direction in a human readable word. More...
 
DIRECTION_45 Opposite () const
 Return a direction opposite (180 degree) to (this). More...
 
AngleType Angle (const DIRECTION_45 &aOther) const
 Return the type of angle between directions (this) and aOther. More...
 
bool IsObtuse (const DIRECTION_45 &aOther) const
 
bool IsDiagonal () const
 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, bool aFillet=false) const
 Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime. More...
 
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. More...
 
const DIRECTION_45 Left () const
 Return the direction on the left side of this (i.e. More...
 
const VECTOR2I ToVector () const
 
int Mask () const
 

Private Member Functions

void construct_ (const VECTOR2I &aVec)
 Calculate the direction from a vector. More...
 

Private Attributes

Directions m_dir
 Are we routing on 45 or 90 degree increments. More...
 
bool m_90deg
 

Detailed Description

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

Definition at line 36 of file direction45.h.

Member Enumeration Documentation

◆ AngleType

Represent kind of angle formed by vectors heading in two DIRECTION_45s.

Enumerator
ANG_OBTUSE 
ANG_RIGHT 
ANG_ACUTE 
ANG_STRAIGHT 
ANG_HALF_FULL 
ANG_UNDEFINED 

Definition at line 65 of file direction45.h.

◆ 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!
Enumerator
NE 
SE 
SW 
NW 
LAST 
UNDEFINED 

Definition at line 48 of file direction45.h.

48  : int
49  {
50  N = 0,
51  NE = 1,
52  E = 2,
53  SE = 3,
54  S = 4,
55  SW = 5,
56  W = 6,
57  NW = 7,
58  LAST = 8,
59  UNDEFINED = -1
60  };

Constructor & Destructor Documentation

◆ DIRECTION_45() [1/4]

DIRECTION_45::DIRECTION_45 ( Directions  aDir = UNDEFINED)
inline

Definition at line 75 of file direction45.h.

75 : m_dir( aDir ), m_90deg( false ) {}
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

◆ DIRECTION_45() [2/4]

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.

Definition at line 80 of file direction45.h.

80  :
81  m_90deg( a90 )
82  {
83  VECTOR2I vec( aVec );
84  vec.y = -vec.y;
85  construct_( vec );
86  }
Define a general 2D-vector/point.
Definition: vector2d.h:61
void construct_(const VECTOR2I &aVec)
Calculate the direction from a vector.
Definition: direction45.h:305

References construct_(), and VECTOR2< T >::y.

◆ DIRECTION_45() [3/4]

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

Definition at line 91 of file direction45.h.

91  :
92  m_90deg( a90 )
93  {
94  VECTOR2I vec( aSeg.B - aSeg.A );
95  vec.y = -vec.y;
96  construct_( vec );
97  }
Define a general 2D-vector/point.
Definition: vector2d.h:61
VECTOR2I A
Definition: seg.h:48
void construct_(const VECTOR2I &aVec)
Calculate the direction from a vector.
Definition: direction45.h:305
VECTOR2I B
Definition: seg.h:49

References SEG::A, SEG::B, construct_(), and VECTOR2< T >::y.

◆ DIRECTION_45() [4/4]

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

Definition at line 104 of file direction45.h.

104  :
105  m_90deg( a90 )
106  {
107  VECTOR2I vec( aArc.GetP1() - aArc.GetP0() );
108  vec.y = -vec.y;
109  construct_( vec );
110  }
Define a general 2D-vector/point.
Definition: vector2d.h:61
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
void construct_(const VECTOR2I &aVec)
Calculate the direction from a vector.
Definition: direction45.h:305
const VECTOR2I & GetP1() const
Definition: shape_arc.h:112

References construct_(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), and VECTOR2< T >::y.

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

Definition at line 169 of file direction45.h.

170  {
171  if( m_dir == UNDEFINED || aOther.m_dir == UNDEFINED )
172  return ANG_UNDEFINED;
173 
174  int d = std::abs( m_dir - aOther.m_dir );
175 
176  if( d == 1 || d == 7 )
177  return ANG_OBTUSE;
178  else if( d == 2 || d == 6 )
179  return ANG_RIGHT;
180  else if( d == 3 || d == 5 )
181  return ANG_ACUTE;
182  else if( d == 4 )
183  return ANG_HALF_FULL;
184  else
185  return ANG_STRAIGHT;
186  }
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References ANG_ACUTE, ANG_HALF_FULL, ANG_OBTUSE, ANG_RIGHT, ANG_STRAIGHT, ANG_UNDEFINED, m_dir, and UNDEFINED.

Referenced by PNS::angle(), PNS::LINE::CountCorners(), PNS::LINE::dragSegment45(), PNS::MOUSE_TRAIL_TRACER::GetPosture(), PNS::LINE_PLACER::handlePullback(), IsObtuse(), PNS::LINE_PLACER::mergeHead(), PNS::OPTIMIZER::smartPadsSingle(), and PNS::tightenSegment().

◆ BuildInitialTrace()

const SHAPE_LINE_CHAIN DIRECTION_45::BuildInitialTrace ( const VECTOR2I aP0,
const VECTOR2I aP1,
bool  aStartDiagonal = false,
bool  aFillet = false 
) 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
aFilletif true will fillet the 45-degree portion of the line chain
Returns
the trace

Definition at line 23 of file direction_45.cpp.

25 {
26  bool startDiagonal;
27 
28  if( m_dir == UNDEFINED )
29  startDiagonal = aStartDiagonal;
30  else
31  startDiagonal = IsDiagonal();
32 
33  int w = abs( aP1.x - aP0.x );
34  int h = abs( aP1.y - aP0.y );
35  int sw = sign( aP1.x - aP0.x );
36  int sh = sign( aP1.y - aP0.y );
37 
38  VECTOR2I mp0, mp1;
39 
40  /*
41  * Non-filleted case:
42  *
43  * For width greater than height, we're calculating something like this.
44  * mp0 will be used if we start straight; mp1 if we start diagonal.
45  *
46  * aP0 ----------------- mp0
47  * . \
48  * . \
49  * . \
50  * mp1 . . . . . . . . aP1
51  *
52  * Filleted case:
53  *
54  * For a fillet, we need to know the arc start point (A in the diagram below)
55  * A straight segment will be needed between aP0 and A if we are starting straight,
56  * or between the arc end and aP1 if we are starting diagonally.
57  *
58  * aP0 -- A --___ mp0
59  * . ---
60  * . --
61  * . --
62  * mp1 . . . . . . . . aP1
63  *
64  * For the length of this segment (tangentLength), we subtract the length of the "diagonal"
65  * line from the "straight" line (i.e. dist(aP0, mp0) - dist(mp0, aP1))
66  * In the example above, we will have a straight segment from aP0 to A, and then we can use
67  * the distance from A to aP1 (diagLength) to calculate the radius of the arc.
68  */
69 
70  int tangentLength;
71 
72  if( w > h )
73  {
74  mp0 = VECTOR2I( ( w - h ) * sw, 0 ); // direction: E
75  mp1 = VECTOR2I( h * sw, h * sh ); // direction: NE
76  tangentLength = ( w - h ) - mp1.EuclideanNorm();
77  }
78  else
79  {
80  mp0 = VECTOR2I( 0, sh * ( h - w ) ); // direction: N
81  mp1 = VECTOR2I( sw * w, sh * w ); // direction: NE
82  tangentLength = ( h - w ) - mp1.EuclideanNorm();
83  }
84 
86 
87  // Shortcut where we can generate just one segment and quit. Avoids more complicated handling
88  // of precision errors if filleting is enabled
89  // TODO: needs refactoring if we support 90-degree arcs via this function
90  if( w == h || w == 0 || h == 0 )
91  {
92  pl.Append( aP0 );
93  pl.Append( aP1 );
94  return pl;
95  }
96 
97  // TODO: if tangentLength zero, we could still place a small arc at the start...
98  if( aFillet )
99  {
100  SHAPE_ARC arc;
101  VECTOR2I arcEndpoint;
102 
103  double diag2 = tangentLength >= 0 ? mp1.SquaredEuclideanNorm() : mp0.SquaredEuclideanNorm();
104  double diagLength = std::sqrt( ( 2 * diag2 ) - ( 2 * diag2 * std::cos( 3 * M_PI_4 ) ) );
105  int arcRadius = KiROUND( diagLength / ( 2.0 * std::cos( 67.5 * M_PI / 180.0 ) ) );
106 
107  // There are four different ways to build an arc, depending on whether or not we are
108  // starting diagonally and whether or not we have a negative tangent length (meaning the
109  // arc has to be on the opposite end of the line from normal). This math could probably
110  // be condensed and optimized but I'm tired of staring at it for now (and it works!)
111 
112  if( startDiagonal )
113  {
114  int rotationSign = ( w > h ) ? ( sw * sh * -1 ) : ( sw * sh );
115 
116  if( tangentLength >= 0 )
117  {
118  // Positive tangentLength, diagonal start: arc goes at the start
119  arcEndpoint = aP1 - mp0.Resize( tangentLength );
120  arc.ConstructFromStartEndAngle( aP0, arcEndpoint, 45 * rotationSign );
121 
122  if( arc.GetP0() == arc.GetP1() )
123  pl.Append( aP0 );
124  else
125  pl.Append( arc );
126 
127  pl.Append( aP1 );
128  }
129  else
130  {
131  // Negative tangentLength, diagonal start: arc goes at the end
132  arcEndpoint = aP0 + mp1.Resize( std::abs( tangentLength ) );
133  arc.ConstructFromStartEndAngle( arcEndpoint, aP1, 45 * rotationSign );
134 
135  pl.Append( aP0 );
136 
137  if( arc.GetP0() == arc.GetP1() )
138  pl.Append( aP1 );
139  else
140  pl.Append( arc );
141  }
142  }
143  else
144  {
145  int rotationSign = ( w > h ) ? ( sw * sh ) : ( sw * sh * -1 );
146  VECTOR2D centerDir( mp0.Rotate( M_PI_2 * rotationSign ) );
147 
148  if( tangentLength >= 0 )
149  {
150  // Positive tangentLength: arc goes at the end
151  arcEndpoint = aP0 + mp0.Resize( tangentLength );
152  arc.ConstructFromStartEndAngle( arcEndpoint, aP1, 45 * rotationSign );
153 
154  pl.Append( aP0 );
155 
156  if( arc.GetP0() == arc.GetP1() )
157  pl.Append( aP1 );
158  else
159  pl.Append( arc );
160  }
161  else
162  {
163  // Negative tangentLength: arc goes at the start
164  VECTOR2I arcCenter = aP0 + centerDir.Resize( arcRadius );
165  SHAPE_ARC ca( arcCenter, aP0, 45 * rotationSign );
166 
167  // Constructing with a center can lead to imprecise endpoint. We need to guarantee
168  // tangency of the endpoint.
169  // TODO: update the math above to calculate the proper endpoint directly
170  VECTOR2I endpoint( ca.GetP1() );
171 
172  if( std::abs( endpoint.y - aP1.y ) < SHAPE_ARC::MIN_PRECISION_IU )
173  {
174  VECTOR2I fixedEnd( endpoint.x, aP1.y );
175  ca.ConstructFromStartEndAngle( ca.GetP0(), fixedEnd, 45 * rotationSign );
176  }
177  else if( std::abs( endpoint.x - aP1.x ) < SHAPE_ARC::MIN_PRECISION_IU )
178  {
179  VECTOR2I fixedEnd( aP1.x, endpoint.y );
180  ca.ConstructFromStartEndAngle( ca.GetP0(), fixedEnd, 45 * rotationSign );
181  }
182 
183  if( ca.GetP0() == ca.GetP1() )
184  pl.Append( aP0 );
185  else
186  pl.Append( ca );
187 
188  pl.Append( aP1 );
189  }
190  }
191  }
192  else
193  {
194  pl.Append( aP0 );
195  pl.Append( startDiagonal ? ( aP0 + mp1 ) : ( aP0 + mp0 ) );
196  pl.Append( aP1 );
197  }
198 
199  pl.Simplify();
200  return pl;
201 }
int sign(T val)
Definition: util.h:104
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
#define M_PI_2
Definition: transline.cpp:40
Define a general 2D-vector/point.
Definition: vector2d.h:61
SHAPE_ARC & ConstructFromStartEndAngle(const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle, double aWidth=0)
Construct this arc from the given start, end and angle.
Definition: shape_arc.cpp:183
extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
Definition: vector2d.h:300
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
Definition: shape.h:122
bool IsDiagonal() const
Returns true if the direction is diagonal (e.g.
Definition: direction45.h:201
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
Definition: vector2d.h:371
Represent a polyline (an zero-thickness chain of connected line segments).
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:293
const VECTOR2I & GetP1() const
Definition: shape_arc.h:112

References SHAPE_LINE_CHAIN::Append(), SHAPE_ARC::ConstructFromStartEndAngle(), VECTOR2< T >::EuclideanNorm(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), IsDiagonal(), KiROUND(), m_dir, M_PI_2, SHAPE::MIN_PRECISION_IU, VECTOR2< T >::Resize(), VECTOR2< T >::Rotate(), sign(), SHAPE_LINE_CHAIN::Simplify(), VECTOR2< T >::SquaredEuclideanNorm(), UNDEFINED, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), PNS::DP_GATEWAYS::buildEntries(), PNS::DIFF_PAIR::BuildInitial(), PNS::LINE_PLACER::buildInitialLine(), PNS::dragCornerInternal(), PNS::OPTIMIZER::fanoutCleanup(), PNS::OPTIMIZER::mergeDpStep(), PNS::OPTIMIZER::mergeStep(), PNS::LINE_PLACER::reduceTail(), and PNS::OPTIMIZER::smartPadsSingle().

◆ construct_()

void DIRECTION_45::construct_ ( const VECTOR2I aVec)
inlineprivate

Calculate the direction from a vector.

If the vector's angle is not a multiple of 45 degrees, the direction is rounded to the nearest octant.

Parameters
aVecour vectorour actual direction

Definition at line 305 of file direction45.h.

References LAST, m_dir, UNDEFINED, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DIRECTION_45().

◆ Format()

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

Format the direction in a human readable word.

Returns
name of the direction

Definition at line 117 of file direction45.h.

118  {
119  switch( m_dir )
120  {
121  case N:
122  return "north";
123 
124  case NE:
125  return "north-east";
126 
127  case E:
128  return "east";
129 
130  case SE:
131  return "south-east";
132 
133  case S:
134  return "south";
135 
136  case SW:
137  return "south-west";
138 
139  case W:
140  return "west";
141 
142  case NW:
143  return "north-west";
144 
145  case UNDEFINED:
146  return "undefined";
147 
148  default:
149  return "<Error>";
150  }
151  }
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References E, m_dir, N, NE, NW, S, SE, SW, UNDEFINED, and W.

Referenced by PNS::LINE_PLACER::buildInitialLine(), PNS::MOUSE_TRAIL_TRACER::GetPosture(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::initPlacement(), PNS::LINE_PLACER::mergeHead(), PNS::LINE_PLACER::routeStep(), and PNS::LINE_PLACER::Start().

◆ IsDefined()

bool DIRECTION_45::IsDefined ( ) const
inline

Definition at line 206 of file direction45.h.

207  {
208  return m_dir != UNDEFINED;
209  }
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References m_dir, and UNDEFINED.

◆ 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.

Definition at line 201 of file direction45.h.

202  {
203  return ( m_dir % 2 ) == 1;
204  }
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References m_dir.

Referenced by BuildInitialTrace(), PNS::MOUSE_TRAIL_TRACER::GetPosture(), and PNS::OPTIMIZER::mergeDpStep().

◆ IsObtuse()

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

Definition at line 191 of file direction45.h.

192  {
193  return Angle( aOther ) == ANG_OBTUSE;
194  }
AngleType Angle(const DIRECTION_45 &aOther) const
Return the type of angle between directions (this) and aOther.
Definition: direction45.h:169

References ANG_OBTUSE, and Angle().

Referenced by PNS::OPTIMIZER::mergeDpStep(), and PNS::tightenSegment().

◆ 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).

Definition at line 256 of file direction45.h.

257  {
258  DIRECTION_45 l;
259 
260  if ( m_dir != UNDEFINED )
261  {
262  if( m_90deg )
263  l.m_dir = static_cast<Directions>( ( m_dir + LAST - 2 ) % LAST );
264  else
265  l.m_dir = static_cast<Directions>( ( m_dir + LAST - 1 ) % LAST );
266  }
267 
268  return l;
269  }
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References LAST, m_90deg, m_dir, and UNDEFINED.

Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), and PNS::LINE::dragSegment45().

◆ Mask()

int DIRECTION_45::Mask ( ) const
inline

Definition at line 292 of file direction45.h.

293  {
294  return 1 << ( (int) m_dir );
295  }
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References m_dir.

◆ operator!=()

bool DIRECTION_45::operator!= ( const DIRECTION_45 aOther) const
inline

Definition at line 230 of file direction45.h.

231  {
232  return aOther.m_dir != m_dir;
233  }
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References m_dir.

◆ operator==()

bool DIRECTION_45::operator== ( const DIRECTION_45 aOther) const
inline

Definition at line 225 of file direction45.h.

226  {
227  return aOther.m_dir == m_dir;
228  }
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References m_dir.

◆ Opposite()

DIRECTION_45 DIRECTION_45::Opposite ( ) const
inline

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

Returns
opposite direction

Definition at line 158 of file direction45.h.

159  {
160  const Directions OppositeMap[] = { S, SW, W, NW, N, NE, E, SE, UNDEFINED };
161  return OppositeMap[m_dir];
162  }
Directions
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined ...
Definition: direction45.h:48
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References E, m_dir, N, NE, NW, S, SE, SW, UNDEFINED, and W.

◆ 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).

Definition at line 238 of file direction45.h.

239  {
240  DIRECTION_45 r;
241 
242  if ( m_dir != UNDEFINED )
243  {
244  if( m_90deg )
245  r.m_dir = static_cast<Directions>( ( m_dir + 2 ) % LAST );
246  else
247  r.m_dir = static_cast<Directions>( ( m_dir + 1 ) % LAST );
248  }
249 
250  return r;
251  }
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
E_SERIE r
Definition: eserie.cpp:41
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References LAST, m_90deg, m_dir, r, and UNDEFINED.

Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), PNS::LINE::dragSegment45(), PNS::MOUSE_TRAIL_TRACER::FlipPosture(), and PNS::MOUSE_TRAIL_TRACER::GetPosture().

◆ ToVector()

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

Definition at line 274 of file direction45.h.

275  {
276  switch( m_dir )
277  {
278  case N: return VECTOR2I( 0, -1 );
279  case S: return VECTOR2I( 0, 1 );
280  case E: return VECTOR2I( 1, 0 );
281  case W: return VECTOR2I( -1, 0 );
282  case NE: return VECTOR2I( 1, -1 );
283  case NW: return VECTOR2I( -1, -1 );
284  case SE: return VECTOR2I( 1, 1 );
285  case SW: return VECTOR2I( -1, 1 );
286 
287  default:
288  return VECTOR2I( 0, 0 );
289  }
290  }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
Directions m_dir
Are we routing on 45 or 90 degree increments.
Definition: direction45.h:334

References E, m_dir, N, NE, NW, S, SE, SW, and W.

Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), and PNS::LINE::dragSegment45().

Member Data Documentation

◆ m_90deg

bool DIRECTION_45::m_90deg
private

Definition at line 337 of file direction45.h.

Referenced by Left(), and Right().

◆ m_dir

Directions DIRECTION_45::m_dir
private

Are we routing on 45 or 90 degree increments.

Definition at line 334 of file direction45.h.

Referenced by Angle(), BuildInitialTrace(), construct_(), Format(), IsDefined(), IsDiagonal(), Left(), Mask(), operator!=(), operator==(), Opposite(), Right(), and ToVector().


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