mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
Remove CoglVector3 type and use float * instead
It proved to be inconvenient that we had a special CoglVector3 typedef for vectors instead of just accepting pointers to float arrays because you'd so often end up having to make awkward casts from another vector type into a CoglVector3 and then cast back again. We're hoping that taking float pointers instead will lead to less unnecessary casting.
This commit is contained in:
parent
2b351af46a
commit
e163f1ca1a
@ -2085,41 +2085,41 @@ cogl_matrix_look_at (CoglMatrix *matrix,
|
||||
float world_up_z)
|
||||
{
|
||||
CoglMatrix tmp;
|
||||
CoglVector3 forward;
|
||||
CoglVector3 side;
|
||||
CoglVector3 up;
|
||||
float forward[3];
|
||||
float side[3];
|
||||
float up[3];
|
||||
|
||||
/* Get a unit viewing direction vector */
|
||||
cogl_vector3_init (&forward,
|
||||
cogl_vector3_init (forward,
|
||||
object_x - eye_position_x,
|
||||
object_y - eye_position_y,
|
||||
object_z - eye_position_z);
|
||||
cogl_vector3_normalize (&forward);
|
||||
cogl_vector3_normalize (forward);
|
||||
|
||||
cogl_vector3_init (&up, world_up_x, world_up_y, world_up_z);
|
||||
cogl_vector3_init (up, world_up_x, world_up_y, world_up_z);
|
||||
|
||||
/* Take the sideways direction as being perpendicular to the viewing
|
||||
* direction and the word up vector. */
|
||||
cogl_vector3_cross_product (&side, &forward, &up);
|
||||
cogl_vector3_normalize (&side);
|
||||
cogl_vector3_cross_product (side, forward, up);
|
||||
cogl_vector3_normalize (side);
|
||||
|
||||
/* Now we have unit sideways and forward-direction vectors calculate
|
||||
* a new mutually perpendicular up vector. */
|
||||
cogl_vector3_cross_product (&up, &side, &forward);
|
||||
cogl_vector3_cross_product (up, side, forward);
|
||||
|
||||
tmp.xx = side.x;
|
||||
tmp.yx = side.y;
|
||||
tmp.zx = side.z;
|
||||
tmp.xx = side[0];
|
||||
tmp.yx = side[1];
|
||||
tmp.zx = side[2];
|
||||
tmp.wx = 0;
|
||||
|
||||
tmp.xy = up.x;
|
||||
tmp.yy = up.y;
|
||||
tmp.zy = up.z;
|
||||
tmp.xy = up[0];
|
||||
tmp.yy = up[1];
|
||||
tmp.zy = up[2];
|
||||
tmp.wy = 0;
|
||||
|
||||
tmp.xz = -forward.x;
|
||||
tmp.yz = -forward.y;
|
||||
tmp.zz = -forward.z;
|
||||
tmp.xz = -forward[0];
|
||||
tmp.yz = -forward[1];
|
||||
tmp.zz = -forward[2];
|
||||
tmp.wz = 0;
|
||||
|
||||
tmp.xw = 0;
|
||||
|
@ -74,36 +74,38 @@ cogl_quaternion_init (CoglQuaternion *quaternion,
|
||||
float y,
|
||||
float z)
|
||||
{
|
||||
CoglVector3 axis = { x, y, z};
|
||||
cogl_quaternion_init_from_angle_vector (quaternion, angle, &axis);
|
||||
float axis[3] = { x, y, z};
|
||||
cogl_quaternion_init_from_angle_vector (quaternion, angle, axis);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_quaternion_init_from_angle_vector (CoglQuaternion *quaternion,
|
||||
float angle,
|
||||
const CoglVector3 *axis_in)
|
||||
const float *axis3f_in)
|
||||
{
|
||||
/* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair
|
||||
* in this form:
|
||||
* [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )]
|
||||
*/
|
||||
CoglVector3 axis;
|
||||
float axis[3];
|
||||
float half_angle;
|
||||
float sin_half_angle;
|
||||
|
||||
/* XXX: Should we make cogl_vector3_normalize have separate in and
|
||||
* out args? */
|
||||
axis = *axis_in;
|
||||
cogl_vector3_normalize (&axis);
|
||||
axis[0] = axis3f_in[0];
|
||||
axis[1] = axis3f_in[1];
|
||||
axis[2] = axis3f_in[2];
|
||||
cogl_vector3_normalize (axis);
|
||||
|
||||
half_angle = angle * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f;
|
||||
sin_half_angle = sinf (half_angle);
|
||||
|
||||
quaternion->w = cosf (half_angle);
|
||||
|
||||
quaternion->x = axis.x * sin_half_angle;
|
||||
quaternion->y = axis.y * sin_half_angle;
|
||||
quaternion->z = axis.z * sin_half_angle;
|
||||
quaternion->x = axis[0] * sin_half_angle;
|
||||
quaternion->y = axis[1] * sin_half_angle;
|
||||
quaternion->z = axis[2] * sin_half_angle;
|
||||
|
||||
cogl_quaternion_normalize (quaternion);
|
||||
}
|
||||
@ -365,7 +367,7 @@ cogl_quaternion_get_rotation_angle (const CoglQuaternion *quaternion)
|
||||
|
||||
void
|
||||
cogl_quaternion_get_rotation_axis (const CoglQuaternion *quaternion,
|
||||
CoglVector3 *vector)
|
||||
float *vector3)
|
||||
{
|
||||
float sin_half_angle_sqr;
|
||||
float one_over_sin_angle_over_2;
|
||||
@ -383,18 +385,18 @@ cogl_quaternion_get_rotation_axis (const CoglQuaternion *quaternion,
|
||||
{
|
||||
/* Either an identity quaternion or numerical imprecision.
|
||||
* Either way we return an arbitrary vector. */
|
||||
vector->x = 1;
|
||||
vector->y = 0;
|
||||
vector->z = 0;
|
||||
vector3[0] = 1;
|
||||
vector3[1] = 0;
|
||||
vector3[2] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Calculate 1 / sin(𝜃/2) */
|
||||
one_over_sin_angle_over_2 = 1.0f / sqrtf (sin_half_angle_sqr);
|
||||
|
||||
vector->x = quaternion->x * one_over_sin_angle_over_2;
|
||||
vector->y = quaternion->y * one_over_sin_angle_over_2;
|
||||
vector->z = quaternion->z * one_over_sin_angle_over_2;
|
||||
vector3[0] = quaternion->x * one_over_sin_angle_over_2;
|
||||
vector3[1] = quaternion->y * one_over_sin_angle_over_2;
|
||||
vector3[2] = quaternion->z * one_over_sin_angle_over_2;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -164,7 +164,7 @@ cogl_quaternion_init (CoglQuaternion *quaternion,
|
||||
/**
|
||||
* cogl_quaternion_init_from_angle_vector:
|
||||
* @quaternion: An uninitialized #CoglQuaternion
|
||||
* @axis: your axis vector about which you want to rotate.
|
||||
* @axis: your 3 component axis vector about which you want to rotate.
|
||||
*
|
||||
* Initializes a quaternion that rotates @angle degrees around the
|
||||
* given @axis vector. The axis vector does not need to be
|
||||
@ -178,7 +178,7 @@ cogl_quaternion_init (CoglQuaternion *quaternion,
|
||||
void
|
||||
cogl_quaternion_init_from_angle_vector (CoglQuaternion *quaternion,
|
||||
float angle,
|
||||
const CoglVector3 *axis);
|
||||
const float *axis3f);
|
||||
|
||||
/**
|
||||
* cogl_quaternion_init_identity:
|
||||
@ -316,7 +316,7 @@ cogl_quaternion_get_rotation_angle (const CoglQuaternion *quaternion);
|
||||
*/
|
||||
void
|
||||
cogl_quaternion_get_rotation_axis (const CoglQuaternion *quaternion,
|
||||
CoglVector3 *vector);
|
||||
float *vector3);
|
||||
|
||||
/**
|
||||
* cogl_quaternion_normalize:
|
||||
|
@ -32,25 +32,30 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#define X 0
|
||||
#define Y 1
|
||||
#define Z 2
|
||||
#define W 3
|
||||
|
||||
void
|
||||
cogl_vector3_init (CoglVector3 *vector, float x, float y, float z)
|
||||
cogl_vector3_init (float *vector, float x, float y, float z)
|
||||
{
|
||||
vector->x = x;
|
||||
vector->y = y;
|
||||
vector->z = z;
|
||||
vector[X] = x;
|
||||
vector[Y] = y;
|
||||
vector[Z] = z;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_init_zero (CoglVector3 *vector)
|
||||
cogl_vector3_init_zero (float *vector)
|
||||
{
|
||||
memset (vector, 0, sizeof (CoglVector3));
|
||||
memset (vector, 0, sizeof (float) * 3);
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_vector3_equal (gconstpointer v1, gconstpointer v2)
|
||||
{
|
||||
CoglVector3 *vector0 = (CoglVector3 *)v1;
|
||||
CoglVector3 *vector1 = (CoglVector3 *)v2;
|
||||
float *vector0 = (float *)v1;
|
||||
float *vector1 = (float *)v2;
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE);
|
||||
_COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE);
|
||||
@ -59,160 +64,162 @@ cogl_vector3_equal (gconstpointer v1, gconstpointer v2)
|
||||
* for comparing the components so we just use == that will at least
|
||||
* consider -0 and 0 to be equal. */
|
||||
return
|
||||
vector0->x == vector1->x &&
|
||||
vector0->y == vector1->y &&
|
||||
vector0->z == vector1->z;
|
||||
vector0[X] == vector1[X] &&
|
||||
vector0[Y] == vector1[Y] &&
|
||||
vector0[Z] == vector1[Z];
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_vector3_equal_with_epsilon (const CoglVector3 *vector0,
|
||||
const CoglVector3 *vector1,
|
||||
cogl_vector3_equal_with_epsilon (const float *vector0,
|
||||
const float *vector1,
|
||||
float epsilon)
|
||||
{
|
||||
_COGL_RETURN_VAL_IF_FAIL (vector0 != NULL, FALSE);
|
||||
_COGL_RETURN_VAL_IF_FAIL (vector1 != NULL, FALSE);
|
||||
|
||||
if (fabsf (vector0->x - vector1->x) < epsilon &&
|
||||
fabsf (vector0->y - vector1->y) < epsilon &&
|
||||
fabsf (vector0->z - vector1->z) < epsilon)
|
||||
if (fabsf (vector0[X] - vector1[X]) < epsilon &&
|
||||
fabsf (vector0[Y] - vector1[Y]) < epsilon &&
|
||||
fabsf (vector0[Z] - vector1[Z]) < epsilon)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CoglVector3 *
|
||||
cogl_vector3_copy (const CoglVector3 *vector)
|
||||
float *
|
||||
cogl_vector3_copy (const float *vector)
|
||||
{
|
||||
if (vector)
|
||||
return g_slice_dup (CoglVector3, vector);
|
||||
return g_slice_copy (sizeof (float) * 3, vector);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_free (CoglVector3 *vector)
|
||||
cogl_vector3_free (float *vector)
|
||||
{
|
||||
g_slice_free (CoglVector3, vector);
|
||||
g_slice_free1 (sizeof (float) * 3, vector);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_invert (CoglVector3 *vector)
|
||||
cogl_vector3_invert (float *vector)
|
||||
{
|
||||
vector->x = -vector->x;
|
||||
vector->y = -vector->y;
|
||||
vector->z = -vector->z;
|
||||
vector[X] = -vector[X];
|
||||
vector[Y] = -vector[Y];
|
||||
vector[Z] = -vector[Z];
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_add (CoglVector3 *result,
|
||||
const CoglVector3 *a,
|
||||
const CoglVector3 *b)
|
||||
cogl_vector3_add (float *result,
|
||||
const float *a,
|
||||
const float *b)
|
||||
{
|
||||
result->x = a->x + b->x;
|
||||
result->y = a->y + b->y;
|
||||
result->z = a->z + b->z;
|
||||
result[X] = a[X] + b[X];
|
||||
result[Y] = a[Y] + b[Y];
|
||||
result[Z] = a[Z] + b[Z];
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_subtract (CoglVector3 *result,
|
||||
const CoglVector3 *a,
|
||||
const CoglVector3 *b)
|
||||
cogl_vector3_subtract (float *result,
|
||||
const float *a,
|
||||
const float *b)
|
||||
{
|
||||
result->x = a->x - b->x;
|
||||
result->y = a->y - b->y;
|
||||
result->z = a->z - b->z;
|
||||
result[X] = a[X] - b[X];
|
||||
result[Y] = a[Y] - b[Y];
|
||||
result[Z] = a[Z] - b[Z];
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_multiply_scalar (CoglVector3 *vector,
|
||||
cogl_vector3_multiply_scalar (float *vector,
|
||||
float scalar)
|
||||
{
|
||||
vector->x *= scalar;
|
||||
vector->y *= scalar;
|
||||
vector->z *= scalar;
|
||||
vector[X] *= scalar;
|
||||
vector[Y] *= scalar;
|
||||
vector[Z] *= scalar;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_divide_scalar (CoglVector3 *vector,
|
||||
cogl_vector3_divide_scalar (float *vector,
|
||||
float scalar)
|
||||
{
|
||||
float one_over_scalar = 1.0f / scalar;
|
||||
vector->x *= one_over_scalar;
|
||||
vector->y *= one_over_scalar;
|
||||
vector->z *= one_over_scalar;
|
||||
vector[X] *= one_over_scalar;
|
||||
vector[Y] *= one_over_scalar;
|
||||
vector[Z] *= one_over_scalar;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_normalize (CoglVector3 *vector)
|
||||
cogl_vector3_normalize (float *vector)
|
||||
{
|
||||
float mag_squared =
|
||||
vector->x * vector->x +
|
||||
vector->y * vector->y +
|
||||
vector->z * vector->z;
|
||||
vector[X] * vector[X] +
|
||||
vector[Y] * vector[Y] +
|
||||
vector[Z] * vector[Z];
|
||||
|
||||
if (mag_squared > 0.0f)
|
||||
{
|
||||
float one_over_mag = 1.0f / sqrtf (mag_squared);
|
||||
vector->x *= one_over_mag;
|
||||
vector->y *= one_over_mag;
|
||||
vector->z *= one_over_mag;
|
||||
vector[X] *= one_over_mag;
|
||||
vector[Y] *= one_over_mag;
|
||||
vector[Z] *= one_over_mag;
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
cogl_vector3_magnitude (const CoglVector3 *vector)
|
||||
cogl_vector3_magnitude (const float *vector)
|
||||
{
|
||||
return sqrtf (vector->x * vector->x +
|
||||
vector->y * vector->y +
|
||||
vector->z * vector->z);
|
||||
return sqrtf (vector[X] * vector[X] +
|
||||
vector[Y] * vector[Y] +
|
||||
vector[Z] * vector[Z]);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector3_cross_product (CoglVector3 *result,
|
||||
const CoglVector3 *a,
|
||||
const CoglVector3 *b)
|
||||
cogl_vector3_cross_product (float *result,
|
||||
const float *a,
|
||||
const float *b)
|
||||
{
|
||||
CoglVector3 tmp;
|
||||
float tmp[3];
|
||||
|
||||
tmp.x = a->y * b->z - a->z * b->y;
|
||||
tmp.y = a->z * b->x - a->x * b->z;
|
||||
tmp.z = a->x * b->y - a->y * b->x;
|
||||
*result = tmp;
|
||||
tmp[X] = a[Y] * b[Z] - a[Z] * b[Y];
|
||||
tmp[Y] = a[Z] * b[X] - a[X] * b[Z];
|
||||
tmp[Z] = a[X] * b[Y] - a[Y] * b[X];
|
||||
result[X] = tmp[X];
|
||||
result[Y] = tmp[Y];
|
||||
result[Z] = tmp[Z];
|
||||
}
|
||||
|
||||
float
|
||||
cogl_vector3_dot_product (const CoglVector3 *a, const CoglVector3 *b)
|
||||
cogl_vector3_dot_product (const float *a, const float *b)
|
||||
{
|
||||
return a->x * b->x + a->y * b->y + a->z * b->z;
|
||||
return a[X] * b[X] + a[Y] * b[Y] + a[Z] * b[Z];
|
||||
}
|
||||
|
||||
float
|
||||
cogl_vector3_distance (const CoglVector3 *a, const CoglVector3 *b)
|
||||
cogl_vector3_distance (const float *a, const float *b)
|
||||
{
|
||||
float dx = b->x - a->x;
|
||||
float dy = b->y - a->y;
|
||||
float dz = b->z - a->z;
|
||||
float dx = b[X] - a[X];
|
||||
float dy = b[Y] - a[Y];
|
||||
float dz = b[Z] - a[Z];
|
||||
|
||||
return sqrtf (dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
cogl_vector4_init (CoglVector4 *vector, float x, float y, float z)
|
||||
cogl_vector4_init (float *vector, float x, float y, float z)
|
||||
{
|
||||
vector->x = x;
|
||||
vector->y = y;
|
||||
vector->z = z;
|
||||
vector->w = w;
|
||||
vector[X] = x;
|
||||
vector[Y] = y;
|
||||
vector[Z] = z;
|
||||
vector[W] = w;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector4_init_zero (CoglVector4 *vector)
|
||||
cogl_vector4_init_zero (float *vector)
|
||||
{
|
||||
memset (vector, 0, sizeof (CoglVector4));
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector4_init_from_vector4 (CoglVector4 *vector, CoglVector4 *src)
|
||||
cogl_vector4_init_from_vector4 (float *vector, float *src)
|
||||
{
|
||||
*vector4 = *src;
|
||||
}
|
||||
@ -226,8 +233,8 @@ cogl_vector4_equal (gconstpointer *v0, gconstpointer *v1)
|
||||
return memcmp (v1, v2, sizeof (float) * 4) == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
CoglVector4 *
|
||||
cogl_vector4_copy (CoglVector4 *vector)
|
||||
float *
|
||||
cogl_vector4_copy (float *vector)
|
||||
{
|
||||
if (vector)
|
||||
return g_slice_dup (CoglVector4, vector);
|
||||
@ -235,13 +242,13 @@ cogl_vector4_copy (CoglVector4 *vector)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector4_free (CoglVector4 *vector)
|
||||
cogl_vector4_free (float *vector)
|
||||
{
|
||||
g_slice_free (CoglVector4, vector);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector4_invert (CoglVector4 *vector)
|
||||
cogl_vector4_invert (float *vector)
|
||||
{
|
||||
vector.x = -vector.x;
|
||||
vector.y = -vector.y;
|
||||
@ -250,9 +257,9 @@ cogl_vector4_invert (CoglVector4 *vector)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector4_add (CoglVector4 *result,
|
||||
CoglVector4 *a,
|
||||
CoglVector4 *b)
|
||||
cogl_vector4_add (float *result,
|
||||
float *a,
|
||||
float *b)
|
||||
{
|
||||
result.x = a.x + b.x;
|
||||
result.y = a.y + b.y;
|
||||
@ -261,9 +268,9 @@ cogl_vector4_add (CoglVector4 *result,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector4_subtract (CoglVector4 *result,
|
||||
CoglVector4 *a,
|
||||
CoglVector4 *b)
|
||||
cogl_vector4_subtract (float *result,
|
||||
float *a,
|
||||
float *b)
|
||||
{
|
||||
result.x = a.x - b.x;
|
||||
result.y = a.y - b.y;
|
||||
@ -272,7 +279,7 @@ cogl_vector4_subtract (CoglVector4 *result,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vector4_divide (CoglVector4 *vector,
|
||||
cogl_vector4_divide (float *vector,
|
||||
float scalar)
|
||||
{
|
||||
float one_over_scalar = 1.0f / scalar;
|
||||
|
@ -44,50 +44,9 @@ G_BEGIN_DECLS
|
||||
* component float vectors.
|
||||
*/
|
||||
|
||||
/* All of the cogl-vector API is currently experimental so we
|
||||
* suffix the actual symbols with _EXP so if somone is monitoring for
|
||||
* ABI changes it will hopefully be clearer to them what's going on if
|
||||
* any of the symbols dissapear at a later date.
|
||||
*/
|
||||
#define cogl_vector3_init cogl_vector3_init_EXP
|
||||
#define cogl_vector3_init_zero cogl_vector3_init_zero_EXP
|
||||
#define cogl_vector3_equal cogl_vector3_equal_EXP
|
||||
#define cogl_vector3_equal_with_epsilon cogl_vector3_equal_with_epsilon_EXP
|
||||
#define cogl_vector3_copy cogl_vector3_copy_EXP
|
||||
#define cogl_vector3_free cogl_vector3_free_EXP
|
||||
#define cogl_vector3_invert cogl_vector3_invert_EXP
|
||||
#define cogl_vector3_add cogl_vector3_add_EXP
|
||||
#define cogl_vector3_subtract cogl_vector3_subtract_EXP
|
||||
#define cogl_vector3_multiply_scalar cogl_vector3_multiply_scalar_EXP
|
||||
#define cogl_vector3_divide_scalar cogl_vector3_divide_scalar_EXP
|
||||
#define cogl_vector3_normalize cogl_vector3_normalize_EXP
|
||||
#define cogl_vector3_magnitude cogl_vector3_magnitude_EXP
|
||||
#define cogl_vector3_cross_product cogl_vector3_cross_product_EXP
|
||||
#define cogl_vector3_dot_product cogl_vector3_dot_product_EXP
|
||||
#define cogl_vector3_distance cogl_vector3_distance_EXP
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* FIXME: add sse alignment constraint? */
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} CoglVector3;
|
||||
|
||||
#if 0
|
||||
typedef struct
|
||||
{
|
||||
/* FIXME: add sse alignment constraint? */
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
} CoglVector4;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* cogl_vector3_init:
|
||||
* @vector: The CoglVector3 you want to initialize
|
||||
* @vector: The 3 component vector you want to initialize
|
||||
* @x: The x component
|
||||
* @y: The y component
|
||||
* @z: The z component
|
||||
@ -100,11 +59,11 @@ typedef struct
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_init (CoglVector3 *vector, float x, float y, float z);
|
||||
cogl_vector3_init (float *vector, float x, float y, float z);
|
||||
|
||||
/**
|
||||
* cogl_vector3_init_zero:
|
||||
* @vector: The CoglVector3 you want to initialize
|
||||
* @vector: The 3 component vector you want to initialize
|
||||
*
|
||||
* Initializes a 3 component, single precision float vector with zero
|
||||
* for each component.
|
||||
@ -113,12 +72,12 @@ cogl_vector3_init (CoglVector3 *vector, float x, float y, float z);
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_init_zero (CoglVector3 *vector);
|
||||
cogl_vector3_init_zero (float *vector);
|
||||
|
||||
/**
|
||||
* cogl_vector3_equal:
|
||||
* @v1: The first CoglVector3 you want to compare
|
||||
* @v2: The second CoglVector3 you want to compare
|
||||
* @v1: The first 3 component vector you want to compare
|
||||
* @v2: The second 3 component vector you want to compare
|
||||
*
|
||||
* Compares the components of two vectors and returns TRUE if they are
|
||||
* the same.
|
||||
@ -139,8 +98,8 @@ cogl_vector3_equal (gconstpointer v1, gconstpointer v2);
|
||||
|
||||
/**
|
||||
* cogl_vector3_equal_with_epsilon:
|
||||
* @vector0: The first CoglVector3 you want to compare
|
||||
* @vector1: The second CoglVector3 you want to compare
|
||||
* @vector0: The first 3 component vector you want to compare
|
||||
* @vector1: The second 3 component vector you want to compare
|
||||
* @epsilon: The allowable difference between components to still be
|
||||
* considered equal
|
||||
*
|
||||
@ -159,43 +118,43 @@ cogl_vector3_equal (gconstpointer v1, gconstpointer v2);
|
||||
* Stability: Unstable
|
||||
*/
|
||||
gboolean
|
||||
cogl_vector3_equal_with_epsilon (const CoglVector3 *vector0,
|
||||
const CoglVector3 *vector1,
|
||||
cogl_vector3_equal_with_epsilon (const float *vector0,
|
||||
const float *vector1,
|
||||
float epsilon);
|
||||
|
||||
/**
|
||||
* cogl_vector3_copy:
|
||||
* @vector: The CoglVector3 you want to copy
|
||||
* @vector: The 3 component vector you want to copy
|
||||
*
|
||||
* Allocates a new #CoglVector3 structure on the heap initializing the
|
||||
* components from the given @vector and returns a pointer to the newly
|
||||
* allocated vector. You should free the memory using
|
||||
* Allocates a new 3 component float vector on the heap initializing
|
||||
* the components from the given @vector and returns a pointer to the
|
||||
* newly allocated vector. You should free the memory using
|
||||
* cogl_vector3_free()
|
||||
*
|
||||
* Returns: A newly allocated #CoglVector3.
|
||||
* Returns: A newly allocated 3 component float vector
|
||||
*
|
||||
* Since: 1.4
|
||||
* Stability: Unstable
|
||||
*/
|
||||
CoglVector3 *
|
||||
cogl_vector3_copy (const CoglVector3 *vector);
|
||||
float *
|
||||
cogl_vector3_copy (const float *vector);
|
||||
|
||||
/**
|
||||
* cogl_vector3_free:
|
||||
* @vector: The CoglVector3 you want to free
|
||||
* @vector: The 3 component you want to free
|
||||
*
|
||||
* Frees a #CoglVector3 that was previously allocated with
|
||||
* Frees a 3 component vector that was previously allocated with
|
||||
* cogl_vector_copy()
|
||||
*
|
||||
* Since: 1.4
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_free (CoglVector3 *vector);
|
||||
cogl_vector3_free (float *vector);
|
||||
|
||||
/**
|
||||
* cogl_vector3_invert:
|
||||
* @vector: The CoglVector3 you want to manipulate
|
||||
* @vector: The 3 component vector you want to manipulate
|
||||
*
|
||||
* Inverts/negates all the components of the given @vector.
|
||||
*
|
||||
@ -203,7 +162,7 @@ cogl_vector3_free (CoglVector3 *vector);
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_invert (CoglVector3 *vector);
|
||||
cogl_vector3_invert (float *vector);
|
||||
|
||||
/**
|
||||
* cogl_vector3_add:
|
||||
@ -218,9 +177,9 @@ cogl_vector3_invert (CoglVector3 *vector);
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_add (CoglVector3 *result,
|
||||
const CoglVector3 *a,
|
||||
const CoglVector3 *b);
|
||||
cogl_vector3_add (float *result,
|
||||
const float *a,
|
||||
const float *b);
|
||||
|
||||
/**
|
||||
* cogl_vector3_subtract:
|
||||
@ -235,13 +194,13 @@ cogl_vector3_add (CoglVector3 *result,
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_subtract (CoglVector3 *result,
|
||||
const CoglVector3 *a,
|
||||
const CoglVector3 *b);
|
||||
cogl_vector3_subtract (float *result,
|
||||
const float *a,
|
||||
const float *b);
|
||||
|
||||
/**
|
||||
* cogl_vector3_multiply_scalar:
|
||||
* @vector: The CoglVector3 you want to manipulate
|
||||
* @vector: The 3 component vector you want to manipulate
|
||||
* @scalar: The scalar you want to multiply the vector components by
|
||||
*
|
||||
* Multiplies each of the @vector components by the given scalar.
|
||||
@ -250,12 +209,12 @@ cogl_vector3_subtract (CoglVector3 *result,
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_multiply_scalar (CoglVector3 *vector,
|
||||
cogl_vector3_multiply_scalar (float *vector,
|
||||
float scalar);
|
||||
|
||||
/**
|
||||
* cogl_vector3_divide_scalar:
|
||||
* @vector: The CoglVector3 you want to manipulate
|
||||
* @vector: The 3 component vector you want to manipulate
|
||||
* @scalar: The scalar you want to divide the vector components by
|
||||
*
|
||||
* Divides each of the @vector components by the given scalar.
|
||||
@ -264,12 +223,12 @@ cogl_vector3_multiply_scalar (CoglVector3 *vector,
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_divide_scalar (CoglVector3 *vector,
|
||||
cogl_vector3_divide_scalar (float *vector,
|
||||
float scalar);
|
||||
|
||||
/**
|
||||
* cogl_vector3_normalize:
|
||||
* @vector: The CoglVector3 you want to manipulate
|
||||
* @vector: The 3 component vector you want to manipulate
|
||||
*
|
||||
* Updates the vector so it is a "unit vector" such that the
|
||||
* @vector<!-- -->s magnitude or length is equal to 1.
|
||||
@ -278,11 +237,11 @@ cogl_vector3_divide_scalar (CoglVector3 *vector,
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_normalize (CoglVector3 *vector);
|
||||
cogl_vector3_normalize (float *vector);
|
||||
|
||||
/**
|
||||
* cogl_vector3_magnitude:
|
||||
* @vector: The CoglVector3 you want the magnitude for
|
||||
* @vector: The 3 component vector you want the magnitude for
|
||||
*
|
||||
* Calculates the scalar magnitude or length of @vector.
|
||||
*
|
||||
@ -292,13 +251,13 @@ cogl_vector3_normalize (CoglVector3 *vector);
|
||||
* Stability: Unstable
|
||||
*/
|
||||
float
|
||||
cogl_vector3_magnitude (const CoglVector3 *vector);
|
||||
cogl_vector3_magnitude (const float *vector);
|
||||
|
||||
/**
|
||||
* cogl_vector3_cross_product:
|
||||
* @result: Where you want the result written
|
||||
* @u: Your first CoglVector3
|
||||
* @v: Your second CoglVector3
|
||||
* @u: Your first 3 component vector
|
||||
* @v: Your second 3 component vector
|
||||
*
|
||||
* Calculates the cross product between the two vectors @u and @v.
|
||||
*
|
||||
@ -322,16 +281,16 @@ cogl_vector3_magnitude (const CoglVector3 *vector);
|
||||
* Stability: Unstable
|
||||
*/
|
||||
void
|
||||
cogl_vector3_cross_product (CoglVector3 *result,
|
||||
const CoglVector3 *u,
|
||||
const CoglVector3 *v);
|
||||
cogl_vector3_cross_product (float *result,
|
||||
const float *u,
|
||||
const float *v);
|
||||
|
||||
/**
|
||||
* cogl_vector3_dot_product:
|
||||
* @a: Your first CoglVector3
|
||||
* @b: Your second CoglVector3
|
||||
* @a: Your first 3 component vector
|
||||
* @b: Your second 3 component vector
|
||||
*
|
||||
* Calculates the dot product of the two #CoglVector3<!-- -->s. This
|
||||
* Calculates the dot product of the two 3 component vectors. This
|
||||
* can be used to determine the magnitude of one vector projected onto
|
||||
* another. (for example a surface normal)
|
||||
*
|
||||
@ -365,7 +324,7 @@ cogl_vector3_cross_product (CoglVector3 *result,
|
||||
* Stability: Unstable
|
||||
*/
|
||||
float
|
||||
cogl_vector3_dot_product (const CoglVector3 *a, const CoglVector3 *b);
|
||||
cogl_vector3_dot_product (const float *a, const float *b);
|
||||
|
||||
/**
|
||||
* cogl_vector3_distance:
|
||||
@ -375,13 +334,14 @@ cogl_vector3_dot_product (const CoglVector3 *a, const CoglVector3 *b);
|
||||
* If you consider the two given vectors as (x,y,z) points instead
|
||||
* then this will compute the distance between those two points.
|
||||
*
|
||||
* Returns: The distance between two points given as @CoglVector3<!-- -->s
|
||||
* Returns: The distance between two points given as 3 component
|
||||
* vectors.
|
||||
*
|
||||
* Since: 1.4
|
||||
* Stability: Unstable
|
||||
*/
|
||||
float
|
||||
cogl_vector3_distance (const CoglVector3 *a, const CoglVector3 *b);
|
||||
cogl_vector3_distance (const float *a, const float *b);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user