rotate to focus on objects

Post: #1
Hi All,
With the great help of you I have managed to select objects in the 3d enviroment. I would like to rotate the whole thing into a position where the selected object is rotated to the nearest position to the viewer (would be in the middle of the screen). The problem is that the idea I used seems to be not working. Better say it works, but do not serves the expected values. Somebody may help me to find the bug in the idea?

Thanks a lot!

This is the code where I try to calculate the needed rotations: (X,Y,Z are the coordinates of the object I would like to rotate to get into "focus")
atan2 gives back tha arc tangent of y/x; the multiplication with 57,... is the conversion from radian to degrees. The additions in the begining is not sure that correct of course.

this would be the code where make the rotation:
glTranslated(0, 0, -200); #to move the screen a little bit farer to see everything

glRotated($room_rotY, 0, 1, 0);
glRotated($room_rotX, 1, 0, 0);
glRotated($room_rotZ, 0, 0, 1);

glCallList($objects); #to draw the objects on the window
Quote this message in a reply
Posts: 17
Joined: 2006.02
Post: #2
ThemsAllTook has a good tutorial on rotations in 3D space:
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cube auto-rotate sakrist 2 3,357 May 5, 2009 03:31 AM
Last Post: Ingemar
  How does one rotate a scanned image in openGL? WhatMeWorry 16 9,532 Feb 2, 2005 09:25 PM
Last Post: arekkusu
  Focus on SDL Nick 13 6,118 Jul 22, 2004 07:30 PM
Last Post: Nick
  Best way to rotate an object Jake 12 4,884 Jul 30, 2003 01:09 PM
Last Post: Jake
  Move and Rotate camera SummerLand 2 3,543 Nov 25, 2002 10:53 PM
Last Post: Feanor