Rhino C++ API  9.0
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ON_2x2Matrix Class Reference

#include <opennurbs_matrix.h>

Public Member Functions

 ON_2x2Matrix ()=default
 
 ON_2x2Matrix (const class ON_Matrix &M)
 
 ON_2x2Matrix (const double M[2][2])
 
 ON_2x2Matrix (const ON_2x2Matrix &)=default
 
 ON_2x2Matrix (double a, double b, double c, double d)
 
 ON_2x2Matrix (double d)
 
 ON_2x2Matrix (double d0, double d1)
 
 ON_2x2Matrix (double M[2][2])
 
 ~ON_2x2Matrix ()=default
 
double Coefficient (int i, int j) const
 
double Determinant () const
 
const ON_2x2Matrix Inverse () const
 
bool IsDiagonal () const
 
bool IsDiagonal (double relative_tolerance) const
 
bool IsIdentity () const
 
bool IsIdentity (double tolerance) const
 
bool IsNotZero () const
 
bool IsNotZero (double zero_tolerance) const
 
bool IsOrthoganal () const
 
bool IsOrthoganal (double tolerance) const
 M is an orthoganal matrix if M * Transpose(M) = Identity. More...
 
bool IsValid () const
 
bool IsZero () const
 
bool IsZero (double zero_tolerance) const
 
double MaximumCoefficientAbsoluteValue () const
 
double MaximumDigonalAbsoluteValue () const
 
double MaximumOffDigonalAbsoluteValue () const
 
double MinimumCoefficientAbsoluteValue () const
 
double MinimumDigonalAbsoluteValue () const
 
double MinimumOffDigonalAbsoluteValue () const
 
ON_2x2Matrixoperator= (const ON_2x2Matrix &)=default
 
double * operator[] (int i)
 
const double * operator[] (int i) const
 
const ON_2x2Matrix PseudoInverse () const
 Use the singular value decomposition to get the pseudo inverse. More...
 
int Rank () const
 
int Rank (double zero_tolerance) const
 
bool SVD (ON_2x2Matrix &U, double singular_values[2], ON_2x2Matrix &V) const
 Get the singular vaue decomposition of this matrix = U * Diagonal(singular_values[0], singular_values[1]) * Transpose(V). More...
 
const ON_2x2Matrix SwapColumns () const
 
const ON_2x2Matrix SwapRows () const
 
const ON_2x2Matrix SwapRowsAndColumns () const
 
double Trace () const
 
const ON_2x2Matrix Transpose () const
 

Static Public Member Functions

static const ON_2x2Matrix CombineSVD (const ON_2x2Matrix &U, double s0, double s1, const ON_2x2Matrix &V)
 
static const ON_2x2Matrix ProcrustesRotation (const ON_2dPoint &P0, const ON_2dPoint &P1, const ON_2dPoint &P2, const ON_2dPoint &Q0, const ON_2dPoint &Q1, const ON_2dPoint &Q2)
 Use theKabsch-Umeyama algorithm to calculate the rotation matrix R that minimizes |R*P0 - Q0|^2 + |R*P1 - Q1|^2 + |R*P2 - Q2|^2.
The input must satisfy P0 + P1 + P2 = (0,0) and Q0 + Q1 + Q2 = (0,0). Typically, by the time you are calculating this rotation, the P and Q triangles have the same orientation. If you want a rotation matrix that acts on the right, take the transpose of the returned value. If you have more than 3 points, use the version of ProcrustesRotation() that takes a 2x2 matrix H = P * Transpose(Q). More...
 
static const ON_2x2Matrix ProcrustesRotation (const ON_2x2Matrix &H)
 If P[] and Q[] are sets of N 2d points, N gt;= 3, P[0] + ... + P[N-1] = (0,0) and Q[0] + ... + Q[N-1] = (0,0), then the Procrustes left rotation R is the rotation matrix that minimizes |R*P[0] - Q[0]|^2 + ... + |R*P[N-1] - Q[N-1]|^2. More...
 
static const ON_2x2Matrix Rotation (double cos_angle, double sin_angle)
 Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix. More...
 
static const ON_2x2Matrix Rotation (ON_2dVector V)
 Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix. More...
 
static const ON_2x2Matrix RotationDegrees (double angle_degrees)
 Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix. More...
 
static const ON_2x2Matrix RotationRadians (double angle_radians)
 Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix. More...
 
static bool Test (ON_TextLog &text_log)
 Test a ON_2x2Matrix::SVD(), ON_2x2Matrix::Determinant(), ON_2x2Matrix::Rank() and ON_2x2Matrix::Inverse() on every matrix returned by the version of TestList() with a callback parameter More...
 
static unsigned TestList (ON__UINT_PTR context, bool(*Callback)(ON__UINT_PTR context, int A_rank, const ON_2x2Matrix A))
 Iterates through a sequence of test matrices. More...
 

Public Attributes

double m [2][2]
 

Static Public Attributes

static const ON_2x2Matrix Identity
 The diagonal coefficients are 1 and the off diagonal coefficients are 0. More...
 
static const ON_2x2Matrix Nan
 Every coefficient is ON_DBL_QNAN. More...
 
static const ON_2x2Matrix Zero
 All coefficients are 0. More...
 
static const double ZeroTolerance
 Default zero tolerance that can be used when a nonzero tolerance is needed and you don't know what to pass. 1.0e-12. More...
 

Constructor & Destructor Documentation

◆ ON_2x2Matrix() [1/8]

ON_2x2Matrix::ON_2x2Matrix ( )
default

◆ ~ON_2x2Matrix()

ON_2x2Matrix::~ON_2x2Matrix ( )
default

◆ ON_2x2Matrix() [2/8]

ON_2x2Matrix::ON_2x2Matrix ( const ON_2x2Matrix )
default

◆ ON_2x2Matrix() [3/8]

ON_2x2Matrix::ON_2x2Matrix ( double  M[2][2])

◆ ON_2x2Matrix() [4/8]

ON_2x2Matrix::ON_2x2Matrix ( const double  M[2][2])

◆ ON_2x2Matrix() [5/8]

ON_2x2Matrix::ON_2x2Matrix ( double  d)

◆ ON_2x2Matrix() [6/8]

ON_2x2Matrix::ON_2x2Matrix ( double  d0,
double  d1 
)

◆ ON_2x2Matrix() [7/8]

ON_2x2Matrix::ON_2x2Matrix ( double  a,
double  b,
double  c,
double  d 
)

◆ ON_2x2Matrix() [8/8]

ON_2x2Matrix::ON_2x2Matrix ( const class ON_Matrix M)

Member Function Documentation

◆ Coefficient()

double ON_2x2Matrix::Coefficient ( int  i,
int  j 
) const

◆ CombineSVD()

static const ON_2x2Matrix ON_2x2Matrix::CombineSVD ( const ON_2x2Matrix U,
double  s0,
double  s1,
const ON_2x2Matrix V 
)
static

◆ Determinant()

double ON_2x2Matrix::Determinant ( ) const

◆ Inverse()

const ON_2x2Matrix ON_2x2Matrix::Inverse ( ) const

◆ IsDiagonal() [1/2]

bool ON_2x2Matrix::IsDiagonal ( ) const

◆ IsDiagonal() [2/2]

bool ON_2x2Matrix::IsDiagonal ( double  relative_tolerance) const

◆ IsIdentity() [1/2]

bool ON_2x2Matrix::IsIdentity ( ) const
Returns
True if the diagonal coefficients are 1 and the off diagonal coefficients are 0.

◆ IsIdentity() [2/2]

bool ON_2x2Matrix::IsIdentity ( double  tolerance) const
Parameters
tolerance
Returns
True if fabs(x - 1.0) <= tolerance for both diagonal coefficients and fabs(x) <= tolerance for both off diagonal coefficients.

◆ IsNotZero() [1/2]

bool ON_2x2Matrix::IsNotZero ( ) const
Parameters
zero_tolerance
Returns
True if at least one coefficient is not zero and all coefficients are valid.

◆ IsNotZero() [2/2]

bool ON_2x2Matrix::IsNotZero ( double  zero_tolerance) const
Parameters
zero_tolerance
Returns
True if the absolute value of at least one coefficient is > zero_tolerance and coefficients are valid.

◆ IsOrthoganal() [1/2]

bool ON_2x2Matrix::IsOrthoganal ( ) const

◆ IsOrthoganal() [2/2]

bool ON_2x2Matrix::IsOrthoganal ( double  tolerance) const

M is an orthoganal matrix if M * Transpose(M) = Identity.

Parameters
toleranceIf every coefficient of (M * Transpose(M) - Idenity) has absolute value <= tolerance, then true is returned.
Returns
True if this matrix is orthoganal.

◆ IsValid()

bool ON_2x2Matrix::IsValid ( ) const

◆ IsZero() [1/2]

bool ON_2x2Matrix::IsZero ( ) const
Returns
True if the absolute values of all four coefficients are 0.

◆ IsZero() [2/2]

bool ON_2x2Matrix::IsZero ( double  zero_tolerance) const
Parameters
zero_tolerance
Returns
True if the absolute values of all four coefficients are <= zero_tolerance.

◆ MaximumCoefficientAbsoluteValue()

double ON_2x2Matrix::MaximumCoefficientAbsoluteValue ( ) const

◆ MaximumDigonalAbsoluteValue()

double ON_2x2Matrix::MaximumDigonalAbsoluteValue ( ) const

◆ MaximumOffDigonalAbsoluteValue()

double ON_2x2Matrix::MaximumOffDigonalAbsoluteValue ( ) const

◆ MinimumCoefficientAbsoluteValue()

double ON_2x2Matrix::MinimumCoefficientAbsoluteValue ( ) const

◆ MinimumDigonalAbsoluteValue()

double ON_2x2Matrix::MinimumDigonalAbsoluteValue ( ) const

◆ MinimumOffDigonalAbsoluteValue()

double ON_2x2Matrix::MinimumOffDigonalAbsoluteValue ( ) const

◆ operator=()

ON_2x2Matrix& ON_2x2Matrix::operator= ( const ON_2x2Matrix )
default

◆ operator[]() [1/2]

double* ON_2x2Matrix::operator[] ( int  i)

Parameters
i0 <= i < 1
Returns
If i is 0 or 1, the pointer to the i-th row is returned. Otherwise nullptr is returned.

◆ operator[]() [2/2]

const double* ON_2x2Matrix::operator[] ( int  i) const

Parameters
i0 <= i < 1
Returns
If i is 0 or 1, the pointer to the i-th row is returned. Otherwise nullptr is returned.

◆ ProcrustesRotation() [1/2]

static const ON_2x2Matrix ON_2x2Matrix::ProcrustesRotation ( const ON_2dPoint P0,
const ON_2dPoint P1,
const ON_2dPoint P2,
const ON_2dPoint Q0,
const ON_2dPoint Q1,
const ON_2dPoint Q2 
)
static

Use theKabsch-Umeyama algorithm to calculate the rotation matrix R that minimizes |R*P0 - Q0|^2 + |R*P1 - Q1|^2 + |R*P2 - Q2|^2.
The input must satisfy P0 + P1 + P2 = (0,0) and Q0 + Q1 + Q2 = (0,0). Typically, by the time you are calculating this rotation, the P and Q triangles have the same orientation. If you want a rotation matrix that acts on the right, take the transpose of the returned value. If you have more than 3 points, use the version of ProcrustesRotation() that takes a 2x2 matrix H = P * Transpose(Q).

Parameters
P0
P1
P2
Q0
Q1
Q2
Returns
The Procrustes rotation matrix that acts on the left of points.

◆ ProcrustesRotation() [2/2]

static const ON_2x2Matrix ON_2x2Matrix::ProcrustesRotation ( const ON_2x2Matrix H)
static

If P[] and Q[] are sets of N 2d points, N gt;= 3, P[0] + ... + P[N-1] = (0,0) and Q[0] + ... + Q[N-1] = (0,0), then the Procrustes left rotation R is the rotation matrix that minimizes |R*P[0] - Q[0]|^2 + ... + |R*P[N-1] - Q[N-1]|^2.

Parameters
HH = P * Transpose(Q), where P is the 2xN matrix whose columns are P[0], ..., P[N-1] and Q is the 2xN matrix whose columns are Q[0], ..., Q[N-1].
Returns
The Procrustes rotation matrix that acts on the left of points.

◆ PseudoInverse()

const ON_2x2Matrix ON_2x2Matrix::PseudoInverse ( ) const

Use the singular value decomposition to get the pseudo inverse.

Returns
V*Diagonal(1/sigma0, 1/sigma1)*Transpose(U) where U * Diagonal(sigma0, sigma1) * Transpose(V) is the singular value decomposistion.

◆ Rank() [1/2]

int ON_2x2Matrix::Rank ( ) const
Returns
Rank(0.0).

◆ Rank() [2/2]

int ON_2x2Matrix::Rank ( double  zero_tolerance) const
Parameters
zero_toleranceCoefficients and determinants with absolute value <= zero_tolerance are treated as 0. ///
Returns
If this matrix is valid, the rank is returned. Otherwise -1 is returned.

◆ Rotation() [1/2]

static const ON_2x2Matrix ON_2x2Matrix::Rotation ( double  cos_angle,
double  sin_angle 
)
static

Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix.

Parameters
cos_angle
sin_angle
Returns
The matrix R such that ON_2dVector(cos_angle, sin_angle) = R * ON_2dVector::XAxis.

◆ Rotation() [2/2]

static const ON_2x2Matrix ON_2x2Matrix::Rotation ( ON_2dVector  V)
static

Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix.

Parameters
V
Returns
The matrix R such that V = R * ON_2dVector::XAxis.

◆ RotationDegrees()

static const ON_2x2Matrix ON_2x2Matrix::RotationDegrees ( double  angle_degrees)
static

Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix.

Parameters
angle_degrees
Returns
The matrix R such that R * P rotates P counterclockwise by angle_degrees.

◆ RotationRadians()

static const ON_2x2Matrix ON_2x2Matrix::RotationRadians ( double  angle_radians)
static

Get a rotation matrix that acts on the left (rotated point = R * point). If you want a rotation matrix that acts on the right, then use the transpose of the returned matrix.

Parameters
angle_radians
Returns
The matrix R such that R * P rotates P counterclockwise by angle_radians.

◆ SVD()

bool ON_2x2Matrix::SVD ( ON_2x2Matrix U,
double  singular_values[2],
ON_2x2Matrix V 
) const

Get the singular vaue decomposition of this matrix = U * Diagonal(singular_values[0], singular_values[1]) * Transpose(V).

Parameters
UThe returned U will be an orthoganal matrix.
singular_valuesThe singular values are returned in increasing order 0 <= singular_values[0] <= singular_values[1].
VThe returned V will be an orthoganal matrix.
Returns

◆ SwapColumns()

const ON_2x2Matrix ON_2x2Matrix::SwapColumns ( ) const

◆ SwapRows()

const ON_2x2Matrix ON_2x2Matrix::SwapRows ( ) const

◆ SwapRowsAndColumns()

const ON_2x2Matrix ON_2x2Matrix::SwapRowsAndColumns ( ) const

◆ Test()

static bool ON_2x2Matrix::Test ( ON_TextLog text_log)
static

Test a ON_2x2Matrix::SVD(), ON_2x2Matrix::Determinant(), ON_2x2Matrix::Rank() and ON_2x2Matrix::Inverse() on every matrix returned by the version of TestList() with a callback parameter

Parameters
text_logA description of any failure and the number of successful tests is sent to text_log.
Returns
True if every test passes.

◆ TestList()

static unsigned ON_2x2Matrix::TestList ( ON__UINT_PTR  context,
bool(*)(ON__UINT_PTR context, int A_rank, const ON_2x2Matrix A Callback 
)
static

Iterates through a sequence of test matrices.

Parameters
contextValue passed as the first parameter to Callback()
CallbackThis function is called for each test matrix. A is the matrix being tested. If the A_rank paratmer is >=0, then A was computed in a way that if arithmetic was perfect, then A.rank() would be A_rank. Otherwise A_rank = -1 and the rank of A is unknown. Return true to continue testing
Returns
Number of times Callback() returned true.

◆ Trace()

double ON_2x2Matrix::Trace ( ) const

◆ Transpose()

const ON_2x2Matrix ON_2x2Matrix::Transpose ( ) const

Member Data Documentation

◆ Identity

const ON_2x2Matrix ON_2x2Matrix::Identity
static

The diagonal coefficients are 1 and the off diagonal coefficients are 0.

◆ m

double ON_2x2Matrix::m[2][2]

◆ Nan

const ON_2x2Matrix ON_2x2Matrix::Nan
static

Every coefficient is ON_DBL_QNAN.

◆ Zero

const ON_2x2Matrix ON_2x2Matrix::Zero
static

All coefficients are 0.

◆ ZeroTolerance

const double ON_2x2Matrix::ZeroTolerance
static

Default zero tolerance that can be used when a nonzero tolerance is needed and you don't know what to pass. 1.0e-12.