KiCad PCB EDA Suite
matrix3x3.h File Reference
#include <math/vector2d.h>
#include <math/vector3.h>

Go to the source code of this file.

Classes

class  MATRIX3x3< T >
 MATRIX3x3 describes a general 3x3 matrix. More...
 

Typedefs

typedef MATRIX3x3< double > MATRIX3x3D
 

Functions

template<class T >
std::ostream & operator<< (std::ostream &aStream, const MATRIX3x3< T > &aMatrix)
 
template<class T >
MATRIX3x3< T > const operator* (MATRIX3x3< T > const &aA, MATRIX3x3< T > const &aB)
 Matrix multiplication. More...
 
template<class T >
VECTOR2< T > const operator* (MATRIX3x3< T > const &aA, VECTOR2< T > const &aB)
 Multiplication with a 2D vector, the 3rd z-component is assumed to be 1. More...
 
template<class T >
VECTOR3< T > const operator* (MATRIX3x3< T > const &aA, VECTOR3< T > const &aB)
 
template<class T , class S >
MATRIX3x3< T > const operator* (MATRIX3x3< T > const &aA, T aScalar)
 Multiplication with a scalar. More...
 
template<class T , class S >
MATRIX3x3< T > const operator* (T aScalar, MATRIX3x3< T > const &aMatrix)
 
template<class T , class S >
MATRIX3x3< T > const operator* (MATRIX3x3< T > const &aMatrix, S aScalar)
 
template<class T , class S >
MATRIX3x3< T > const operator* (S aScalar, MATRIX3x3< T > const &aMatrix)
 

Typedef Documentation

◆ MATRIX3x3D

typedef MATRIX3x3<double> MATRIX3x3D

Definition at line 473 of file matrix3x3.h.

Function Documentation

◆ operator*() [1/7]

template<class T >
MATRIX3x3< T > const operator* ( MATRIX3x3< T > const &  aA,
MATRIX3x3< T > const &  aB 
)

Matrix multiplication.

Definition at line 304 of file matrix3x3.h.

305{
306 MATRIX3x3<T> result;
307
308 for( int i = 0; i < 3; i++ )
309 {
310 for( int j = 0; j < 3; j++ )
311 {
312 result.m_data[i][j] = aA.m_data[i][0] * aB.m_data[0][j] +
313 aA.m_data[i][1] * aB.m_data[1][j] +
314 aA.m_data[i][2] * aB.m_data[2][j];
315 }
316 }
317
318 return result;
319}
MATRIX3x3 describes a general 3x3 matrix.
Definition: matrix3x3.h:63
T m_data[3][3]
Definition: matrix3x3.h:65

References MATRIX3x3< T >::m_data.

◆ operator*() [2/7]

template<class T , class S >
MATRIX3x3< T > const operator* ( MATRIX3x3< T > const &  aA,
aScalar 
)

Multiplication with a scalar.

◆ operator*() [3/7]

template<class T >
VECTOR2< T > const operator* ( MATRIX3x3< T > const &  aA,
VECTOR2< T > const &  aB 
)

Multiplication with a 2D vector, the 3rd z-component is assumed to be 1.

Definition at line 323 of file matrix3x3.h.

324{
325 VECTOR2<T> result( 0, 0 );
326 result.x = aMatrix.m_data[0][0] * aVector.x + aMatrix.m_data[0][1] * aVector.y
327 + aMatrix.m_data[0][2];
328 result.y = aMatrix.m_data[1][0] * aVector.x + aMatrix.m_data[1][1] * aVector.y
329 + aMatrix.m_data[1][2];
330
331 return result;
332}
Define a general 2D-vector/point.
Definition: vector2d.h:74

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

◆ operator*() [4/7]

template<class T >
VECTOR3< T > const operator* ( MATRIX3x3< T > const &  aA,
VECTOR3< T > const &  aB 
)

Definition at line 336 of file matrix3x3.h.

337{
338 VECTOR3<T> result( 0, 0, 0 );
339 result.x = aMatrix.m_data[0][0] * aVector.x + aMatrix.m_data[0][1] * aVector.y
340 + aMatrix.m_data[0][2] * aVector.z;
341 result.y = aMatrix.m_data[1][0] * aVector.x + aMatrix.m_data[1][1] * aVector.y
342 + aMatrix.m_data[1][2] * aVector.z;
343 result.z = aMatrix.m_data[2][0] * aVector.x + aMatrix.m_data[2][1] * aVector.y
344 + aMatrix.m_data[2][2] * aVector.z;
345
346 return result;
347}
Define a general 3D-vector.
Definition: vector3.h:53

References MATRIX3x3< T >::m_data, VECTOR3< T >::x, VECTOR3< T >::y, and VECTOR3< T >::z.

◆ operator*() [5/7]

template<class T , class S >
MATRIX3x3< T > const operator* ( MATRIX3x3< T > const &  aMatrix,
aScalar 
)

Definition at line 360 of file matrix3x3.h.

361{
362 MATRIX3x3<T> result;
363
364 for( int i = 0; i < 3; i++ )
365 {
366 for( int j = 0; j < 3; j++ )
367 {
368 result.m_data[i][j] = aMatrix.m_data[i][j] * aScalar;
369 }
370 }
371
372 return result;
373}

References MATRIX3x3< T >::m_data.

◆ operator*() [6/7]

template<class T , class S >
MATRIX3x3< T > const operator* ( aScalar,
MATRIX3x3< T > const &  aMatrix 
)

Definition at line 377 of file matrix3x3.h.

378{
379 return aMatrix * aScalar;
380}

◆ operator*() [7/7]

template<class T , class S >
MATRIX3x3< T > const operator* ( aScalar,
MATRIX3x3< T > const &  aMatrix 
)

◆ operator<<()

template<class T >
std::ostream & operator<< ( std::ostream &  aStream,
const MATRIX3x3< T > &  aMatrix 
)

Definition at line 422 of file matrix3x3.h.

423{
424 for( int i = 0; i < 3; i++ )
425 {
426 aStream << "| ";
427
428 for( int j = 0; j < 3; j++ )
429 {
430 aStream << aMatrix.m_data[i][j];
431 aStream << " ";
432 }
433
434 aStream << "|";
435 aStream << "\n";
436 }
437
438 return aStream;
439}

References MATRIX3x3< T >::m_data.