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

#include <opennurbs_xform.h>

Public Member Functions

 ON_Xform2d ()
 
 ON_Xform2d (const ON_Xform2d &)=default
 
 ON_Xform2d (double m00, double m01, double m02, double m10, double m11, double m12)
 
 ~ON_Xform2d ()=default
 
int Compare (const ON_Xform2d &other) const
 
ON__UINT32 CRC32 (ON__UINT32 current_remainder) const
 
double Determinant () const
 
void GetAffineElements (double &a, double &b, double &c, double &d, double &tx, double &ty) const
 Get the six coefficients used by the traditional 2d drawing APIs. More...
 
void GetAffineElements (double abcdtxty[6]) const
 Fills in an array of 6 doubles in (a,b,c,d,tx,ty) order. More...
 
void GetAffineElements (float abcdtxty[6]) const
 
const ON_SHA1_Hash Hash () const
 
ON_Xform2d Inverse (double *determinant=nullptr) const
 
bool Invert (double *determinant=nullptr)
 
bool IsIdentity () const
 
bool IsNan () const
 
bool IsTranslation () const
 
bool IsValid () const
 
bool IsZeroTransformation () const
 
bool operator!= (const ON_Xform2d &rhs) const
 Intentionally returns false if any coefficient is a nan. More...
 
ON_2dPoint operator* (const ON_2dPoint &) const
 operators More...
 
ON_2dVector operator* (const ON_2dVector &) const
 
ON_Xform2d operator* (const ON_Xform2d &) const
 
ON_Xform2d & operator= (const ON_Xform2d &)=default
 
bool operator== (const ON_Xform2d &rhs) const
 Intentionally returns false if any coefficient is a nan. More...
 
double * operator[] (int)
 Returns &m_xform[i][0] when 0 <= i < 2 and nullptr otherwise. More...
 
const double * operator[] (int) const
 
const ON_Xform ToXform () const
 

Static Public Member Functions

static const ON_Xform2d FromAffineElements (const double abcdtxty[6])
 From an array of 6 doubles in (a,b,c,d,tx,ty) order. More...
 
static const ON_Xform2d FromAffineElements (const float abcdtxty[6])
 From an array of 6 floats in (a,b,c,d,tx,ty) order. More...
 
static const ON_Xform2d FromAffineElements (double a, double b, double c, double d, double tx, double ty)
 
static const ON_Xform2d FromXform (const ON_Xform &xform, double zero_tolerance=0.0)
 
static const ON_Xform2d RotationTransformation (const ON_2dVector &start_dir, const ON_2dVector &end_dir, const ON_2dPoint &rotation_center=ON_2dPoint::Origin)
 
static const ON_Xform2d RotationTransformationFromAngleRadians (double angle_radians, const ON_2dPoint &rotation_center=ON_2dPoint::Origin)
 
static const ON_Xform2d RotationTransformationFromSineAndCosine (double sin_angle, double cos_angle, const ON_2dPoint &rotation_center=ON_2dPoint::Origin)
 
static const ON_Xform2d ScaleTransformation (const ON_2dPoint &fixed_point, double scale_factor)
 
static const ON_Xform2d ScaleTransformation (const ON_2dPoint &fixed_point, double x_scale_factor, double y_scale_factor)
 
static const ON_Xform2d TranslationTransformation (const ON_2dVector &delta)
 standard transformations More...
 
static const ON_Xform2d TranslationTransformation (double dx, double dy)
 

Public Attributes

double m_xform [2][3]
 

Static Public Attributes

static const ON_Xform2d IdentityTransformation
 
static const ON_Xform2d Nan
 ON_Xform2d::Nan - every stored coefficient is ON_DBL_QNAN. More...
 
static const ON_Xform2d Unset
 ON_Xform2d::Unset - every stored coefficient is ON_UNSET_VALUE. More...
 
static const ON_Xform2d ZeroTransformation
 

Detailed Description

Description: ON_Xform2d is a 2d affine transformation and is the 2d analog of ON_Xform. It is intended for use with the traditional 2d drawing APIs which represents a 2d transformation with six coefficients.

Constructor & Destructor Documentation

◆ ON_Xform2d() [1/3]

ON_Xform2d::ON_Xform2d ( )

Description: Like ON_Xform, the default constructor creates the ZERO transformation, not the identity transformation. Every coefficient is zero. Use ON_Xform2d::IdentityTransformation when you want the identity.

◆ ~ON_Xform2d()

ON_Xform2d::~ON_Xform2d ( )
default

◆ ON_Xform2d() [2/3]

ON_Xform2d::ON_Xform2d ( const ON_Xform2d &  )
default

◆ ON_Xform2d() [3/3]

ON_Xform2d::ON_Xform2d ( double  m00,
double  m01,
double  m02,
double  m10,
double  m11,
double  m12 
)

Member Function Documentation

◆ Compare()

int ON_Xform2d::Compare ( const ON_Xform2d &  other) const

Description: Well ordered dictionary compare that is nan aware.

◆ CRC32()

ON__UINT32 ON_Xform2d::CRC32 ( ON__UINT32  current_remainder) const

◆ Determinant()

double ON_Xform2d::Determinant ( ) const

Returns: The determinant of the 2x2 linear part, m_xform[0][0]*m_xform[1][1] - m_xform[0][1]*m_xform[1][0]. Because the bottom row is (0,0,1), this is also the determinant of the full 3x3 matrix and the signed area scale factor of the transformation. A negative determinant means the transformation reverses orientation.

◆ FromAffineElements() [1/3]

static const ON_Xform2d ON_Xform2d::FromAffineElements ( const double  abcdtxty[6])
static

From an array of 6 doubles in (a,b,c,d,tx,ty) order.

◆ FromAffineElements() [2/3]

static const ON_Xform2d ON_Xform2d::FromAffineElements ( const float  abcdtxty[6])
static

From an array of 6 floats in (a,b,c,d,tx,ty) order.

◆ FromAffineElements() [3/3]

static const ON_Xform2d ON_Xform2d::FromAffineElements ( double  a,
double  b,
double  c,
double  d,
double  tx,
double  ty 
)
static

Description: The traditional 2d drawing APIs store an affine transformation as six numbers (a,b,c,d,tx,ty) that map a point (x,y) to x1 = a*x + c*y + tx y1 = b*x + d*y + ty These are the six numbers, in this order, used by Eto.Drawing.Matrix, Windows GDI+, Direct2D (D2D1_MATRIX_3X2_F), Core Graphics (CGAffineTransform), Cairo (cairo_matrix_t), Java 2D, SVG and PDF. In terms of ON_Xform2d coefficients, a = m_xform[0][0] c = m_xform[0][1] tx = m_xform[0][2] b = m_xform[1][0] d = m_xform[1][1] ty = m_xform[1][2] Note well that (a,b,c,d,tx,ty) is the transpose of the ON_Xform2d coefficient order, because those APIs use the row vector convention. Composition order is reversed as well. If A2d and B2d are the ON_Xform2d equivalents of the platform transformations A and B, then A2d * B2d is the equivalent of B * A

◆ FromXform()

static const ON_Xform2d ON_Xform2d::FromXform ( const ON_Xform &  xform,
double  zero_tolerance = 0.0 
)
static

Description: Get the 2d transformation defined by the x and y rows and columns of a 4x4 transformation. Parameters: xform - [in] zero_tolerance - [in] An element of xform is "zero" if fabs(x) <= zero_tolerance and is "one" if fabs(1.0-x) <= zero_tolerance. Returns: The 2d transformation xform[0][0] xform[0][1] xform[0][3] xform[1][0] xform[1][1] xform[1][3] if xform is affine and maps the world xy plane to itself, i.e. the z row and z column of the linear part are (0,0,1) and xform[2][3] is zero. Otherwise ON_Xform2d::Nan is returned.

◆ GetAffineElements() [1/3]

void ON_Xform2d::GetAffineElements ( double &  a,
double &  b,
double &  c,
double &  d,
double &  tx,
double &  ty 
) const

Get the six coefficients used by the traditional 2d drawing APIs.

◆ GetAffineElements() [2/3]

void ON_Xform2d::GetAffineElements ( double  abcdtxty[6]) const

Fills in an array of 6 doubles in (a,b,c,d,tx,ty) order.

◆ GetAffineElements() [3/3]

void ON_Xform2d::GetAffineElements ( float  abcdtxty[6]) const

Fills in an array of 6 floats in (a,b,c,d,tx,ty) order. This is the layout of D2D1_MATRIX_3X2_F.

◆ Hash()

const ON_SHA1_Hash ON_Xform2d::Hash ( ) const

◆ Inverse()

ON_Xform2d ON_Xform2d::Inverse ( double *  determinant = nullptr) const

Description: If the linear part of this transformation is non-singular, the inverse is returned. Otherwise the pseudo inverse is returned. Parameters: determinant - [out] If not nullptr, the determinant of this transformation is returned here.

◆ Invert()

bool ON_Xform2d::Invert ( double *  determinant = nullptr)

Description: If the linear part of this transformation is non-singular, this is replaced with its inverse and true is returned. Otherwise this is replaced with the pseudo inverse and false is returned. Parameters: determinant - [out] If not nullptr, the determinant of the transformation before it was inverted is returned here. Returns: True if this transformation is invertible.

◆ IsIdentity()

bool ON_Xform2d::IsIdentity ( ) const

Returns: true if the matrix is the identity transformation

◆ IsNan()

bool ON_Xform2d::IsNan ( ) const

Returns: True if any coefficient in the transformation matrix is a nan.

◆ IsTranslation()

bool ON_Xform2d::IsTranslation ( ) const

Returns: true if the matrix is a pure translation

◆ IsValid()

bool ON_Xform2d::IsValid ( ) const

Returns: True if ON_IsValid() is true for every coefficient in the transformation matrix.

◆ IsZeroTransformation()

bool ON_Xform2d::IsZeroTransformation ( ) const

Returns: true if every stored coefficient is zero.

◆ operator!=()

bool ON_Xform2d::operator!= ( const ON_Xform2d &  rhs) const

Intentionally returns false if any coefficient is a nan.

◆ operator*() [1/3]

ON_2dPoint ON_Xform2d::operator* ( const ON_2dPoint &  ) const

operators

Note well: The right hand column is the translation. It has an important effect when transforming a Euclidean point and has no effect when transforming a vector.

◆ operator*() [2/3]

ON_2dVector ON_Xform2d::operator* ( const ON_2dVector &  ) const

Note well: The right hand column is the translation. It has an important effect when transforming a Euclidean point and has no effect when transforming a vector.

◆ operator*() [3/3]

ON_Xform2d ON_Xform2d::operator* ( const ON_Xform2d &  ) const

The returned transformation applies the right hand side first, i.e. (A*B)*P == A*(B*P).

◆ operator=()

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

◆ operator==()

bool ON_Xform2d::operator== ( const ON_Xform2d &  rhs) const

Intentionally returns false if any coefficient is a nan.

◆ operator[]() [1/2]

double* ON_Xform2d::operator[] ( int  )

Returns &m_xform[i][0] when 0 <= i < 2 and nullptr otherwise.

◆ operator[]() [2/2]

const double* ON_Xform2d::operator[] ( int  ) const

◆ RotationTransformation()

static const ON_Xform2d ON_Xform2d::RotationTransformation ( const ON_2dVector &  start_dir,
const ON_2dVector &  end_dir,
const ON_2dPoint &  rotation_center = ON_2dPoint::Origin 
)
static

Description: Calculate the rotation that rotates start_dir to end_dir while fixing rotation_center. Parameters: start_dir - [in] nonzero vector end_dir - [in] nonzero vector rotation_center - [in] the fixed point of the rotation Returns: If the input is valid, a rotation transformation is returned. Otherwise ON_Xform2d::Nan is returned.

◆ RotationTransformationFromAngleRadians()

static const ON_Xform2d ON_Xform2d::RotationTransformationFromAngleRadians ( double  angle_radians,
const ON_2dPoint &  rotation_center = ON_2dPoint::Origin 
)
static

Description Create a rotation transformation from an angle in radians and a rotation center. A positive angle rotates the x axis towards the y axis (counter-clockwise in a right handed coordinate system). Parameters: angle_radians [in] - An angle in radians rotation_center [in] - The fixed point of the rotation. Returns: If the input is valid, a rotation transformation is returned. Otherwise ON_Xform2d::Nan is returned.

◆ RotationTransformationFromSineAndCosine()

static const ON_Xform2d ON_Xform2d::RotationTransformationFromSineAndCosine ( double  sin_angle,
double  cos_angle,
const ON_2dPoint &  rotation_center = ON_2dPoint::Origin 
)
static

Description Create a rotation transformation from the sine and cosine of an angle and a rotation center. Returns: If the input is valid, a rotation transformation is returned. Otherwise ON_Xform2d::Nan is returned.

◆ ScaleTransformation() [1/2]

static const ON_Xform2d ON_Xform2d::ScaleTransformation ( const ON_2dPoint &  fixed_point,
double  scale_factor 
)
static

Description: Create a uniform scale transformation with a specified fixed point.

◆ ScaleTransformation() [2/2]

static const ON_Xform2d ON_Xform2d::ScaleTransformation ( const ON_2dPoint &  fixed_point,
double  x_scale_factor,
double  y_scale_factor 
)
static

Description: Create a non-uniform scale transformation with a specified fixed point.

◆ ToXform()

const ON_Xform ON_Xform2d::ToXform ( ) const

Returns: The 4x4 transformation that applies this transformation to the x and y coordinates and leaves the z coordinate unchanged. m00 m01 0 m02 m10 m11 0 m12 0 0 1 0 0 0 0 1

◆ TranslationTransformation() [1/2]

static const ON_Xform2d ON_Xform2d::TranslationTransformation ( const ON_2dVector &  delta)
static

standard transformations

Right column is (delta.x, delta.y).

◆ TranslationTransformation() [2/2]

static const ON_Xform2d ON_Xform2d::TranslationTransformation ( double  dx,
double  dy 
)
static

Member Data Documentation

◆ IdentityTransformation

const ON_Xform2d ON_Xform2d::IdentityTransformation
static

ON_Xform2d::IdentityTransformation The linear part is the 2x2 identity and the translation is zero. 1 0 0 0 1 0

◆ m_xform

double ON_Xform2d::m_xform[2][3]

[i][j] = row i, column j. I.e., [0][0] [0][1] [0][2] [1][0] [1][1] [1][2]

◆ Nan

const ON_Xform2d ON_Xform2d::Nan
static

ON_Xform2d::Nan - every stored coefficient is ON_DBL_QNAN.

◆ Unset

const ON_Xform2d ON_Xform2d::Unset
static

ON_Xform2d::Unset - every stored coefficient is ON_UNSET_VALUE.

◆ ZeroTransformation

const ON_Xform2d ON_Xform2d::ZeroTransformation
static

ON_Xform2d::ZeroTransformation Every stored coefficient is zero. 0 0 0 0 0 0