Beatmup
Beatmup::AffineMapping Class Reference

2x3 affine mapping containing a 2x2 matrix and a 2D point More...

#include <geometry.h>

Public Member Functions

 AffineMapping ()
 
 AffineMapping (const Matrix2 &aMatrix, const Point &aPosition)
 
 AffineMapping (const Rectangle &rectangle)
 Creates a mapping of unit square to a given rectangle. More...
 
Point getPosition () const
 
Matrix2 getMatrix () const
 
Point operator() (const Point &point) const
 Maps a point. More...
 
AffineMapping operator* (const AffineMapping &mapping) const
 Composition of two mappings. More...
 
void setIdentity ()
 
void invert ()
 Inverts the mapping. More...
 
AffineMapping getInverse () const
 Returns inverse mapping. More...
 
Point getInverse (const Point &pos) const
 Computes inverse mapping of a point. More...
 
Point getInverse (float x, float y) const
 
void setCenterPosition (const Point &newPos)
 Adjusts the mapping origin so that the center of the axes box matches a given point. More...
 
void translate (const Point &shift)
 Translates the mapping. More...
 
void scale (float factor, const Point &fixedPoint=Point::ZERO)
 Scales the mapping around a given point in target domain. More...
 
void rotateDegrees (float angle, const Point &fixedPoint=Point::ZERO)
 Rotates the mapping around a given point in target domain. More...
 
bool isPointInside (const Point &point) const
 Tests whether a point from the output domain is inside the input axes span. More...
 
bool isPointInside (float x, float y) const
 
bool isPointInside (float x, float y, float width, float height) const
 

Public Attributes

Matrix2 matrix
 
Point position
 

Static Public Attributes

static const AffineMapping IDENTITY
 

Detailed Description

2x3 affine mapping containing a 2x2 matrix and a 2D point

Definition at line 639 of file geometry.h.

Constructor & Destructor Documentation

◆ AffineMapping() [1/3]

AffineMapping::AffineMapping ( )

Definition at line 27 of file geometry.cpp.

27 {}

◆ AffineMapping() [2/3]

AffineMapping::AffineMapping ( const Matrix2 aMatrix,
const Point aPosition 
)

Definition at line 29 of file geometry.cpp.

29  :
30  matrix(aMatrix), position(aPosition)
31 {}

◆ AffineMapping() [3/3]

AffineMapping::AffineMapping ( const Rectangle rectangle)

Creates a mapping of unit square to a given rectangle.

Parameters
[in]rectangleThe rectangle

Definition at line 33 of file geometry.cpp.

33  :
34  matrix(rectangle.width(), rectangle.height()), position(rectangle.getX1(), rectangle.getY1())
35 {}
numeric height() const
Definition: geometry.h:178
numeric width() const
Definition: geometry.h:174
numeric getX1() const
Definition: geometry.h:169
numeric getY1() const
Definition: geometry.h:170

Member Function Documentation

◆ getPosition()

Point Beatmup::AffineMapping::getPosition ( ) const
inline

Definition at line 653 of file geometry.h.

653  {
654  return position;
655  }

◆ getMatrix()

Matrix2 Beatmup::AffineMapping::getMatrix ( ) const
inline

Definition at line 657 of file geometry.h.

657  {
658  return matrix;
659  }

◆ operator()()

Point Beatmup::AffineMapping::operator() ( const Point point) const
inline

Maps a point.

Definition at line 664 of file geometry.h.

664  {
665  return matrix(point) + position;
666  }

◆ operator*()

AffineMapping AffineMapping::operator* ( const AffineMapping mapping) const

Composition of two mappings.

Definition at line 38 of file geometry.cpp.

38  {
40 }
Beatmup::AffineMapping & mapping

◆ setIdentity()

void AffineMapping::setIdentity ( )

Definition at line 42 of file geometry.cpp.

42  {
43  matrix.setElements(1.0f, 0.0f, 0.0f, 1.0f);
45 }
void setElements(float a11, float a12, float a21, float a22)
Sets matrix element values.
Definition: geometry.h:582
static const CustomPoint ZERO
Definition: geometry.h:122

◆ invert()

void AffineMapping::invert ( )

Inverts the mapping.

Definition at line 47 of file geometry.cpp.

47  {
49  position = -(matrix * position);
50 }
CustomMatrix2 getInverse() const
Computes inverse transformation.
Definition: geometry.h:464

◆ getInverse() [1/3]

AffineMapping AffineMapping::getInverse ( ) const

Returns inverse mapping.

Definition at line 52 of file geometry.cpp.

52  {
53  AffineMapping inverse;
54  inverse.matrix = matrix.getInverse();
55  inverse.position = - ( inverse.matrix * position );
56  return inverse;
57 }
2x3 affine mapping containing a 2x2 matrix and a 2D point
Definition: geometry.h:639

◆ getInverse() [2/3]

Point AffineMapping::getInverse ( const Point pos) const

Computes inverse mapping of a point.

Definition at line 59 of file geometry.cpp.

59  {
60  return matrix.getInverse(point.x - position.x, point.y - position.y);
61 }

◆ getInverse() [3/3]

Point AffineMapping::getInverse ( float  x,
float  y 
) const

Definition at line 63 of file geometry.cpp.

63  {
64  return matrix.getInverse(x - position.x, y - position.y);
65 }
jobject jlong jint jint y
jobject jlong jint x

◆ setCenterPosition()

void AffineMapping::setCenterPosition ( const Point newPos)

Adjusts the mapping origin so that the center of the axes box matches a given point.

Definition at line 67 of file geometry.cpp.

67  {
68  position = newPos - matrix(0.5f, 0.5f);
69 }

◆ translate()

void AffineMapping::translate ( const Point shift)

Translates the mapping.

Definition at line 71 of file geometry.cpp.

71  {
72  position = position + shift;
73 }

◆ scale()

void AffineMapping::scale ( float  factor,
const Point fixedPoint = Point::ZERO 
)

Scales the mapping around a given point in target domain.

Definition at line 75 of file geometry.cpp.

75  {
76  const Point pos0 = matrix(fixedPoint);
78  position = position + pos0 - matrix * fixedPoint;
79 }
void scale(numeric factor)
Definition: geometry.h:399
layer getMapping().setCenterPosition(Beatmup jlong jfloat factor

◆ rotateDegrees()

void AffineMapping::rotateDegrees ( float  angle,
const Point fixedPoint = Point::ZERO 
)

Rotates the mapping around a given point in target domain.

Definition at line 81 of file geometry.cpp.

81  {
82  const Point pos0 = matrix(fixedPoint);
83  matrix.rotateDegrees(angle);
84  position = position + pos0 - matrix * fixedPoint;
85 }
void rotateDegrees(float angle)
Definition: geometry.h:429

◆ isPointInside() [1/3]

bool AffineMapping::isPointInside ( const Point point) const

Tests whether a point from the output domain is inside the input axes span.

Definition at line 87 of file geometry.cpp.

87  {
88  return isPointInside(point.x, point.y);
89 }
bool isPointInside(const Point &point) const
Tests whether a point from the output domain is inside the input axes span.
Definition: geometry.cpp:87

◆ isPointInside() [2/3]

bool AffineMapping::isPointInside ( float  x,
float  y 
) const

Definition at line 91 of file geometry.cpp.

91  {
93 }
bool isPointInsideAxes(numeric x, numeric y, numeric w, numeric h) const
Checks whether a given input point is inside the unit square when transformed.
Definition: geometry.h:536

◆ isPointInside() [3/3]

bool AffineMapping::isPointInside ( float  x,
float  y,
float  width,
float  height 
) const

Definition at line 95 of file geometry.cpp.

95  {
97 }
jlong jint width
jlong jint jint height

Member Data Documentation

◆ matrix

Matrix2 Beatmup::AffineMapping::matrix

Definition at line 641 of file geometry.h.

◆ position

Point Beatmup::AffineMapping::position

Definition at line 642 of file geometry.h.

◆ IDENTITY

const AffineMapping AffineMapping::IDENTITY
static

Definition at line 717 of file geometry.h.


The documentation for this class was generated from the following files: