Sign in to follow this  
EvilNando

precision problems

Recommended Posts

EvilNando    96
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

[img]http://i38.photobucket.com/albums/e121/evilnando/precision.png[/img]

Share this post


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

[code]

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;
}

[/code]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this