資源簡介
這里給出一個已知兩點坐標和圓心角,求圓心坐標的程序源碼,供大家參考,代碼涉及大量數學推導,求解出唯一的圓心坐標,
代碼片段和文件信息
void?CircleCenter(double?x1double?y1double?x2double?y2double?centerAngledouble?&xdouble?&y)??
{??
double?L=sqrt(pow((x1-x2)2)+pow((y1-y2)2));?//弦長
double?R=0.5*L/sin(0.5*centerAngle);//圓弧半徑
????if(x1?==?x2)
????{
????????y?=?(y1?+?y2)?/?2;
????????if(y1?>?y2?&&?centerAngle?>?PI?)
????????????x?=?x1?-?sqrt(R*R-pow((y2?-?y1)/22));
????????else
????????????x?=?x1?+?sqrt(R*R-pow((y2?-?y1)/22));
????}
????else
????{
????????double?c1?=?(x
評論
共有 條評論