我想在我的光线跟踪项目中使用Armadillo库进行计算。我在某处读到,我可以使用自己的矢量类将其传递给Armadillo,使用模板编程,但我找不到更多的信息。我想这样做,因为我想省略使用表运算符。
我想像GLM一样使用Armadillo
arma::vec3 orig;
orig.x = 12.f;
orig.y = 13.f;GLM中的位置:
glm::ivec3 vec;
vec.x = ...;
vec.y = ...;我考虑的是宏,但这不是一个优雅的解决方案。另外,我还必须使用armadillo,所以建议使用GLM falls
发布于 2019-04-19 18:09:50
我之前忘了添加答案:我复制重载操作符[]并将其更改为以下形式(Col_meat.hpp文件),并对y、z、w执行相同的操作(当然是更改索引)
template<typename eT>
template<uword fixed_n_elem>
arma_inline
arma_warn_unused
eT&
Col<eT>::fixed<fixed_n_elem>::x(void)
{
arma_debug_check((0 >= fixed_n_elem), "Col::x(): index out of bounds");
return (use_extra) ? mem_local_extra[0] : Mat<eT>::mem_local[0];
}
template<typename eT>
template<uword fixed_n_elem>
arma_inline
arma_warn_unused
const eT&
Col<eT>::fixed<fixed_n_elem>::x(void) const
{
arma_debug_check((0 >= fixed_n_elem), "Col::x(): index out of bounds");
return (use_extra) ? mem_local_extra[0] : Mat<eT>::mem_local[0];
}https://stackoverflow.com/questions/55445163
复制相似问题