MNN
1.0
|
#include <Matrix.h>
Public 类型 | |
enum | TypeMask { kIdentity_Mask = 0, kTranslate_Mask = 0x01, kScale_Mask = 0x02, kAffine_Mask = 0x04, kPerspective_Mask = 0x08 } |
enum | ScaleToFit { kFill_ScaleToFit, kStart_ScaleToFit, kCenter_ScaleToFit, kEnd_ScaleToFit } |
Public 成员函数 | |
Matrix () | |
TypeMask | getType () const |
bool | isIdentity () const |
bool | isScaleTranslate () const |
bool | isTranslate () const |
bool | rectStaysRect () const |
bool | preservesAxisAlignment () const |
float | operator[] (int index) const |
float | get (int index) const |
float | getScaleX () const |
float | getScaleY () const |
float | getSkewY () const |
float | getSkewX () const |
float | getTranslateX () const |
float | getTranslateY () const |
float | getPerspX () const |
float | getPerspY () const |
float & | operator[] (int index) |
void | set (int index, float value) |
void | setScaleX (float v) |
void | setScaleY (float v) |
void | setSkewY (float v) |
void | setSkewX (float v) |
void | setTranslateX (float v) |
void | setTranslateY (float v) |
void | setPerspX (float v) |
void | setPerspY (float v) |
void | setAll (float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float persp0, float persp1, float persp2) |
void | get9 (float buffer[9]) const |
void | set9 (const float buffer[9]) |
void | reset () |
void | setIdentity () |
void | setTranslate (float dx, float dy) |
void | setScale (float sx, float sy, float px, float py) |
void | setScale (float sx, float sy) |
void | setRotate (float degrees, float px, float py) |
void | setRotate (float degrees) |
void | setSinCos (float sinValue, float cosValue, float px, float py) |
void | setSinCos (float sinValue, float cosValue) |
void | setSkew (float kx, float ky, float px, float py) |
void | setSkew (float kx, float ky) |
void | setConcat (const Matrix &a, const Matrix &b) |
void | preTranslate (float dx, float dy) |
void | preScale (float sx, float sy, float px, float py) |
void | preScale (float sx, float sy) |
void | preRotate (float degrees, float px, float py) |
void | preRotate (float degrees) |
void | preSkew (float kx, float ky, float px, float py) |
void | preSkew (float kx, float ky) |
void | preConcat (const Matrix &other) |
void | postTranslate (float dx, float dy) |
void | postScale (float sx, float sy, float px, float py) |
void | postScale (float sx, float sy) |
bool | postIDiv (int divx, int divy) |
void | postRotate (float degrees, float px, float py) |
void | postRotate (float degrees) |
void | postSkew (float kx, float ky, float px, float py) |
void | postSkew (float kx, float ky) |
void | postConcat (const Matrix &other) |
bool | setRectToRect (const Rect &src, const Rect &dst, ScaleToFit stf) |
bool | setPolyToPoly (const Point src[], const Point dst[], int count) |
bool | invert (Matrix *inverse) const |
bool | asAffine (float affine[6]) const |
void | setAffine (const float affine[6]) |
void | mapPoints (Point dst[], const Point src[], int count) const |
void | mapPoints (Point pts[], int count) const |
void | mapXY (float x, float y, Point *result) const |
Point | mapXY (float x, float y) const |
bool | mapRect (Rect *dst, const Rect &src) const |
bool | mapRect (Rect *rect) const |
Rect | mapRect (const Rect &src) const |
void | mapRectScaleTranslate (Rect *dst, const Rect &src) const |
bool | cheapEqualTo (const Matrix &m) const |
void | dump () const |
float | getMinScale () const |
float | getMaxScale () const |
bool | getMinMaxScales (float scaleFactors[2]) const |
void | dirtyMatrixTypeCache () |
void | setScaleTranslate (float sx, float sy, float tx, float ty) |
静态 Public 成员函数 | |
static Matrix | MakeScale (float sx, float sy) |
static Matrix | MakeScale (float scale) |
static Matrix | MakeTrans (float dx, float dy) |
static Matrix | MakeAll (float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float pers0, float pers1, float pers2) |
static Matrix | MakeRectToRect (const Rect &src, const Rect &dst, ScaleToFit stf) |
static void | SetAffineIdentity (float affine[6]) |
static const Matrix & | I () |
static const Matrix & | InvalidMatrix () |
static Matrix | Concat (const Matrix &a, const Matrix &b) |
静态 Public 属性 | |
static constexpr int | kMScaleX = 0 |
horizontal scale factor 更多... | |
static constexpr int | kMSkewX = 1 |
horizontal skew factor 更多... | |
static constexpr int | kMTransX = 2 |
horizontal translation 更多... | |
static constexpr int | kMSkewY = 3 |
vertical skew factor 更多... | |
static constexpr int | kMScaleY = 4 |
vertical scale factor 更多... | |
static constexpr int | kMTransY = 5 |
vertical translation 更多... | |
static constexpr int | kMPersp0 = 6 |
input x perspective factor 更多... | |
static constexpr int | kMPersp1 = 7 |
input y perspective factor 更多... | |
static constexpr int | kMPersp2 = 8 |
perspective bias 更多... | |
static constexpr int | kAScaleX = 0 |
horizontal scale factor 更多... | |
static constexpr int | kASkewY = 1 |
vertical skew factor 更多... | |
static constexpr int | kASkewX = 2 |
horizontal skew factor 更多... | |
static constexpr int | kAScaleY = 3 |
vertical scale factor 更多... | |
static constexpr int | kATransX = 4 |
horizontal translation 更多... | |
static constexpr int | kATransY = 5 |
vertical translation 更多... | |
友元 | |
MNN_PUBLIC bool | operator== (const Matrix &a, const Matrix &b) |
MNN_PUBLIC bool | operator!= (const Matrix &a, const Matrix &b) |
Matrix holds a 3x3 matrix for transforming coordinates. This allows mapping Point and vectors with translation, scaling, skewing, rotation, and perspective.
Matrix elements are in row major order. Matrix does not have a constructor, so it must be explicitly initialized. setIdentity() initializes Matrix so it has no effect. setTranslate(), setScale(), setSkew(), setRotate(), set9 and setAll() initializes all Matrix elements with the corresponding mapping.
Matrix includes a hidden variable that classifies the type of matrix to improve performance. Matrix is not thread safe unless getType() is called first.
枚举值 | |
---|---|
kFill_ScaleToFit | scales in x and y to fill destination Rect |
kStart_ScaleToFit | scales and aligns to left and top |
kCenter_ScaleToFit | scales and aligns to center |
kEnd_ScaleToFit | scales and aligns to right and bottom |
|
inline |
bool MNN::CV::Matrix::asAffine | ( | float | affine[6] | ) | const |
|
inline |
Returns true if Matrix equals m, using an efficient comparison.
Returns false when the sign of zero values is the different; when one matrix has positive zero value and the other has negative zero value.
Returns true even when both Matrix contain NaN.
NaN never equals any value, including itself. To improve performance, NaN values are treated as bit patterns that are equal if their bit patterns are equal.
m | Matrix to compare |
Returns Matrix a multiplied by Matrix b.
Given:
| A B C | | J K L | a = | D E F |, b = | M N O | | G H I | | P Q R |
sets Matrix to:
| A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | a * b = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |
|
inline |
Sets internal cache to unknown state. Use to force update after repeated modifications to Matrix element reference returned by operator[](int index).
void MNN::CV::Matrix::dump | ( | ) | const |
|
inline |
Returns one matrix value. Asserts if index is out of range and SK_DEBUG is defined.
index | one of: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY, kMPersp0, kMPersp1, kMPersp2 |
|
inline |
Copies nine scalar values contained by Matrix into buffer, in member value ascending order: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY, kMPersp0, kMPersp1, kMPersp2.
buffer | storage for nine scalar values |
float MNN::CV::Matrix::getMaxScale | ( | ) | const |
bool MNN::CV::Matrix::getMinMaxScales | ( | float | scaleFactors[2] | ) | const |
Sets scaleFactors[0] to the minimum scaling factor, and scaleFactors[1] to the maximum scaling factor. Scaling factors are computed by decomposing the Matrix scaling and skewing elements.
Returns true if scaleFactors are found; otherwise, returns false and sets scaleFactors to undefined values.
scaleFactors | storage for minimum and maximum scale factors |
float MNN::CV::Matrix::getMinScale | ( | ) | const |
|
inline |
Returns factor scaling input x-axis relative to input y-axis.
|
inline |
Returns factor scaling input y-axis relative to input x-axis.
|
inline |
Returns scale factor multiplied by x-axis input, contributing to x-axis output. With mapPoints(), scales Point along the x-axis.
|
inline |
Returns scale factor multiplied by y-axis input, contributing to y-axis output. With mapPoints(), scales Point along the y-axis.
|
inline |
Returns scale factor multiplied by y-axis input, contributing to x-axis output. With mapPoints(), skews Point along the x-axis. Skewing both axes can rotate Point.
|
inline |
Returns scale factor multiplied by x-axis input, contributing to y-axis output. With mapPoints(), skews Point along the y-axis. Skewing both axes can rotate Point.
|
inline |
Returns translation contributing to x-axis output. With mapPoints(), moves Point along the x-axis.
|
inline |
Returns translation contributing to y-axis output. With mapPoints(), moves Point along the y-axis.
|
inline |
Returns a bit field describing the transformations the matrix may perform. The bit field is computed conservatively, so it may include false positives. For example, when kPerspective_Mask is set, all other bits are set.
|
static |
|
static |
|
inline |
Sets inverse to reciprocal matrix, returning true if Matrix can be inverted. Geometrically, if Matrix maps from source to destination, inverse Matrix maps from destination to source. If Matrix can not be inverted, inverse is unchanged.
inverse | storage for inverted Matrix; may be nullptr |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Sets Matrix to:
| scaleX skewX transX | | skewY scaleY transY | | pers0 pers1 pers2 |
scaleX | horizontal scale factor |
skewX | horizontal skew factor |
transX | horizontal translation |
skewY | vertical skew factor |
scaleY | vertical scale factor |
transY | vertical translation |
pers0 | input x-axis perspective factor |
pers1 | input y-axis perspective factor |
pers2 | perspective scale factor |
|
inlinestatic |
Returns Matrix set to scale and translate src Rect to dst Rect. stf selects whether mapping completely fills dst or preserves the aspect ratio, and how to align src within dst. Returns the identity Matrix if src is empty. If dst is empty, returns Matrix set to:
| 0 0 0 | | 0 0 0 | | 0 0 1 |
src | Rect to map from |
dst | Rect to map to |
stf | one of: kFill_ScaleToFit, kStart_ScaleToFit, kCenter_ScaleToFit, kEnd_ScaleToFit |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Maps src Point array of length count to dst Point array of equal or greater length. Point are mapped by multiplying each Point by Matrix. Given:
| A B C | | x | Matrix = | D E F |, pt = | y | | G H I | | 1 |
where
for (i = 0; i < count; ++i) { x = src[i].fX y = src[i].fY }
each dst Point is computed as:
|A B C| |x| Ax+By+C Dx+Ey+F Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- |G H I| |1| Gx+Hy+I Gx+Hy+I
src and dst may point to the same storage.
|
inline |
Maps pts Point array of length count in place. Point are mapped by multiplying each Point by Matrix. Given:
| A B C | | x | Matrix = | D E F |, pt = | y | | G H I | | 1 |
where
for (i = 0; i < count; ++i) { x = pts[i].fX y = pts[i].fY }
each resulting pts Point is computed as:
|A B C| |x| Ax+By+C Dx+Ey+F Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- |G H I| |1| Gx+Hy+I Gx+Hy+I
Sets dst to bounds of src corners mapped by Matrix. Returns true if mapped corners are dst corners.
Returned value is the same as calling rectStaysRect().
|
inline |
Sets rect to bounds of rect corners mapped by Matrix. Returns true if mapped corners are computed rect corners.
Returned value is the same as calling rectStaysRect().
rect | rectangle to map, and storage for bounds of mapped corners |
|
inline |
|
inline |
|
inline |
Returns one matrix value. Asserts if index is out of range and SK_DEBUG is defined.
index | one of: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY, kMPersp0, kMPersp1, kMPersp2 |
|
inline |
Returns writable Matrix value. Asserts if index is out of range and SK_DEBUG is defined. Clears internal cache anticipating that caller will change Matrix value.
Next call to read Matrix state may recompute cache; subsequent writes to Matrix value must be followed by dirtyMatrixTypeCache().
index | one of: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY, kMPersp0, kMPersp1, kMPersp2 |
void MNN::CV::Matrix::postConcat | ( | const Matrix & | other | ) |
Sets Matrix to Matrix other multiplied by Matrix. This can be thought of mapping by other after applying Matrix.
Given:
| J K L | | A B C | Matrix = | M N O |, other = | D E F | | P Q R | | G H I |
sets Matrix to:
| A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | other * Matrix = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |
other | Matrix on left side of multiply expression |
bool MNN::CV::Matrix::postIDiv | ( | int | divx, |
int | divy | ||
) |
Sets Matrix to Matrix constructed from scaling by (1/divx, 1/divy) about pivot point (px, py), multiplied by Matrix.
Returns false if either divx or divy is zero.
Given:
| J K L | | sx 0 0 | Matrix = | M N O |, I(divx, divy) = | 0 sy 0 | | P Q R | | 0 0 1 |
where
sx = 1 / divx sy = 1 / divy
sets Matrix to:
| sx 0 0 | | J K L | | sx*J sx*K sx*L | I(divx, divy) * Matrix = | 0 sy 0 | | M N O | = | sy*M sy*N sy*O | | 0 0 1 | | P Q R | | P Q R |
divx | integer divisor for inverse scale in x |
divy | integer divisor for inverse scale in y |
void MNN::CV::Matrix::postRotate | ( | float | degrees, |
float | px, | ||
float | py | ||
) |
Sets Matrix to Matrix constructed from rotating by degrees about pivot point (px, py), multiplied by Matrix. This can be thought of as rotating about a pivot point after applying Matrix.
Positive degrees rotates clockwise.
Given:
| J K L | | c -s dx | Matrix = | M N O |, R(degrees, px, py) = | s c dy | | P Q R | | 0 0 1 |
where
c = cos(degrees) s = sin(degrees) dx = s * py + (1 - c) * px dy = -s * px + (1 - c) * py
sets Matrix to:
|c -s dx| |J K L| |cJ-sM+dx*P cK-sN+dx*Q cL-sO+dx+R| R(degrees, px, py) * Matrix = |s c dy| |M N O| = |sJ+cM+dy*P sK+cN+dy*Q sL+cO+dy*R| |0 0 1| |P Q R| | P Q R|
degrees | angle of axes relative to upright axes |
px | pivot x |
py | pivot y |
void MNN::CV::Matrix::postRotate | ( | float | degrees | ) |
Sets Matrix to Matrix constructed from rotating by degrees about pivot point (0, 0), multiplied by Matrix. This can be thought of as rotating about the origin after applying Matrix.
Positive degrees rotates clockwise.
Given:
| J K L | | c -s 0 | Matrix = | M N O |, R(degrees, px, py) = | s c 0 | | P Q R | | 0 0 1 |
where
c = cos(degrees) s = sin(degrees)
sets Matrix to:
| c -s dx | | J K L | | cJ-sM cK-sN cL-sO | R(degrees, px, py) * Matrix = | s c dy | | M N O | = | sJ+cM sK+cN sL+cO | | 0 0 1 | | P Q R | | P Q R |
degrees | angle of axes relative to upright axes |
void MNN::CV::Matrix::postScale | ( | float | sx, |
float | sy, | ||
float | px, | ||
float | py | ||
) |
Sets Matrix to Matrix constructed from scaling by (sx, sy) about pivot point (px, py), multiplied by Matrix. This can be thought of as scaling about a pivot point after applying Matrix.
Given:
| J K L | | sx 0 dx | Matrix = | M N O |, S(sx, sy, px, py) = | 0 sy dy | | P Q R | | 0 0 1 |
where
dx = px - sx * px dy = py - sy * py
sets Matrix to:
| sx 0 dx | | J K L | | sx*J+dx*P sx*K+dx*Q sx*L+dx+R | S(sx, sy, px, py) * Matrix = | 0 sy dy | | M N O | = | sy*M+dy*P sy*N+dy*Q sy*O+dy*R | | 0 0 1 | | P Q R | | P Q R |
sx | horizontal scale factor |
sy | vertical scale factor |
px | pivot x |
py | pivot y |
void MNN::CV::Matrix::postScale | ( | float | sx, |
float | sy | ||
) |
Sets Matrix to Matrix constructed from scaling by (sx, sy) about pivot point (0, 0), multiplied by Matrix. This can be thought of as scaling about the origin after applying Matrix.
Given:
| J K L | | sx 0 0 | Matrix = | M N O |, S(sx, sy) = | 0 sy 0 | | P Q R | | 0 0 1 |
sets Matrix to:
| sx 0 0 | | J K L | | sx*J sx*K sx*L | S(sx, sy) * Matrix = | 0 sy 0 | | M N O | = | sy*M sy*N sy*O | | 0 0 1 | | P Q R | | P Q R |
sx | horizontal scale factor |
sy | vertical scale factor |
void MNN::CV::Matrix::postSkew | ( | float | kx, |
float | ky, | ||
float | px, | ||
float | py | ||
) |
Sets Matrix to Matrix constructed from skewing by (kx, ky) about pivot point (px, py), multiplied by Matrix. This can be thought of as skewing about a pivot point after applying Matrix.
Given:
| J K L | | 1 kx dx | Matrix = | M N O |, K(kx, ky, px, py) = | ky 1 dy | | P Q R | | 0 0 1 |
where
dx = -kx * py dy = -ky * px
sets Matrix to:
| 1 kx dx| |J K L| |J+kx*M+dx*P K+kx*N+dx*Q L+kx*O+dx+R| K(kx, ky, px, py) * Matrix = |ky 1 dy| |M N O| = |ky*J+M+dy*P ky*K+N+dy*Q ky*L+O+dy*R| | 0 0 1| |P Q R| | P Q R|
kx | horizontal skew factor |
ky | vertical skew factor |
px | pivot x |
py | pivot y |
void MNN::CV::Matrix::postSkew | ( | float | kx, |
float | ky | ||
) |
Sets Matrix to Matrix constructed from skewing by (kx, ky) about pivot point (0, 0), multiplied by Matrix. This can be thought of as skewing about the origin after applying Matrix.
Given:
| J K L | | 1 kx 0 | Matrix = | M N O |, K(kx, ky) = | ky 1 0 | | P Q R | | 0 0 1 |
sets Matrix to:
| 1 kx 0 | | J K L | | J+kx*M K+kx*N L+kx*O | K(kx, ky) * Matrix = | ky 1 0 | | M N O | = | ky*J+M ky*K+N ky*L+O | | 0 0 1 | | P Q R | | P Q R |
kx | horizontal skew factor |
ky | vertical skew factor |
void MNN::CV::Matrix::postTranslate | ( | float | dx, |
float | dy | ||
) |
Sets Matrix to Matrix constructed from translation (dx, dy) multiplied by Matrix. This can be thought of as moving the point to be mapped after applying Matrix.
Given:
| J K L | | 1 0 dx | Matrix = | M N O |, T(dx, dy) = | 0 1 dy | | P Q R | | 0 0 1 |
sets Matrix to:
| 1 0 dx | | J K L | | J+dx*P K+dx*Q L+dx*R | T(dx, dy) * Matrix = | 0 1 dy | | M N O | = | M+dy*P N+dy*Q O+dy*R | | 0 0 1 | | P Q R | | P Q R |
void MNN::CV::Matrix::preConcat | ( | const Matrix & | other | ) |
Sets Matrix to Matrix multiplied by Matrix other. This can be thought of mapping by other before applying Matrix.
Given:
| A B C | | J K L | Matrix = | D E F |, other = | M N O | | G H I | | P Q R |
sets Matrix to:
| A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | Matrix * other = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |
other | Matrix on right side of multiply expression |
void MNN::CV::Matrix::preRotate | ( | float | degrees, |
float | px, | ||
float | py | ||
) |
Sets Matrix to Matrix multiplied by Matrix constructed from rotating by degrees about pivot point (px, py). This can be thought of as rotating about a pivot point before applying Matrix.
Positive degrees rotates clockwise.
Given:
| A B C | | c -s dx | Matrix = | D E F |, R(degrees, px, py) = | s c dy | | G H I | | 0 0 1 |
where
c = cos(degrees) s = sin(degrees) dx = s * py + (1 - c) * px dy = -s * px + (1 - c) * py
sets Matrix to:
| A B C | | c -s dx | | Ac+Bs -As+Bc A*dx+B*dy+C | Matrix * R(degrees, px, py) = | D E F | | s c dy | = | Dc+Es -Ds+Ec D*dx+E*dy+F | | G H I | | 0 0 1 | | Gc+Hs -Gs+Hc G*dx+H*dy+I |
degrees | angle of axes relative to upright axes |
px | pivot x |
py | pivot y |
void MNN::CV::Matrix::preRotate | ( | float | degrees | ) |
Sets Matrix to Matrix multiplied by Matrix constructed from rotating by degrees about pivot point (0, 0). This can be thought of as rotating about the origin before applying Matrix.
Positive degrees rotates clockwise.
Given:
| A B C | | c -s 0 | Matrix = | D E F |, R(degrees, px, py) = | s c 0 | | G H I | | 0 0 1 |
where
c = cos(degrees) s = sin(degrees)
sets Matrix to:
| A B C | | c -s 0 | | Ac+Bs -As+Bc C | Matrix * R(degrees, px, py) = | D E F | | s c 0 | = | Dc+Es -Ds+Ec F | | G H I | | 0 0 1 | | Gc+Hs -Gs+Hc I |
degrees | angle of axes relative to upright axes |
void MNN::CV::Matrix::preScale | ( | float | sx, |
float | sy, | ||
float | px, | ||
float | py | ||
) |
Sets Matrix to Matrix multiplied by Matrix constructed from scaling by (sx, sy) about pivot point (px, py). This can be thought of as scaling about a pivot point before applying Matrix.
Given:
| A B C | | sx 0 dx | Matrix = | D E F |, S(sx, sy, px, py) = | 0 sy dy | | G H I | | 0 0 1 |
where
dx = px - sx * px dy = py - sy * py
sets Matrix to:
| A B C | | sx 0 dx | | A*sx B*sy A*dx+B*dy+C | Matrix * S(sx, sy, px, py) = | D E F | | 0 sy dy | = | D*sx E*sy D*dx+E*dy+F | | G H I | | 0 0 1 | | G*sx H*sy G*dx+H*dy+I |
sx | horizontal scale factor |
sy | vertical scale factor |
px | pivot x |
py | pivot y |
void MNN::CV::Matrix::preScale | ( | float | sx, |
float | sy | ||
) |
Sets Matrix to Matrix multiplied by Matrix constructed from scaling by (sx, sy) about pivot point (0, 0). This can be thought of as scaling about the origin before applying Matrix.
Given:
| A B C | | sx 0 0 | Matrix = | D E F |, S(sx, sy) = | 0 sy 0 | | G H I | | 0 0 1 |
sets Matrix to:
| A B C | | sx 0 0 | | A*sx B*sy C | Matrix * S(sx, sy) = | D E F | | 0 sy 0 | = | D*sx E*sy F | | G H I | | 0 0 1 | | G*sx H*sy I |
sx | horizontal scale factor |
sy | vertical scale factor |
|
inline |
Returns true Matrix maps Rect to another Rect. If true, Matrix is identity, or scales, or rotates a multiple of 90 degrees, or mirrors on axes. In all cases, Matrix may also have translation. Matrix form is either:
| scale-x 0 translate-x | | 0 scale-y translate-y | | 0 0 1 |
or
| 0 rotate-x translate-x | | rotate-y 0 translate-y | | 0 0 1 |
for non-zero values of scale-x, scale-y, rotate-x, and rotate-y.
Also called rectStaysRect(); use the one that provides better inline documentation.
void MNN::CV::Matrix::preSkew | ( | float | kx, |
float | ky, | ||
float | px, | ||
float | py | ||
) |
Sets Matrix to Matrix multiplied by Matrix constructed from skewing by (kx, ky) about pivot point (px, py). This can be thought of as skewing about a pivot point before applying Matrix.
Given:
| A B C | | 1 kx dx | Matrix = | D E F |, K(kx, ky, px, py) = | ky 1 dy | | G H I | | 0 0 1 |
where
dx = -kx * py dy = -ky * px
sets Matrix to:
| A B C | | 1 kx dx | | A+B*ky A*kx+B A*dx+B*dy+C | Matrix * K(kx, ky, px, py) = | D E F | | ky 1 dy | = | D+E*ky D*kx+E D*dx+E*dy+F | | G H I | | 0 0 1 | | G+H*ky G*kx+H G*dx+H*dy+I |
kx | horizontal skew factor |
ky | vertical skew factor |
px | pivot x |
py | pivot y |
void MNN::CV::Matrix::preSkew | ( | float | kx, |
float | ky | ||
) |
Sets Matrix to Matrix multiplied by Matrix constructed from skewing by (kx, ky) about pivot point (0, 0). This can be thought of as skewing about the origin before applying Matrix.
Given:
| A B C | | 1 kx 0 | Matrix = | D E F |, K(kx, ky) = | ky 1 0 | | G H I | | 0 0 1 |
sets Matrix to:
| A B C | | 1 kx 0 | | A+B*ky A*kx+B C | Matrix * K(kx, ky) = | D E F | | ky 1 0 | = | D+E*ky D*kx+E F | | G H I | | 0 0 1 | | G+H*ky G*kx+H I |
kx | horizontal skew factor |
ky | vertical skew factor |
void MNN::CV::Matrix::preTranslate | ( | float | dx, |
float | dy | ||
) |
Sets Matrix to Matrix multiplied by Matrix constructed from translation (dx, dy). This can be thought of as moving the point to be mapped before applying Matrix.
Given:
| A B C | | 1 0 dx | Matrix = | D E F |, T(dx, dy) = | 0 1 dy | | G H I | | 0 0 1 |
sets Matrix to:
| A B C | | 1 0 dx | | A B A*dx+B*dy+C | Matrix * T(dx, dy) = | D E F | | 0 1 dy | = | D E D*dx+E*dy+F | | G H I | | 0 0 1 | | G H G*dx+H*dy+I |
|
inline |
Returns true Matrix maps Rect to another Rect. If true, Matrix is identity, or scales, or rotates a multiple of 90 degrees, or mirrors on axes. In all cases, Matrix may also have translation. Matrix form is either:
| scale-x 0 translate-x | | 0 scale-y translate-y | | 0 0 1 |
or
| 0 rotate-x translate-x | | rotate-y 0 translate-y | | 0 0 1 |
for non-zero values of scale-x, scale-y, rotate-x, and rotate-y.
Also called preservesAxisAlignment(); use the one that provides better inline documentation.
void MNN::CV::Matrix::reset | ( | ) |
Sets Matrix to identity; which has no effect on mapped Point. Sets Matrix to:
| 1 0 0 | | 0 1 0 | | 0 0 1 |
Also called setIdentity(); use the one that provides better inline documentation.
|
inline |
void MNN::CV::Matrix::set9 | ( | const float | buffer[9] | ) |
Sets Matrix to nine scalar values in buffer, in member value ascending order: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY, kMPersp0, kMPersp1, kMPersp2.
Sets matrix to:
| buffer[0] buffer[1] buffer[2] | | buffer[3] buffer[4] buffer[5] | | buffer[6] buffer[7] buffer[8] |
In the future, set9 followed by get9 may not return the same values. Since Matrix maps non-homogeneous coordinates, scaling all nine values produces an equivalent transformation, possibly improving precision.
buffer | nine scalar values |
void MNN::CV::Matrix::setAffine | ( | const float | affine[6] | ) |
|
static |
Fills affine with identity values in column major order. Sets affine to:
| 1 0 0 | | 0 1 0 |
Affine 3x2 matrices in column major order are used by OpenGL and XPS.
affine | storage for 3x2 affine matrix |
|
inline |
Sets all values from parameters. Sets matrix to:
| scaleX skewX transX | | skewY scaleY transY | | persp0 persp1 persp2 |
scaleX | horizontal scale factor to store |
skewX | horizontal skew factor to store |
transX | horizontal translation to store |
skewY | vertical skew factor to store |
scaleY | vertical scale factor to store |
transY | vertical translation to store |
persp0 | input x-axis values perspective factor to store |
persp1 | input y-axis values perspective factor to store |
persp2 | perspective scale factor to store |
Sets Matrix to Matrix a multiplied by Matrix b. Either a or b may be this.
Given:
| A B C | | J K L | a = | D E F |, b = | M N O | | G H I | | P Q R |
sets Matrix to:
| A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | a * b = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |
|
inline |
|
inline |
Sets input x-axis perspective factor, which causes mapXY() to vary input x-axis values inversely proportional to input y-axis values.
v | perspective factor |
|
inline |
Sets input y-axis perspective factor, which causes mapXY() to vary input y-axis values inversely proportional to input x-axis values.
v | perspective factor |
Sets Matrix to map src to dst. count must be zero or greater, and four or less.
If count is zero, sets Matrix to identity and returns true. If count is one, sets Matrix to translate and returns true. If count is two or more, sets Matrix to map Point if possible; returns false if Matrix cannot be constructed. If count is four, Matrix may include perspective.
bool MNN::CV::Matrix::setRectToRect | ( | const Rect & | src, |
const Rect & | dst, | ||
ScaleToFit | stf | ||
) |
Sets Matrix to scale and translate src Rect to dst Rect. stf selects whether mapping completely fills dst or preserves the aspect ratio, and how to align src within dst. Returns false if src is empty, and sets Matrix to identity. Returns true if dst is empty, and sets Matrix to:
| 0 0 0 | | 0 0 0 | | 0 0 1 |
void MNN::CV::Matrix::setRotate | ( | float | degrees, |
float | px, | ||
float | py | ||
) |
void MNN::CV::Matrix::setRotate | ( | float | degrees | ) |
Sets Matrix to rotate by degrees about a pivot point at (0, 0). Positive degrees rotates clockwise.
degrees | angle of axes relative to upright axes |
void MNN::CV::Matrix::setScale | ( | float | sx, |
float | sy, | ||
float | px, | ||
float | py | ||
) |
void MNN::CV::Matrix::setScale | ( | float | sx, |
float | sy | ||
) |
Sets Matrix to scale by sx and sy about at pivot point at (0, 0).
sx | horizontal scale factor |
sy | vertical scale factor |
|
inline |
Initializes Matrix with scale and translate elements.
| sx 0 tx | | 0 sy ty | | 0 0 1 |
sx | horizontal scale factor to store |
sy | vertical scale factor to store |
tx | horizontal translation to store |
ty | vertical translation to store |
|
inline |
Sets horizontal scale factor.
v | horizontal scale factor to store |
|
inline |
Sets vertical scale factor.
v | vertical scale factor to store |
void MNN::CV::Matrix::setSinCos | ( | float | sinValue, |
float | cosValue, | ||
float | px, | ||
float | py | ||
) |
Sets Matrix to rotate by sinValue and cosValue, about a pivot point at (px, py). The pivot point is unchanged when mapped with Matrix.
Vector (sinValue, cosValue) describes the angle of rotation relative to (0, 1). Vector length specifies scale.
sinValue | rotation vector x-axis component |
cosValue | rotation vector y-axis component |
px | pivot x-axis |
py | pivot y-axis |
void MNN::CV::Matrix::setSinCos | ( | float | sinValue, |
float | cosValue | ||
) |
Sets Matrix to rotate by sinValue and cosValue, about a pivot point at (0, 0).
Vector (sinValue, cosValue) describes the angle of rotation relative to (0, 1). Vector length specifies scale.
sinValue | rotation vector x-axis component |
cosValue | rotation vector y-axis component |
void MNN::CV::Matrix::setSkew | ( | float | kx, |
float | ky, | ||
float | px, | ||
float | py | ||
) |
void MNN::CV::Matrix::setSkew | ( | float | kx, |
float | ky | ||
) |
Sets Matrix to skew by kx and ky, about a pivot point at (0, 0).
kx | horizontal skew factor |
ky | vertical skew factor |
|
inline |
Sets horizontal skew factor.
v | horizontal skew factor to store |
|
inline |
Sets vertical skew factor.
v | vertical skew factor to store |
void MNN::CV::Matrix::setTranslate | ( | float | dx, |
float | dy | ||
) |
Sets Matrix to translate by (dx, dy).
dx | horizontal translation |
dy | vertical translation |
|
inline |
Sets horizontal translation.
v | horizontal translation to store |
|
inline |
Sets vertical translation.
v | vertical translation to store |
|
friend |
|
friend |
|
static |
horizontal scale factor
Affine arrays are in column major order to match the matrix used by PDF and XPS.
|
static |
vertical scale factor
|
static |
horizontal skew factor
|
static |
vertical skew factor
|
static |
horizontal translation
|
static |
vertical translation
|
static |
input x perspective factor
|
static |
input y perspective factor
|
static |
perspective bias
|
static |
|
static |
vertical scale factor
|
static |
horizontal skew factor
|
static |
vertical skew factor
|
static |
horizontal translation
|
static |
vertical translation