fun*_*ial 2 opengl haskell matrix linear-algebra
我最近gl_*Matrix自己使用了已弃用的处理矩阵.一切似乎都很好,除了旋转大约是应该的80倍.我可以切换到使用opengl的矩阵而不更改任何其他代码,并且旋转很好.完整的源代码在Github上.最相关的功能在这里:
calculateMatricesFromPlayer :: GameObject a -> WorldMatrices
calculateMatricesFromPlayer p@(Player{}) =
let Vec3 px py pz = playerPosition p
Vec3 rx ry _ = playerRotation p
-- Create projection matrix
projMat = gperspectiveMatrix 45 (800/600) 0.1 100
-- Create view matrix
rotatedMatX = grotationMatrix rx [-1, 0, 0]
rotatedMatXY = rotatedMatX * grotationMatrix ry [0, -1, 0]
translatedMat = gtranslationMatrix [-px, -py, -pz]
viewMat = rotatedMatXY * translatedMat
-- Model matrix is identity by default
modelMat = gidentityMatrix
in WorldMatrices modelMat viewMat projMat
Run Code Online (Sandbox Code Playgroud)
有什么明显的我做错了吗?
由于圆圈中存在360度数和2*pi弧度,pi大约为3,因此大约80,因此使用度数作为输入sin,cos或者tan将输入作为弧度的函数,很可能出现大约80的因子360/(2*pi).