0

I have 2 quarternians (Q1 & Q2), I'd like to apply a coefficient to each Quaternian, where the sum of both coefficients = 1. As far as I'm aware, multiplying a quaternian by another is equivalent to adding them together.

In linear mathematics, this would as simple as:

AC + B(1-C) = Y

and

A.C = S, B*(1-C) = T

so

S + T = Y

I would be lerping C from 0 to 1. Q1 is dynamic, while Q2 is a fixed target, so for this reason, I don't think Quarternian.Lerp is a practical solution.

How do I mutliply a quaternian by a coefficient, as Q1 * Q1 is equivalent to adding them together, which would be suitable for calculating the final product, ie S+T.

I'm unsure how to go about this.

Craig
  • 101
  • It looks like you're describing Quaternion Lerp or Slerp. The formula you've shown is literally a Lerp formula. What leads you to believe that computing the coefficients manually would give you different results than using these standard approaches, or what unwanted outcome have you gotten from Lerp/Slerp that you're hoping you can correct with your own solution? – DMGregory May 26 '20 at 12:54
  • Q1 is being translated to Q3. Q2 is near Q3. I want to progressively apply higher values of Q2 to the product towards the end value. – Craig May 26 '20 at 13:23
  • Which is something you can do with a nested Lerp or Slerp. Lerp(Lerp(Q1, Q3, t1), Q2, t2). It's unclear to me what you expect to gain from doing the coefficient multiplication manually. Can you please explain in detail what unwanted outcome you get from doing a normal Quaternion Lerp or Slerp here? – DMGregory May 26 '20 at 13:26
  • I'm trying to manually perform a Animator.MatchTarget. I'm using the Playables API, for which this function doesn't work. As this is an animation, Q3 is defined in the animation, I can't calculate the lerp from Q1 to Q3. – Craig May 26 '20 at 13:29
  • That sounds like a perfect application for standard Quaternion Lerp. Where have you run into difficulty applying this in your code? Please edit your question to show us how you've written your code, and a concrete test case where it misbehaves. – DMGregory May 26 '20 at 13:34
  • I'm muddling how to do this in my head at the moment, all the code I've tried is not even remotely useful. – Craig May 26 '20 at 13:41
  • Perhaps Lerp(Q1, Q2, Lerp(0, 1, t)) might work, this would progressively add more weight to Q2. – Craig May 26 '20 at 13:43
  • Lerp(0, 1, t) is the same as t alone (or Clamp01(t) if t is allowed to go outside the 0-1 range and you're using Unity's Lerp that clamps between the endpoints). So I think you might be making this more complicated than it needs to be. Showing us even an incomplete stub function would give us something to go on, that's clearer about your intentions and needs in this scenario. – DMGregory May 26 '20 at 13:56

0 Answers0