示例#1
0
/**
 * graphene_vec3_equal:
 * @v1: a #graphene_vec3_t
 * @v2: a #graphene_vec3_t
 *
 * Checks whether the two given #graphene_vec3_t are equal.
 *
 * Returns: `true` if the two vectors are equal, and false otherwise
 *
 * Since: 1.2
 */
bool
graphene_vec3_equal (const graphene_vec3_t *v1,
                     const graphene_vec3_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_vec3_near (v1, v2, GRAPHENE_FLOAT_EPSILON);
}
示例#2
0
static void
quaternion_angle_vec3_to_from (mutest_spec_t *spec)
{
  graphene_quaternion_t q1, q2;
  graphene_vec3_t axis;
  float angle;

  graphene_quaternion_init_from_angle_vec3 (&q1, 45.f, graphene_vec3_y_axis ());
  graphene_quaternion_init_from_quaternion (&q2, &q1);
  graphene_quaternion_to_angle_vec3 (&q2, &angle, &axis);

  mutest_expect ("roundtrip init_from_angle_vec3 and to_angle_vec3 yields the same angle",
                 mutest_float_value (angle),
                 mutest_to_be_close_to, 45.0, 0.0001,
                 NULL);
  mutest_expect ("roundtrip init_from_angle_vec3 and to_angle_vec3 yields the same axis",
                 mutest_bool_value (graphene_vec3_near (&axis, graphene_vec3_y_axis (), 0.0001f)),
                 mutest_to_be_true,
                 NULL);
}