Try this, is a modified version of your code.
Perhaps contain some bugs, because I could not verify.
Code:function LWBulgeCalc($xs, $xe, $ys, $ye, $bulge) { $result = array(); $dx = ($xe - $xs)/2 ; $dy = ($ye - $ys)/2 ; $a = (1/$bulge-$bulge)/2 ; $r = abs($bulge+1/$bulge)*sqrt($dx*$dx + $dy*$dy)/2 ; //Radius circle $dr1x = $dy*$a - $dx ; $dr1y = -$dx*$a - $dy ; $theta_s = rad2deg(acos($dr1x/$r)) ; if($dr1y < 0) $theta_s = 360 - $theta_s ; $theta_e = $theta_s + 4*rad2deg(atan($bulge)) ; if($theta_e < 0) $theta_e += 360 ; if($theta_e >= 360) $theta_e -= 360 ; $result[0] = $xe-$dr1x ; $result[1] = $ye-$dr1y ; $result[2] = $r ; $result[3] = $theta_s ; $result[4] = $theta_e ; return $result; }
Last edited by _Eduardo_; 07-26-2010 at 07:40 PM.
Hello,
I use this in my geometry lib::
Code:public static double GetAnglefromPoints(double x1, double y1, double x2, double y2) { double retval = 0; retval = Math.Round(Math.Atan2((y2 - y1), (x2 - x1)), 4); retval = R2D(retval); return retval; } public static double R2D(double iangle) { return iangle * (180.0 / Math.PI); }
And with GetAnglefromPoints, the first X,Y is center point and the second will either be start or end.
HTH,
Brad Murry