예제 #1
0
/**
 * graphene_vec4_equal:
 * @v1: a #graphene_vec4_t
 * @v2: a #graphene_vec4_t
 *
 * Checks whether the two given #graphene_vec4_t are equal.
 *
 * Returns: `true` if the two vectors are equal, and false otherwise
 *
 * Since: 1.2
 */
bool
graphene_vec4_equal (const graphene_vec4_t *v1,
                     const graphene_vec4_t *v2)
{
  if (v1 == v2)
    return true;

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

  if (graphene_simd4f_cmp_eq (v1->value, v2->value))
    return true;

  return graphene_vec4_near (v1, v2, GRAPHENE_FLOAT_EPSILON);
}
예제 #2
0
static void
quaternion_vec4_to_from (mutest_spec_t *spec)
{
  graphene_quaternion_t *q;
  graphene_vec4_t v, check;

  graphene_vec4_init (&v, 1.f, 2.f, 3.f, 4.f);

  q = graphene_quaternion_init_from_vec4 (graphene_quaternion_alloc (), &v);
  graphene_quaternion_to_vec4 (q, &check);

  mutest_expect ("roundtrip between init_from_vec4 and to_vec4 to yield the same vector",
                 mutest_bool_value (graphene_vec4_near (&v, &check, 0.0001f)),
                 mutest_to_be_true,
                 NULL);

  graphene_quaternion_free (q);
}
예제 #3
0
static void
quaternion_operators_normalize (mutest_spec_t *spec)
{
  graphene_quaternion_t q1, q2;
  graphene_vec4_t v1, v2;

  graphene_quaternion_init (&q1, 1.f, 2.f, 3.f, 4.f);
  graphene_quaternion_normalize (&q1, &q2);

  graphene_vec4_init (&v1, 1.f, 2.f, 3.f, 4.f);
  graphene_vec4_normalize (&v1, &v1);

  graphene_quaternion_to_vec4 (&q2, &v2);

  mutest_expect ("normalizing a quaternion is the same as normalizing the equivalent vec4",
                 mutest_bool_value (graphene_vec4_near (&v1, &v2, 0.00001f)),
                 mutest_to_be_true,
                 NULL);
}