GetXAngle (also GetYAngle, GetZAngle)

This command gives the angle the object is making with the x, y, or z axes. Its syntax is

 xangle = object.GetXAngle(); 

where xangle is the angle of object with the x-axis. If the angle with the y or z axes are desired, then use the GetYAngle or GetZAngle commands.


You must be careful if you are rotating your 3D object about more than one axis because the GetXAngle command can return confusing values as a result. For example, if you are trying to keep track of an object s angle with the horizon, but you are also rotating your object about one or more of the other axes, then the angle with the horizon will be distorted . In these cases, it is best to keep track of the horizon angle using your own code in which you keep track of any radians added to your object s orientation. See the flight simulator programs in Chapter 4 for an example of this.

Sample Code

 oworld = New World(); ocamera = New Camera(oworld); sphere = oworld.CreateSphere(50,50,50,25,25); ocamera.MoveBack(1200); ocamera.Walk(); sphere.AddAngle(1,0,0,5); //Rotate it 1 radian in 5 seconds. //Loop While(1) {  SetText(sphere.GetXAngle()); } 

Elementary Game Programming and Simulators Using Jamagic
Elementary Game Programming & Simulations Using Jamagic (Charles River Media Game Development)
ISBN: 1584502614
EAN: 2147483647
Year: 2002
Pages: 105
Authors: Sergio Perez © 2008-2017.
If you may any questions please contact us: