Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate vec4 cross product with glm?

Why this throws an compilation error: no matching function for call to ‘cross(glm::vec4&, glm::vec4&)’

glm::vec4 a;
glm::vec4 b;
glm::vec4 c = glm::cross(a, b);

but it works fine for vec3?

like image 529
Kimi Avatar asked Dec 15 '22 23:12

Kimi


1 Answers

There is no such thing as a 4D vector cross-product; the operation is only defined for 3D vectors. Well, technically, there is a seven-dimensional vector cross-product, but somehow I don't think you're looking for that.

Since 4D vector cross-products aren't mathematically reasonable, GLM doesn't offer a function to compute it.

like image 178
Nicol Bolas Avatar answered Jan 13 '23 10:01

Nicol Bolas