# Calculate mid angle position based on three points

Hi,

How can I calculate the position of p4 such that it’s always halfway between the angle of p1,2,3?

Thanks!

There’s maybe a better fancy mathematical formula also, but i guess, you could just use a temporarily helper GameObject for this purpose.

Herefore you should have to calculate the angle between the 2 vectors and also their average length. Rotate the helper object to this angle and move it to the position.
Something like this could maybe work (not tested):

``````float angle = Vector3.Angle(p1-p2, p3-p2) / 2f;
float length = (Vector3.Distance(p1,p2) + Vector3.Distance(p3,p2)) / 2f;

//helper GameObject
GameObject p4GO = new GameObject("p4");
p4GO.transform.position = p2;
p4GO.transform.LookAt(p1);
p4GO.transform.Rotate(Vector3.up, angle);//maybe use Vector left or forward instead
p4GO.transform.position += p4GO.transform.forward * length;

Vector3 p4 = p4GO.transform.position;

//here you can destroy the helper, if only the Vector3 is needed
Destroy(p4GO);
``````