Rotation is scaling down the cube

Started by
1 comment, last by gonssas 17 years, 3 months ago
Hello, I am trying to rotate a cube but the rotation is scaling down the cube. Here is the function that rotates:

void rotate_x ( Object *obj, float angle ) {
     
     int i;
     int j;
          
     for ( i=0; i<(*obj).num_points; i++ ) {
         
         (*obj).points.x = (*obj).points.x;

         (*obj).points.y = (*obj).points.y * cos(angle) - (*obj).points.z * sin(angle);

         (*obj).points.z = (*obj).points.y * sin(angle) +  (*obj).points.z * cos(angle));

    }

}

The value for the angle is 0.7. Thanks for your comments.
Advertisement
void rotate_x ( Object *obj, float angle ) {          int i;     int j;               for ( i=0; i<(*obj).num_points; i++ ) {          float y = (*obj).points.y * cos(angle) - (*obj).points.z * sin(angle);         (*obj).points.z = (*obj).points.y * sin(angle) +  (*obj).points.z * cos(angle));         (*obj).points.y = y;    }}
As is, you're overwriting values that are still needed to perform the rotation.
Fixed.

Thanks for your comment.

This topic is closed to new replies.

Advertisement