Ejemplo n.º 1
0
  def test_vector_weights_reduce_to_lerp_preset(self):
    """Tests if vector slerp reduces to lerp for identical vectors as input."""
    q1 = tf.constant((_SQRT2_DIV2, 0.0, _SQRT2_DIV2, 0.0))
    q2 = tf.constant((_SQRT2_DIV2, 0.0, _SQRT2_DIV2, 0.0))
    p = tf.constant((0.75,), dtype=q1.dtype)

    w1, w2 = slerp.vector_weights(q1, q2, p)

    self.assertAllClose(w1, (0.25,), rtol=1e-6)
    self.assertAllClose(w2, (0.75,), rtol=1e-6)
Ejemplo n.º 2
0
  def test_interpolate_with_weights_vector_preset(self):
    """Compares interpolate to vector_weights + interpolate_with_weights."""
    # Any quaternion is a valid vector
    q1 = self._pick_random_quaternion()
    q2 = q1 + tf.ones_like(q1)

    weight1, weight2 = slerp.vector_weights(q1, q2, 0.75)
    qf = slerp.interpolate_with_weights(q1, q2, weight1, weight2)

    qi = slerp.interpolate(q1, q2, 0.75, method=slerp.InterpolationType.VECTOR)
    self.assertAllClose(qf, qi, atol=1e-9)