• Advertisement
Sign in to follow this  

precision problems

This topic is 2452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im using the GLM library for my matrix transformation needs..

doing a quick test by just rotating a quad 90 degrees I come up with the following results

precision.png

Share this post


Link to post
Share on other sites
Advertisement
oh code of course xD



glm::vec4 _vertices[] = { glm::vec4(-50.0f, -50.0f, 0.0f, 1.0f)
, glm::vec4(-50.0f, 50.0f, 0.0f, 1.0f)
, glm::vec4( 50.0f, 50.0f, 0.0f, 1.0f)
, glm::vec4( 50.0f, -50.0f, 0.0f, 1.0f) };

std::cout<<std::endl<<"Untransformed vertices"<<std::endl;

for (int _idx = 0; _idx < 4; _idx++)
{
std::cout<<"Vertex "<<_idx + 1<<" ";
std::cout<<"X: "<<_vertices[_idx].x<<" "
<<"Y: "<<_vertices[_idx].y<<" "
<<"Z: "<<_vertices[_idx].z<<std::endl;
}

glm::vec4 _translation_vector();
float _rotation = glm::radians(90.0f);

glm::mat4 _rotation_matrix = glm::rotate(glm::mat4(1.0f), _rotation, glm::vec3(0.0f, 0.0f, 1.0f));


for (int _idx = 0; _idx < 4; _idx++)
{
_vertices[_idx] = _rotation_matrix * _vertices[_idx];
}

std::cout<<std::endl<<"Transformed vertices"<<std::endl;

for (int _idx = 0; _idx < 4; _idx++)
{
std::cout<<"Vertex "<<_idx + 1<<" ";
std::cout<<"X: "<<std::setprecision(3)<<_vertices[_idx].x<<" "
<<"Y: "<<std::setprecision(3)<<_vertices[_idx].y<<" "
<<"Z: "<<std::setprecision(3)<<_vertices[_idx].z<<std::endl;
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement