I'm creating a collision detection system in C++ using the glm
library.
I have an array of vertices defined as std::vector<glm::vec3> vertices
and a function to calculate the maxX, y, z defined as
GLfloat AssetInstance::maxX()
{
GLfloat max = vertices.at(0).x;
for(glm::vec3 vertex : vertices)
if(vertex.x > max) max = vertex.x;
return max;
}
but if I run the following code:
std::vector<glm::vec3> testVector;
testVector.push_back(glm::vec3(3.0500346, 1.0, 1.0));
testVector.push_back(glm::vec3(3.0500344, 2.0, 2.0));
testVector.push_back(glm::vec3(3.0500343, 3.0, 3.0));
std::cout << maxX(testVector) << std::endl;
the output is 3.05003
I thought that glm::vec3
was double
and that double
was more precise than that?
Is there a better way to do this? My maxX isn't returning precise enough results.