分形树算法之一


drawLeaf(CClientDC dc, int x, int y, int L, double A)
{
CPen NewPen(PS_SOLID,1,RGB(0,0,0));//
CPen OldPen(PS_SOLID,1,RGB(255,255,255));
if(isD)dc.SelectObject(NewPen);
else dc.SelectObject(OldPen);


double B=50;//

double C=9;//

double s1=2;//、

double s2=3;//

double s3=1.3;//

int x1,y1;
int x1L,y1L;
int x1R,y1R;
int x2,y2;
int x2R,y2R;
int x2L,y2L;

if(L>s1)
{
   x2=int(x+L*cos(A*PI));//

   y2=int(y+L*sin(A*PI));
   x2R=int(x2+L/s2*cos((A+B)*PI));
   y2R=int(y2+L/s2*sin((A+B)*PI));
   x2L=int(x2+L/s2*cos((A-B)*PI));
   y2L=int(y2+L/s2*sin((A-B)*PI));


   x1=int(x+L/s2*cos(A*PI));
   y1=int(y+L/s2*sin(A*PI));
   x1R=int(x1+L/s2*cos((A-B)*PI));
   y1R=int(y1+L/s2*sin((A-B)*PI));
   x1L=int(x1+L/s2*cos((A+B)*PI));
   y1L=int(y1+L/s2*sin((A+B)*PI));

   dc.MoveTo(x,y);
   dc.LineTo(x2,y2);
   dc.LineTo(x2L,y2L);
   dc.MoveTo(x2,y2); 
   dc.LineTo(x2R,y2R);
   dc.MoveTo(x1,y1);
   dc.LineTo(x1L,y1L);
   dc.MoveTo(x1,y1);
   dc.LineTo(x1R,y1R);


   drawLeaf(this,int(x2),int(y2),int(L/s3),A+C);
   drawLeaf(this,int(x2R),int(y2R),int(L/s2),A+B);
   drawLeaf(this,int(x2L),int(y2L),int(L/s2),A-B);
   drawLeaf(this,int(x1L),int(y1L),int(L/s2),A+B);
   drawLeaf(this,int(x1R),int(y1R),int(L/s2),A-B);
}


}

baidu 2010-10-28 12:45
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值