KiCad PCB EDA Suite
vector2d.h File Reference
#include <cmath>
#include <climits>
#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 595 of file vector2d.h.

typedef DPOINT DSIZE

Definition at line 596 of file vector2d.h.

typedef VECTOR2<double> VECTOR2D

Definition at line 589 of file vector2d.h.

typedef VECTOR2<int> VECTOR2I

Definition at line 590 of file vector2d.h.

typedef VECTOR2<unsigned int> VECTOR2U

Definition at line 591 of file vector2d.h.

Function Documentation

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

Definition at line 562 of file vector2d.h.

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

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

Definition at line 538 of file vector2d.h.

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

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

Definition at line 550 of file vector2d.h.

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

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

Definition at line 472 of file vector2d.h.

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

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

Definition at line 581 of file vector2d.h.

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