描述
简单的 c++ 向量及矩阵库,包含矩阵运算,向量运算,以及透视投影等特殊矩阵,直接拷贝 matrix.hpp 和 vector.hpp 文件即可。
API 结构
-
class vector2operator+():+operator-():-operator*(): 数乘negate():取负scale():缩放length():长度normalize():归一化(正规化)
-
class vector3operator+():+operator-():-operator*(): 数乘negate():取负scale():缩放length():长度normalize(): 归一化(正规化)dot():求点积cross(): 求叉积
-
class matrixoperator+():+operator-():-operator*():*multiply(): *identity():生成标准矩阵zero():生成 0 矩阵scale():生成缩放矩阵translate():生成平移矩阵rotationX():生成绕 x 轴旋转矩阵rotationY():生成绕 y 轴旋转矩阵rotationZ():生成绕 z 轴旋转矩阵transpose(): 矩阵转置lookAtLH():生成观察矩阵perspectiveFovLH():生成透视投影矩阵orthoLH(): 生成正交投影矩阵transform():矩阵变换transformCoordinates():矩阵齐次变换
文件结构
-
sourcesmatrix.hpp: 矩阵类,包含矩阵基本运算以及变换vector.hpp: 向量类,包含 Vector2 和 Vector3 两个向量以及其基本运算
-
testmatrix_test.cpp: 使用google test对matrix类的方法进行测试vector_test.cpp: 使用google test对vector2和vector3类进行测试