我一直在試圖分析蘋果公園(增強現實示例應用程序),我碰到下面的函數哪裏傳來,投影矩陣的用途是什麼?
方法調用與以下參數:
createProjectionMatrix(projectionTransform, 60.0f*DEGREES_TO_RADIANS, self.bounds.size.width*1.0f/self.bounds.size.height, 0.25f, 1000.0f);
void createProjectionMatrix(mat4f_t mout, float fovy, float aspect, float zNear, float zFar)
{
float f = 1.0f/tanf(fovy/2.0f);
mout[0] = f/aspect;
mout[1] = 0.0f;
mout[2] = 0.0f;
mout[3] = 0.0f;
mout[4] = 0.0f;
mout[5] = f;
mout[6] = 0.0f;
mout[7] = 0.0f;
mout[8] = 0.0f;
mout[9] = 0.0f;
mout[10] = (zFar+zNear)/(zNear-zFar);
mout[11] = -1.0f;
mout[12] = 0.0f;
mout[13] = 0.0f;
mout[14] = 2 * zFar * zNear/(zNear-zFar);
mout[15] = 0.0f;
}
我看到這個projection matrix
乘以rotation matrix
(通過motionManager.deviceMotion API獲得)。 投影矩陣的用途是什麼?爲什麼它應該與旋轉矩陣相乘?
multiplyMatrixAndMatrix(projectionCameraTransform, projectionTransform, cameraTransform);
爲什麼合成矩陣必須再乘以PointOfInterest向量座標?
multiplyMatrixAndVector(v, projectionCameraTransform, placesOfInterestCoordinates[i]);
欣賞這裏的任何幫助。
示例代碼link here