Exemplo n.º 1
0
static gboolean
gimp_operation_cage_coef_calc_is_on_straight (GimpVector2 *d1,
                                              GimpVector2 *d2,
                                              GimpVector2 *p)
{
  GimpVector2 v1, v2;
  gfloat      deter;

  v1.x = p->x - d1->x;
  v1.y = p->y - d1->y;
  v2.x = d2->x - d1->x;
  v2.y = d2->y - d1->y;

  gimp_vector2_normalize (&v1);
  gimp_vector2_normalize (&v2);

  deter = v1.x * v2.y - v2.x * v1.y;

  return (deter < 0.000000001) && (deter > -0.000000001);
}
Exemplo n.º 2
0
/**
 * gimp_vector2_normal_val:
 * @vector: a #GimpVector2.
 *
 * This function is identical to gimp_vector2_normal() but the vector
 * is passed by value rather than by reference.
 *
 * Returns: a #GimpVector2 perpendicular to @vector, with a length of 1.0.
 *
 * Since: 2.8
 **/
GimpVector2
gimp_vector2_normal_val (GimpVector2 vector)
{
  GimpVector2 result;

  result.x = - vector.y;
  result.y = vector.x;

  gimp_vector2_normalize (&result);

  return result;
}
Exemplo n.º 3
0
/**
 * gimp_vector2_normal:
 * @vector: a pointer to a #GimpVector2.
 *
 * Compute a normalized perpendicular vector to @vector
 *
 * Returns: a #GimpVector2 perpendicular to @vector, with a length of 1.0.
 *
 * Since: 2.8
 **/
GimpVector2
gimp_vector2_normal (GimpVector2 *vector)
{
  GimpVector2 result;

  result.x = - vector->y;
  result.y = vector->x;

  gimp_vector2_normalize (&result);

  return result;
}