bool CDLTransform::equals(const ConstCDLTransformRcPtr & other) const { if(!other) return false; if(getImpl()->dir_ != other->getImpl()->dir_) return false; const float abserror = 1e-9f; for(int i=0; i<9; ++i) { if(!equalWithAbsError(getImpl()->sop_[i], other->getImpl()->sop_[i], abserror)) { return false; } } if(!equalWithAbsError(getImpl()->sat_, other->getImpl()->sat_, abserror)) { return false; } if(getImpl()->id_ != other->getImpl()->id_) { return false; } if(getImpl()->description_ != other->getImpl()->description_) { return false; } return true; }
bool IsM44Diagonal(const float* m44) { for(int i=0; i<16; ++i) { if((i%5)==0) continue; if(!equalWithAbsError(0.0, m44[i], FLTMIN)) return false; } return true; }
bool MatrixTransform::equals(const MatrixTransform & other) const { const float abserror = 1e-9f; for(int i=0; i<16; ++i) { if(!equalWithAbsError(getImpl()->matrix_[i], other.getImpl()->matrix_[i], abserror)) { return false; } } for(int i=0; i<4; ++i) { if(!equalWithAbsError(getImpl()->offset_[i], other.getImpl()->offset_[i], abserror)) { return false; } } return true; }
bool GetM44Inverse(float* inverse_out, const float* m) { float d10_21 = m[4]*m[9] - m[5]*m[8]; float d10_22 = m[4]*m[10] - m[6]*m[8]; float d10_23 = m[4]*m[11] - m[7]*m[8]; float d11_22 = m[5]*m[10] - m[6]*m[9]; float d11_23 = m[5]*m[11] - m[7]*m[9]; float d12_23 = m[6]*m[11] - m[7]*m[10]; float a00 = m[13]*d12_23 - m[14]*d11_23 + m[15]*d11_22; float a10 = m[14]*d10_23 - m[15]*d10_22 - m[12]*d12_23; float a20 = m[12]*d11_23 - m[13]*d10_23 + m[15]*d10_21; float a30 = m[13]*d10_22 - m[14]*d10_21 - m[12]*d11_22; float det = a00*m[0] + a10*m[1] + a20*m[2] + a30*m[3]; if(equalWithAbsError(0.0, det, FLTMIN)) return false; det = 1.0f/det; float d00_31 = m[0]*m[13] - m[1]*m[12]; float d00_32 = m[0]*m[14] - m[2]*m[12]; float d00_33 = m[0]*m[15] - m[3]*m[12]; float d01_32 = m[1]*m[14] - m[2]*m[13]; float d01_33 = m[1]*m[15] - m[3]*m[13]; float d02_33 = m[2]*m[15] - m[3]*m[14]; float a01 = m[9]*d02_33 - m[10]*d01_33 + m[11]*d01_32; float a11 = m[10]*d00_33 - m[11]*d00_32 - m[8]*d02_33; float a21 = m[8]*d01_33 - m[9]*d00_33 + m[11]*d00_31; float a31 = m[9]*d00_32 - m[10]*d00_31 - m[8]*d01_32; float a02 = m[6]*d01_33 - m[7]*d01_32 - m[5]*d02_33; float a12 = m[4]*d02_33 - m[6]*d00_33 + m[7]*d00_32; float a22 = m[5]*d00_33 - m[7]*d00_31 - m[4]*d01_33; float a32 = m[4]*d01_32 - m[5]*d00_32 + m[6]*d00_31; float a03 = m[2]*d11_23 - m[3]*d11_22 - m[1]*d12_23; float a13 = m[0]*d12_23 - m[2]*d10_23 + m[3]*d10_22; float a23 = m[1]*d10_23 - m[3]*d10_21 - m[0]*d11_23; float a33 = m[0]*d11_22 - m[1]*d10_22 + m[2]*d10_21; inverse_out[0] = a00*det; inverse_out[1] = a01*det; inverse_out[2] = a02*det; inverse_out[3] = a03*det; inverse_out[4] = a10*det; inverse_out[5] = a11*det; inverse_out[6] = a12*det; inverse_out[7] = a13*det; inverse_out[8] = a20*det; inverse_out[9] = a21*det; inverse_out[10] = a22*det; inverse_out[11] = a23*det; inverse_out[12] = a30*det; inverse_out[13] = a31*det; inverse_out[14] = a32*det; inverse_out[15] = a33*det; return true; }