Monday, November 5, 2018

animation - How to linearly "blend" between multiple 3D points?


I have a set of 3D points that I need to "blend" between. Lets say I have points [A,B,C] and I have the amount I want to blend each as [0.5, 0.2, 0.8], how can I blend between these points with the amount I need?


Obviously if I just had 2 points I could use the vector math (A + (B - A) * ratio).


Method 1: I'm currently using a weighted average, which I suppose gives me the weighted center, but I need to try different blending styles to see visually which looks best.


Method 2 What If I did this:





  1. Calculated a difference vector, each 3D point against the default point (I do have a default point)


    A - Default




  2. Then multiplied this difference with the blend amount


    (A - Default) * Amount




  3. And added these up, would that work? What result would I get?



    (A - Default) * A_Amount + (B - Default) * B_Amount + (C - Default) * C_Amount





Answer



It is called a barycentre. Here your point is:


P = (A * A_ratio + B * B_ratio + C * C_ratio) / (A_ratio + B_ratio + C_ratio)

Badly, Wikipedia have no dedicaced page for this, so you'll have to understand the explanation of center of mass, which is just a generalization of barycentres applied to physics.


EDIT: your second method is equal to:


P - default


Proof:


((A - def) * A_r + (B - def) * B_r + (C - def) * C_r) / (A_r + B_r + C_r)
= (A * A_r + B * B_r + C * C_r) / (A_r + B_r + C_r) - def * (A_r + B_r + C_r) / (A_r + B_r + C_r)
= P - def

No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...