Ok, I am not sure I understand your problem, but it sounds like you want to find the x and y coordinates of a point on a circle? Since you are passing in the length (radius) of the circle, then it is a really simple geometry/trig problem (if I understand your request).
Assumptions:
1) Cartesian coordinate system (obvious since you want x and y)
2) the (0,0) point exists at the axis of the second and hour hands (so for instance, 11 o'clock would be negative x but positive y. Or 7 o'clock would be negative x and negative y)
equation of a circle (geometry):
eq1: radius2 = x2 + y2
since we only know the radius, then we need another equation for the second unknown (trig):
eq2: sin( angle ) = ( x/radius )
so we solve for x in eq2:
x = radius * sin( angle )
NOTE: angle must be in radians. If it is in degrees (90 or 180, etc then you need to devide the angle by 2*Pi
So now we solve eq1 for y in terms of x:
y = sqrt( radius2 - x2 )
sooooo ... you can reduce all your code to:
// Function angle_point
// This function takes degrees and length and finds endpoint coordinates of radius
// Used for drawing out a clock with php
//
// Parameters are $angle (in degrees) and length of segment
function angle_point( $angleInDegrees, $length )
{
// Convert degrees To Radians
$angleInRadians = $angleInDegrees / ( 2 * pi() );
$point['x'] = $length * sin( $angleInRadians );
$point['y'] = sqrt( $length^2 - $point['x']^2;
return $point;
}
I think this is right, I was an engineer long time ago.
Hope this helps,
Michael