Esempio n. 1
0
/**
 * graphene_vec3_near:
 * @v1: a #graphene_vec3_t
 * @v2: a #graphene_vec3_t
 * @epsilon: the threshold between the two vectors
 *
 * Compares the two given #graphene_vec3_t vectors and checks
 * whether their values are within the given @epsilon.
 *
 * Returns: `true` if the two vectors are near each other
 *
 * Since: 1.2
 */
bool
graphene_vec3_near (const graphene_vec3_t *v1,
                    const graphene_vec3_t *v2,
                    float                  epsilon)
{
  float epsilon_sq = epsilon * epsilon;
  graphene_simd4f_t d;

  if (v1 == v2)
    return true;

  if (v1 == NULL || v2 == NULL)
    return false;

  d = graphene_simd4f_sub (v1->value, v2->value);

  return graphene_simd4f_get_x (graphene_simd4f_dot3 (d, d)) < epsilon_sq;
}
Esempio n. 2
0
/**
 * graphene_simd4f_dot3:
 * @a: a #graphene_simd4f_t
 * @b: a #graphene_simd4f_t
 *
 * Computes the dot product of the first three components of the
 * two given #graphene_simd4f_t.
 *
 * Returns: a vector whose components are all set to the
 *   dot product of the components of the two operands
 *
 * Since: 1.0
 */
graphene_simd4f_t
(graphene_simd4f_dot3) (const graphene_simd4f_t a,
                        const graphene_simd4f_t b)
{
  return graphene_simd4f_dot3 (a, b);
}
Esempio n. 3
0
/**
 * graphene_vec3_dot:
 * @a: a #graphene_vec3_t
 * @b: a #graphene_vec3_t
 *
 * Computes the dot product of the two given vectors.
 *
 * Returns: the value of the dot product
 *
 * Since: 1.0
 */
float
graphene_vec3_dot (const graphene_vec3_t *a,
                   const graphene_vec3_t *b)
{
  return graphene_simd4f_get_x (graphene_simd4f_dot3 (a->value, b->value));
}