Gan_Vector3 v3x; Gan_Vector4 v4x; gan_vec4_fill_q ( &v4x, 1.0, 2.0, 3.0, 4.0 ); gan_vec4_get_v3t_q ( &v4x, &v3x ); /* macro */or alternatively
v3x = gan_vec4_get_v3t_s ( &v4x ); /* function */both of which set v3x to {1.0, 2.0, 3.0}. To build a 4-vector from a 3-vector and a scalar use
gan_vec3_fill_q ( &v3x, 1.0, 2.0, 3.0 ); gan_vec4_set_parts_q ( &v4x, &v3x, 4.0 ); /* macro */or alternatively
v4x = gan_vec4_set_parts_s ( &v3x, 4.0 ); /* function */both of which set v4x to {1.0, 2.0, 3.0, 4.0}. To build a 4-vector from two 2-vectors use
Gan_Vector3 v2xt, v2xb; Gan_Vector4 v4x; gan_vec2_fill_q ( &v2xt, 1.0, 2.0 ); gan_vec2_fill_q ( &v2xb, 3.0, 4.0 ); gan_vec4_set_blocks_q ( &v4x, &v2xt, &v2xb ); /* macro */(note that the ``t'' and ``b'' in v2xt and v2xb stand for the ``top'' and ``bottom'' parts of vector ), or alternatively
v4x = gan_vec4_set_blocks_s ( &v2xt, &v2xb ); /* function */both of which again set v4x to {1.0, 2.0, 3.0, 4.0}.
For 3-vectors the equivalent set of functions involves splitting the 3-vector into the x,y coordinates as a 2-vector and z as the scalar. Then we have
Gan_Vector2 v2xt; Gan_Vector3 v3x; gan_vec3_fill_q ( &v3x, 1.0, 2.0, 3.0 ); gan_vec3_get_v2t_q ( &v3x, &v2xt ); /* macro, or */ v2xt = gan_vec3_get_v2t_s ( &v3x ); /* function */the last two lines of which both set v2xt to {1.0, 2.0}. To build a 3-vector from a 2-vector and a scalar use
gan_vec2_fill_q ( &v2xt, 1.0, 2.0 ); gan_vec3_set_parts_q ( &v3x, &v2xt, 3.0 ); /* macro, or */ v3x = gan_vec3_set_parts_s ( &v2xt, 3.0 ); /* function */both of which set v3x to {1.0, 2.0, 3.0}.