Gan_Vector3 v3x;From now on, we shall describe the functions for double precision vectors only. Single precision functions are very similar and will be explained below. Setting the coordinates of a 3-vector can be achieved by one of
Gan_Vector3 v3x = {1.0, 2.0, 3.0};
v3x.x = 1.0; v3x.y = 2.0; v3x.z = 3.0;
gan_vec3_fill_q ( &v3x, 1.0, 2.0, 3.0 );Note that the Gnu C compiler prints a warning when the above call is compiled, and also for most other similar calls in the linear algebra package. This warning can be avoided by inserting an initial (void) cast:
(void)gan_vec3_fill_q ( &v3x, 1.0, 2.0, 3.0 );We omit this cast in the following to keep the exposition simple.
v3x = gan_vec3_fill_s ( 1.0, 2.0, 3.0 );
gan_vec3_zero_q ( &v3x ); /* macro, OR */ v3x = gan_vec3_zero_s(); /* function call */
Copying 3-vectors can be accomplished either by direct assignment
Gan_Vector3 v3y; v3y = v3x;or by use of the one of the routines
gan_vec3_copy_q ( &v3x, &v3y ); /* macro, OR */ v3y = gan_vec3_copy_s ( &v3x ); /* function call */