glm::dot() 没有 return float/double 值吗?
glm::dot() doesn't return float/double value?
我正在尝试使用 glm::dot
来计算两个 glm::dvec3
的点积
但是,我的编译器 returns 当我尝试执行此操作时出现此错误
#include <glm/glm.hpp>
int main(int argc, char* argv[]){
glm::dvec3 a = glm::dvec3(1f, 2f, 3f);
glm::dvec3 b = glm::dvec3(4f, 5f, 6f);
float weight = glm::dot(a, b)
}
错误:当我为 glm::dot
的结果分配权重时,在最后一行出现 Type 'double' and 'glm::dvec3' are not compatible
我正在使用(clion、cygwin、gcc)和 glm 0.9.8 和 c++ 11
编辑: 添加更详细的错误位置和代码上下文
也许有更好的解决方案,但这对我有用
glm::vec3 a;
glm::vec3 b;
glm::dot<3, float, glm::qualifier::highp>(a, b);
因为 GLM 有两种方法点
template<typename T>
GLM_FUNC_QUALIFIER T dot(T x, T y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return x * y;
}
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return detail::compute_dot<vec<L, T, Q>, T, detail::is_aligned<Q>::value>::call(x, y);
}
编译器假定 T 是 vec3,因此使用第一种方法
看看这个post:
In this specific case where the generic type T is used as a parameter
for GetMax the compiler can find out automatically which data type has
to instantiate without having to explicitly specify it within angle
brackets (like we have done before specifying and ). So we
could have written instead: int i,j; GetMax (i,j);
希望对您有所帮助
我正在尝试使用 glm::dot
来计算两个 glm::dvec3
但是,我的编译器 returns 当我尝试执行此操作时出现此错误
#include <glm/glm.hpp>
int main(int argc, char* argv[]){
glm::dvec3 a = glm::dvec3(1f, 2f, 3f);
glm::dvec3 b = glm::dvec3(4f, 5f, 6f);
float weight = glm::dot(a, b)
}
错误:当我为 glm::dot
的结果分配权重时,在最后一行出现Type 'double' and 'glm::dvec3' are not compatible
我正在使用(clion、cygwin、gcc)和 glm 0.9.8 和 c++ 11
编辑: 添加更详细的错误位置和代码上下文
也许有更好的解决方案,但这对我有用
glm::vec3 a;
glm::vec3 b;
glm::dot<3, float, glm::qualifier::highp>(a, b);
因为 GLM 有两种方法点
template<typename T>
GLM_FUNC_QUALIFIER T dot(T x, T y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return x * y;
}
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return detail::compute_dot<vec<L, T, Q>, T, detail::is_aligned<Q>::value>::call(x, y);
}
编译器假定 T 是 vec3,因此使用第一种方法
看看这个post:
In this specific case where the generic type T is used as a parameter for GetMax the compiler can find out automatically which data type has to instantiate without having to explicitly specify it within angle brackets (like we have done before specifying and ). So we could have written instead: int i,j; GetMax (i,j);
希望对您有所帮助