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;
|
Matrix transform;
|
||||||
GLToClipTransform(&transform);
|
GLToClipTransform(&transform);
|
||||||
|
|
||||||
Matrix transformInv;
|
Matrix transformInv = transform.getInversed();
|
||||||
transform.invert(&transformInv);
|
|
||||||
|
|
||||||
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
|
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
|
||||||
float zClip = transform.m[14]/transform.m[15];
|
float zClip = transform.m[14]/transform.m[15];
|
||||||
|
|
|
@ -1452,7 +1452,7 @@ AffineTransform Node::getParentToNodeAffineTransform() const
|
||||||
const Matrix& Node::getParentToNodeTransform() const
|
const Matrix& Node::getParentToNodeTransform() const
|
||||||
{
|
{
|
||||||
if ( _inverseDirty ) {
|
if ( _inverseDirty ) {
|
||||||
_transform.invert(&_inverse);
|
_inverse = _transform.getInversed();
|
||||||
_inverseDirty = false;
|
_inverseDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1489,9 +1489,7 @@ AffineTransform Node::getWorldToNodeAffineTransform() const
|
||||||
|
|
||||||
Matrix Node::getWorldToNodeTransform() const
|
Matrix Node::getWorldToNodeTransform() const
|
||||||
{
|
{
|
||||||
Matrix result = getNodeToWorldTransform();
|
return getNodeToWorldTransform().getInversed();
|
||||||
result.invert();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -274,13 +274,13 @@ Matrix* kmMat4Identity(Matrix* pOut)
|
||||||
|
|
||||||
Matrix* kmMat4Inverse(Matrix* pOut, const Matrix* pM)
|
Matrix* kmMat4Inverse(Matrix* pOut, const Matrix* pM)
|
||||||
{
|
{
|
||||||
pM->invert(pOut);
|
*pOut = pM->getInversed();
|
||||||
return pOut;
|
return pOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix* kmMat4Transpose(Matrix* pOut, const Matrix* pIn)
|
Matrix* kmMat4Transpose(Matrix* pOut, const Matrix* pIn)
|
||||||
{
|
{
|
||||||
pIn->transpose(pOut);
|
*pOut = pIn->getTransposed();
|
||||||
return pOut;
|
return pOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -634,12 +634,14 @@ void Matrix::getBackVector(Vector3* dst) const
|
||||||
dst->z = m[10];
|
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 a0 = m[0] * m[5] - m[1] * m[4];
|
||||||
float a1 = m[0] * m[6] - m[2] * 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[14] = -m[12] * a3 + m[13] * a1 - m[14] * a0;
|
||||||
inverse.m[15] = m[8] * a3 - m[9] * a1 + m[10] * 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -724,14 +726,14 @@ void Matrix::multiply(const Matrix& m1, const Matrix& m2, Matrix* dst)
|
||||||
|
|
||||||
void Matrix::negate()
|
void Matrix::negate()
|
||||||
{
|
{
|
||||||
negate(this);
|
MathUtil::negateMatrix(m, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix::negate(Matrix* dst) const
|
Matrix Matrix::getNegated() const
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
Matrix mat(*this);
|
||||||
|
mat.negate();
|
||||||
MathUtil::negateMatrix(m, dst->m);
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix::rotate(const Quaternion& q)
|
void Matrix::rotate(const Quaternion& q)
|
||||||
|
@ -946,14 +948,14 @@ void Matrix::translate(const Vector3& t, Matrix* dst) const
|
||||||
|
|
||||||
void Matrix::transpose()
|
void Matrix::transpose()
|
||||||
{
|
{
|
||||||
transpose(this);
|
MathUtil::transposeMatrix(m, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix::transpose(Matrix* dst) const
|
Matrix Matrix::getTransposed() const
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
Matrix mat(*this);
|
||||||
|
mat.transpose();
|
||||||
MathUtil::transposeMatrix(m, dst->m);
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_MATH_END
|
NS_CC_MATH_END
|
||||||
|
|
|
@ -467,7 +467,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return true if the the matrix can be inverted, false otherwise.
|
* @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.
|
* 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.
|
* @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.
|
* Determines if this matrix is equal to the identity matrix.
|
||||||
|
@ -535,7 +535,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param dst A matrix to store the result in.
|
* @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
|
* Post-multiplies this matrix by the matrix corresponding to the
|
||||||
|
@ -856,7 +856,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param dst A matrix to store the result in.
|
* @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.
|
* Calculates the sum of this matrix with the given matrix.
|
||||||
|
|
Loading…
Reference in New Issue