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 594 of file vector2d.h.

typedef DPOINT DSIZE

Definition at line 595 of file vector2d.h.

typedef VECTOR2<double> VECTOR2D

Definition at line 588 of file vector2d.h.

typedef VECTOR2<int> VECTOR2I

Definition at line 589 of file vector2d.h.

typedef VECTOR2<unsigned int> VECTOR2U

Definition at line 590 of file vector2d.h.

Function Documentation

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

Definition at line 561 of file vector2d.h.

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

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

Definition at line 537 of file vector2d.h.

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

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

Definition at line 549 of file vector2d.h.

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

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

Definition at line 471 of file vector2d.h.

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

472 {
473  VECTOR2<T> vector( aVector.x * aFactor, aVector.y * aFactor );
474  return vector;
475 }
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 580 of file vector2d.h.

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