KiCad PCB EDA Suite
vector2d.h File Reference
#include <limits>
#include <iostream>
#include <sstream>
#include <math/math_util.h>

Go to the source code of this file.

Classes

struct  VECTOR2_TRAITS< T >
 Class VECTOR2_TRAITS traits class for VECTOR2. More...
 
struct  VECTOR2_TRAITS< int >
 
class  VECTOR2< T >
 Class VECTOR2 defines a general 2D-vector/point. More...
 
class  VECTOR2< T >
 Class VECTOR2 defines a general 2D-vector/point. More...
 

Typedefs

typedef VECTOR2< double > VECTOR2D
 
typedef VECTOR2< int > VECTOR2I
 
typedef VECTOR2< unsigned int > VECTOR2U
 
typedef VECTOR2< double > DPOINT
 
typedef DPOINT DSIZE
 

Functions

template<class T >
std::ostream & operator<< (std::ostream &aStream, const VECTOR2< T > &aVector)
 
template<class T >
VECTOR2< T > operator* (const T &aFactor, const VECTOR2< T > &aVector)
 
template<class T >
const VECTOR2< T > LexicographicalMax (const VECTOR2< T > &aA, const VECTOR2< T > &aB)
 
template<class T >
const VECTOR2< T > LexicographicalMin (const VECTOR2< T > &aA, const VECTOR2< T > &aB)
 
template<class T >
const int LexicographicalCompare (const VECTOR2< T > &aA, const VECTOR2< T > &aB)
 

Typedef Documentation

typedef VECTOR2<double> DPOINT

Definition at line 592 of file vector2d.h.

typedef DPOINT DSIZE

Definition at line 593 of file vector2d.h.

typedef VECTOR2<double> VECTOR2D

Definition at line 586 of file vector2d.h.

typedef VECTOR2<int> VECTOR2I

Definition at line 587 of file vector2d.h.

typedef VECTOR2<unsigned int> VECTOR2U

Definition at line 588 of file vector2d.h.

Function Documentation

template<class T >
const int LexicographicalCompare ( const VECTOR2< T > &  aA,
const VECTOR2< T > &  aB 
)

Definition at line 559 of file vector2d.h.

References VECTOR2< T >::x, and VECTOR2< T >::y.

560 {
561  if( aA.x < aB.x )
562  return -1;
563  else if( aA.x > aB.x )
564  return 1;
565  else // aA.x == aB.x
566  {
567  if( aA.y < aB.y )
568  return -1;
569  else if( aA.y > aB.y )
570  return 1;
571  else
572  return 0;
573  }
574 }
template<class T >
const VECTOR2<T> LexicographicalMax ( const VECTOR2< T > &  aA,
const VECTOR2< T > &  aB 
)

Definition at line 535 of file vector2d.h.

References VECTOR2< T >::x, and VECTOR2< T >::y.

536 {
537  if( aA.x > aB.x )
538  return aA;
539  else if( aA.x == aB.x && aA.y > aB.y )
540  return aA;
541 
542  return aB;
543 }
template<class T >
const VECTOR2<T> LexicographicalMin ( const VECTOR2< T > &  aA,
const VECTOR2< T > &  aB 
)

Definition at line 547 of file vector2d.h.

References VECTOR2< T >::x, and VECTOR2< T >::y.

548 {
549  if( aA.x < aB.x )
550  return aA;
551  else if( aA.x == aB.x && aA.y < aB.y )
552  return aA;
553 
554  return aB;
555 }
template<class T >
VECTOR2<T> operator* ( const T &  aFactor,
const VECTOR2< T > &  aVector 
)

Definition at line 469 of file vector2d.h.

References VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by VECTOR2< unsigned int >::operator wxPoint().

470 {
471  VECTOR2<T> vector( aVector.x * aFactor, aVector.y * aFactor );
472  return vector;
473 }
Class VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
template<class T >
std::ostream & operator<< ( std::ostream &  aStream,
const VECTOR2< T > &  aVector 
)

Definition at line 578 of file vector2d.h.

579 {
580  aStream << "[ " << aVector.x << " | " << aVector.y << " ]";
581  return aStream;
582 }