public void inverseTransform( final Number3D position, final Number3D scale, final Quaternion orientation) { Number3D invTranslate = position.inverse(); Number3D invScale = new Number3D(1 / scale.x, 1 / scale.y, 1 / scale.z); Quaternion invRot = orientation.inverse(); invTranslate = invRot.multiply(invTranslate); invTranslate.multiply(invScale); invRot.toRotationMatrix(mTmp); m[0] = invScale.x * mTmp[0]; m[1] = invScale.x * mTmp[1]; m[2] = invScale.x * mTmp[2]; m[3] = invTranslate.x; m[4] = invScale.y * mTmp[4]; m[5] = invScale.y * mTmp[5]; m[6] = invScale.y * mTmp[6]; m[7] = invTranslate.y; m[8] = invScale.z * mTmp[8]; m[9] = invScale.z * mTmp[9]; m[10] = invScale.z * mTmp[10]; m[11] = invTranslate.z; m[12] = 0; m[13] = 0; m[14] = 0; m[15] = 1; }
public Number3D multiply(final Number3D v) { Number3D r = new Number3D(); float inv = 1.0f / (m[12] * v.x + m[13] * v.y + m[14] * v.z + m[15]); r.x = (m[0] * v.x + m[1] * v.y + m[2] * v.z + m[3]) * inv; r.y = (m[4] * v.x + m[5] * v.y + m[6] * v.z + m[7]) * inv; r.z = (m[8] * v.x + m[8] * v.y + m[10] * v.z + m[11]) * inv; return r; }