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.
Rotation is scaling down the cube
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++ ) { 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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement