樹心幽徑

三角形外接圓的三尖內擺線
2017/12/08,15:07

alt

alt

alt

/*
畫出三角外接圓的三尖內擺線 */

void TriCuspedHypocycloid(double xa,double ya,double xb,double yb,double xc,double yc,Image *pim,char *cst){
double xm,ym,k,t;
//外接圓
pim->strokeColor(cst);
k=0.5*((yc-yb)*(ya-yb)-(xb-xc)*(xa-xb))/((xb-xc)*(ya-yc)-(yc-yb)*(xc-xa));
xm=0.5*(xa+xc)+k*(ya-yc);
ym=0.5*(ya+yc)+k*(xc-xa);
pim->draw(DrawableCircle(xm,ym,xa,ya));
double a=pow(pow(xm-xa,2)+pow(ym-ya,2),0.5)/3;
for (t=0;t<360;t+=3){
    double rad=(t/180)*M_PI;
    double xt=2*a*cos(rad)+a*cos(2*rad)+xm;
    double yt=2*a*sin(rad)-a*sin(2*rad)+ym;
    double xc=2*a*cos(rad)+xm;
    double yc=2*a*sin(rad)+ym;
    pim->draw(DrawableText(xt, yt, "t"));
    pim->draw(DrawableText(xc, yc, "c"));
    pim->draw(DrawableLine(xt,yt,xc,yc));
//    pim->draw(DrawableCircle(xc,yc,xt,yt));
    }

}

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType