Cogl 2.0 Reference Manual | ||||
---|---|---|---|---|
Top | Description |
CoglEuler; void cogl_euler_init (CoglEuler *euler
,float heading
,float pitch
,float roll
); void cogl_euler_init_from_matrix (CoglEuler *euler
,const CoglMatrix *matrix
); void cogl_euler_init_from_quaternion (CoglEuler *euler
,const CoglQuaternion *quaternion
); CoglBool cogl_euler_equal (const void *v1
,const void *v2
); CoglEuler * cogl_euler_copy (const CoglEuler *src
); void cogl_euler_free (CoglEuler *euler
);
Euler angles are a simple representation of a 3 dimensional rotation; comprised of 3 ordered heading, pitch and roll rotations. An important thing to understand is that the axis of rotation belong to the object being rotated and so they also rotate as each of the heading, pitch and roll rotations are applied.
One way to consider euler angles is to imagine controlling an aeroplane, where you first choose a heading (Such as flying south east), then you set the pitch (such as 30 degrees to take off) and then you might set a roll, by dipping the left, wing as you prepare to turn.
They have some advantages and limitations that it helps to be aware of:
Advantages:
Disadvantages:
To minimize the aliasing issue we may refer to "Canonical Euler" angles where heading and roll are restricted to +- 180° and pitch is restricted to +- 90°. If pitch is +- 90° bank is set to 0°.
Quaternions don't suffer from Gimbal Lock and they can be nicely interpolated between, their disadvantage is that they don't have an intuitive representation.
A common practice is to accept angles in the intuitive Euler form
and convert them to quaternions internally to avoid Gimbal Lock and
handle interpolations. See cogl_quaternion_init_from_euler()
.
typedef struct { float heading; float pitch; float roll; } CoglEuler;
Represents an ordered rotation first of heading
degrees around an
object's y axis, then pitch
degrees around an object's x axis and
finally roll
degrees around an object's z axis.
The members of a CoglEuler can be initialized, for example, with
cogl_euler_init()
and cogl_euler_init_from_quaternion()
.
You may also want to look at cogl_quaternion_init_from_euler()
if
you want to do interpolation between 3d rotations.
Angle to rotate around an object's y axis | |
Angle to rotate around an object's x axis | |
Angle to rotate around an object's z axis |
Since 2.0
void cogl_euler_init (CoglEuler *euler
,float heading
,float pitch
,float roll
);
Initializes euler
to represent a rotation of x_angle
degrees
around the x axis, then y_angle
degrees around the y_axis and
z_angle
degrees around the z axis.
|
The CoglEuler angle to initialize |
|
Angle to rotate around an object's y axis |
|
Angle to rotate around an object's x axis |
|
Angle to rotate around an object's z axis |
Since 2.0
void cogl_euler_init_from_matrix (CoglEuler *euler
,const CoglMatrix *matrix
);
Extracts a euler rotation from the given matrix
and
initializses euler
with the component x, y and z rotation angles.
|
The CoglEuler angle to initialize |
|
A CoglMatrix containing a rotation, but no scaling, mirroring or skewing. |
void cogl_euler_init_from_quaternion (CoglEuler *euler
,const CoglQuaternion *quaternion
);
Initializes a euler
rotation with the equivalent rotation
represented by the given quaternion
.
CoglBool cogl_euler_equal (const void *v1
,const void *v2
);
Compares the two given euler angles v1
and v1
and it they are
equal returns TRUE
else FALSE
.
|
The first euler angle to compare |
|
The second euler angle to compare |
Returns : |
TRUE if v1 and v2 are equal else FALSE . |
Since 2.0
CoglEuler * cogl_euler_copy (const CoglEuler *src
);
Allocates a new CoglEuler and initilizes it with the component
angles of src
. The newly allocated euler should be freed using
cogl_euler_free()
.
Since 2.0
void cogl_euler_free (CoglEuler *euler
);
Frees a CoglEuler that was previously allocated using
cogl_euler_copy()
.
|
A CoglEuler allocated via cogl_euler_copy()
|
Since 2.0