Algorithm to find average position

Posted by Simran kaur on Game Development See other posts from Game Development or by Simran kaur
Published on 2014-08-24T08:58:57Z Indexed on 2014/08/24 10:31 UTC
Read the original article Hit count: 323

Filed under:

enter image description here

In the given diagram, I have the extreme left and right points, that is -2 and 4 in this case. So, obviously, I can calculate the width which is 6 in this case.

What we know:

The number of partitions:3 in this case The partition number at at any point i.e which one is 1st,second or third partition (numbered starting from left)

What I want:

The position of the purple line drawn which is positio of average of a particular partition

So, basically I just want a generalized formula to calculate position of the average at any point.

© Game Development or respective owner

Related posts about algorithm