Calculate avg position with weight per point

   356   3   2
User Avatar
Member
948 posts
Joined: April 2008
Offline
I know that to calculate the average position you just need to loop through points add their position together and divide by the amount of points but how can I have a wight per point so it does not have so much influence on the average calculation.
For example I have 3 points and I want to calculate the average position for all of them but I wand point 2 to have 0.5 weight on the influence for this calculation, I hope it makes sense.

I am not very good at math so I need help on this one.

Thanks in advance.
https://vimeo.com/user2163076 [vimeo.com]
User Avatar
Member
8554 posts
Joined: July 2007
Offline
multiply each position by its weight, add them together and divide by sum of weights
Edited by tamte - Feb. 28, 2024 15:26:03
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
393 posts
Joined: Nov. 2016
Offline
Might be simpler ways but here`s one:

In a wrangle:

v@weightedP = v@P * f@weight;

Then use two attribute promotes to calculate the sums of @weightedP and of @weight;

Divide the sum of @weightedP by the sum of @weight to get your average;

Edit: Got tamted.
Edited by Tanto - Feb. 28, 2024 15:33:49
User Avatar
Member
948 posts
Joined: April 2008
Offline
Thanks for the help guys!
https://vimeo.com/user2163076 [vimeo.com]
  • Quick Links