mirror of https://github.com/axmolengine/axmol.git
inverse and conjugate, negate for matrix
This commit is contained in:
parent
8fe4c472fd
commit
183dd1ec64
|
@ -739,8 +739,7 @@ Vector2 Director::convertToGL(const Vector2& uiPoint)
|
|||
Matrix transform;
|
||||
GLToClipTransform(&transform);
|
||||
|
||||
Matrix transformInv;
|
||||
transform.invert(&transformInv);
|
||||
Matrix transformInv = transform.getInversed();
|
||||
|
||||
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
|
||||
float zClip = transform.m[14]/transform.m[15];
|
||||
|
|
|
@ -1452,7 +1452,7 @@ AffineTransform Node::getParentToNodeAffineTransform() const
|
|||
const Matrix& Node::getParentToNodeTransform() const
|
||||
{
|
||||
if ( _inverseDirty ) {
|
||||
_transform.invert(&_inverse);
|
||||
_inverse = _transform.getInversed();
|
||||
_inverseDirty = false;
|
||||
}
|
||||
|
||||
|
@ -1489,9 +1489,7 @@ AffineTransform Node::getWorldToNodeAffineTransform() const
|
|||
|
||||
Matrix Node::getWorldToNodeTransform() const
|
||||
{
|
||||
Matrix result = getNodeToWorldTransform();
|
||||
result.invert();
|
||||
return result;
|
||||
return getNodeToWorldTransform().getInversed();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -274,13 +274,13 @@ Matrix* kmMat4Identity(Matrix* pOut)
|
|||
|
||||
Matrix* kmMat4Inverse(Matrix* pOut, const Matrix* pM)
|
||||
{
|
||||
pM->invert(pOut);
|
||||
*pOut = pM->getInversed();
|
||||
return pOut;
|
||||
}
|
||||
|
||||
Matrix* kmMat4Transpose(Matrix* pOut, const Matrix* pIn)
|
||||
{
|
||||
pIn->transpose(pOut);
|
||||
*pOut = pIn->getTransposed();
|
||||
return pOut;
|
||||
}
|
||||
|
||||
|
|
|
@ -634,12 +634,14 @@ void Matrix::getBackVector(Vector3* dst) const
|
|||
dst->z = m[10];
|
||||
}
|
||||
|
||||
bool Matrix::invert()
|
||||
Matrix Matrix::getInversed() const
|
||||
{
|
||||
return invert(this);
|
||||
Matrix mat(*this);
|
||||
mat.inverse();
|
||||
return mat;
|
||||
}
|
||||
|
||||
bool Matrix::invert(Matrix* dst) const
|
||||
bool Matrix::inverse()
|
||||
{
|
||||
float a0 = m[0] * m[5] - m[1] * m[4];
|
||||
float a1 = m[0] * m[6] - m[2] * m[4];
|
||||
|
@ -683,7 +685,7 @@ bool Matrix::invert(Matrix* dst) const
|
|||
inverse.m[14] = -m[12] * a3 + m[13] * a1 - m[14] * a0;
|
||||
inverse.m[15] = m[8] * a3 - m[9] * a1 + m[10] * a0;
|
||||
|
||||
multiply(inverse, 1.0f / det, dst);
|
||||
multiply(inverse, 1.0f / det, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -724,14 +726,14 @@ void Matrix::multiply(const Matrix& m1, const Matrix& m2, Matrix* dst)
|
|||
|
||||
void Matrix::negate()
|
||||
{
|
||||
negate(this);
|
||||
MathUtil::negateMatrix(m, m);
|
||||
}
|
||||
|
||||
void Matrix::negate(Matrix* dst) const
|
||||
Matrix Matrix::getNegated() const
|
||||
{
|
||||
GP_ASSERT(dst);
|
||||
|
||||
MathUtil::negateMatrix(m, dst->m);
|
||||
Matrix mat(*this);
|
||||
mat.negate();
|
||||
return mat;
|
||||
}
|
||||
|
||||
void Matrix::rotate(const Quaternion& q)
|
||||
|
@ -946,14 +948,14 @@ void Matrix::translate(const Vector3& t, Matrix* dst) const
|
|||
|
||||
void Matrix::transpose()
|
||||
{
|
||||
transpose(this);
|
||||
MathUtil::transposeMatrix(m, m);
|
||||
}
|
||||
|
||||
void Matrix::transpose(Matrix* dst) const
|
||||
Matrix Matrix::getTransposed() const
|
||||
{
|
||||
GP_ASSERT(dst);
|
||||
|
||||
MathUtil::transposeMatrix(m, dst->m);
|
||||
Matrix mat(*this);
|
||||
mat.transpose();
|
||||
return mat;
|
||||
}
|
||||
|
||||
NS_CC_MATH_END
|
||||
|
|
|
@ -467,7 +467,7 @@ public:
|
|||
*
|
||||
* @return true if the the matrix can be inverted, false otherwise.
|
||||
*/
|
||||
bool invert();
|
||||
bool inverse();
|
||||
|
||||
/**
|
||||
* Stores the inverse of this matrix in the specified matrix.
|
||||
|
@ -476,7 +476,7 @@ public:
|
|||
*
|
||||
* @return true if the the matrix can be inverted, false otherwise.
|
||||
*/
|
||||
bool invert(Matrix* dst) const;
|
||||
Matrix getInversed() const;
|
||||
|
||||
/**
|
||||
* Determines if this matrix is equal to the identity matrix.
|
||||
|
@ -535,7 +535,7 @@ public:
|
|||
*
|
||||
* @param dst A matrix to store the result in.
|
||||
*/
|
||||
void negate(Matrix* dst) const;
|
||||
Matrix getNegated() const;
|
||||
|
||||
/**
|
||||
* Post-multiplies this matrix by the matrix corresponding to the
|
||||
|
@ -856,7 +856,7 @@ public:
|
|||
*
|
||||
* @param dst A matrix to store the result in.
|
||||
*/
|
||||
void transpose(Matrix* dst) const;
|
||||
Matrix getTransposed() const;
|
||||
|
||||
/**
|
||||
* Calculates the sum of this matrix with the given matrix.
|
||||
|
|
Loading…
Reference in New Issue