在iOS/Swift中,MatrixHelper是什么模块的一部分?
问题描述:
我试图按照一些示例代码https://medium.com/@yatchoi/getting-started-with-arkit-real-life-waypoints-1707e3cb1da2下方,我越来越unresolved identifier 'MatrixHelper'
在iOS/Swift中,MatrixHelper是什么模块的一部分?
let translationMatrix = MatrixHelper.translate(
x: 0,
y: 0,
z: distance * -1
)
// Rotation matrix theta degrees
let rotationMatrix = MatrixHelper.rotateAboutY(
degrees: bearing * -1
)
什么库或包我需要导入得到MatrixHelper - 一些数学包?我搜索了文档,但找不到任何东西。
答
我想他只是写了一个自定义类来包装GLKit提供的功能。
他将该类命名为MatrixHelper。
随着MatrixHelper.rotateAboutY(),他在呼唤这样的:
GLKMatrix4 GLKMatrix4Rotate(GLKMatrix4 matrix, float radians, float x, float y, float z);
所以在MatrixHelper使用的包装是GLKit和更精确GLKMatrix4
https://developer.apple.com/documentation/glkit/glkmatrix4-pce
我建议反对使用GLKMatrix4或其他GLKMath类型,除非您与其他GLKit API交互 - Apple的新“SIMD”库('simd_float4x4'和相关类型)提供更好的性能,并且直接受ARKit,SceneKit和其他高级高层框架。 (有些矩阵数学方便的封装代码对于SIMD类型的使用会很好) – rickster
您说得对,感谢评论 – Retterdesdialogs
,那么我们如何使用SIMD实现rotateAboutY? – MonkeyBonkey