Having browsed the net extensively I have found a few decent pieces of code, but nothing in PHP, so I've been trying to convert these. The basic theory is that if you add up all of the angles between the points on the polygon from the target point, you should get 360 degrees. However, calculating which angles should be positive and which should be negative, etc is getting to me. I'm not bad at maths, hell, I spent a couple of years working in OpenGL, lots of maths there, but the difference is that the languages I used then supported a getangle function.
I was just wondering if someone has a guaranteed working getangle function for PHP? A function that takes 3 points and calculates the angle between 2 of them from the third, and which takes into account the direction of the vector between the two points so that negatives are calculated correctly. Does anyone know where I can find such a function?
This has really been annoying me, I've trashed the code and started over again 3 times already and I dont want to have to do that again!
Thanks for any help.