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

Go to the source code of this file.

Classes

struct  VECTOR2_TRAITS< T >
 Traits class for VECTOR2. More...
 
struct  VECTOR2_TRAITS< int >
 
class  VECTOR2< T >
 Define a general 2D-vector/point. More...
 
class  VECTOR2< T >
 Define 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

◆ DPOINT

typedef VECTOR2<double> DPOINT

Definition at line 628 of file vector2d.h.

◆ DSIZE

typedef DPOINT DSIZE

Definition at line 629 of file vector2d.h.

◆ VECTOR2D

typedef VECTOR2<double> VECTOR2D

Definition at line 622 of file vector2d.h.

◆ VECTOR2I

typedef VECTOR2<int> VECTOR2I

Definition at line 623 of file vector2d.h.

◆ VECTOR2U

typedef VECTOR2<unsigned int> VECTOR2U

Definition at line 624 of file vector2d.h.

Function Documentation

◆ LexicographicalCompare()

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

Definition at line 595 of file vector2d.h.

596 {
597  if( aA.x < aB.x )
598  return -1;
599  else if( aA.x > aB.x )
600  return 1;
601  else // aA.x == aB.x
602  {
603  if( aA.y < aB.y )
604  return -1;
605  else if( aA.y > aB.y )
606  return 1;
607  else
608  return 0;
609  }
610 }

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

◆ LexicographicalMax()

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

Definition at line 571 of file vector2d.h.

572 {
573  if( aA.x > aB.x )
574  return aA;
575  else if( aA.x == aB.x && aA.y > aB.y )
576  return aA;
577 
578  return aB;
579 }

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

◆ LexicographicalMin()

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

Definition at line 583 of file vector2d.h.

584 {
585  if( aA.x < aB.x )
586  return aA;
587  else if( aA.x == aB.x && aA.y < aB.y )
588  return aA;
589 
590  return aB;
591 }

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

◆ operator *()

template<class T >
VECTOR2<T> operator * ( const T &  aFactor,
const VECTOR2< T > &  aVector 
)

Definition at line 505 of file vector2d.h.

506 {
507  VECTOR2<T> vector( aVector.x * aFactor, aVector.y * aFactor );
508  return vector;
509 }
Define a general 2D-vector/point.
Definition: vector2d.h:61

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

◆ operator<<()

template<class T >
std::ostream & operator<< ( std::ostream &  aStream,
const VECTOR2< T > &  aVector 
)

Definition at line 614 of file vector2d.h.

615 {
616  aStream << "[ " << aVector.x << " | " << aVector.y << " ]";
617  return aStream;
618 }

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