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

  • 1
    \$\begingroup\$ What do you mean by blending here? Do you want the weighted center of these points? If you just want to blend three points A to three other points B you could use your formula with three different sets of A, B, and ratio. \$\endgroup\$
    – danijar
    Dec 24 '12 at 9:43
  • \$\begingroup\$ I need to try different types of blending to see visually which works best. I'm currently using a weighted average, which I suppose gives me the weighted center. Are there other types? See edit; \$\endgroup\$ Dec 24 '12 at 9:47

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


((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
  • \$\begingroup\$ What would the ratios be if I wanted a perfectly centralized point? 0.5 for all? Or 1 for all? \$\endgroup\$ Dec 24 '12 at 9:54
  • \$\begingroup\$ It is called an isobarycenter, and is equal to the average of all points \$\endgroup\$
    – Synxis
    Dec 24 '12 at 9:55
  • \$\begingroup\$ Synxis you are really good in math, but I cannot understand your "P - default" statement or its proof, in simple terms what do you mean? \$\endgroup\$ Dec 24 '12 at 10:04
  • \$\begingroup\$ P - default: P is the barycenter defined at the top of my answer, and default is the point you've named Default'. In a nushell, your second method is just a 'wrong' version of your first, because the result will be translated by -1 * Default` \$\endgroup\$
    – Synxis
    Dec 24 '12 at 11:32
  • \$\begingroup\$ No. You cannot set all ratios to 0, because you have to divide by the sum of all ratios, which has to be non-null. \$\endgroup\$
    – Synxis
    Dec 24 '12 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.