蒙面唱将第一期都是谁:java如何作心脏线图

来源:百度文库 编辑:高校问答 时间:2024/05/09 13:59:38

VC里部分代码(全部的太多了,看不明白就算了):
#include <math.h>

#define MY_FLOAT double
//pi*2
#define M_PI_M2 (MY_FLOAT)6.28318530717958647692

void LAtoXY(MY_FLOAT &fx,MY_FLOAT &fy,MY_FLOAT flength,MY_FLOAT fangle)
{
fx = flength * sin( fangle );
fy = flength * cos( fangle );
}
MY_FLOAT Calculate( MY_FLOAT angle )
{
return 100*(1+sin(angle));
}

// CCardioidView 绘图
void CCardioidView::OnDraw(CDC* pDC)
{
CRect trect;
GetClientRect( &trect );
int ty = trect.bottom-trect.top;
ty /= 2;
int tx = trect.right-trect.left;
tx /= 2;
pDC->MoveTo( 0 , ty );
pDC->LineTo( trect.right , ty );
pDC->MoveTo( tx , 0 );
pDC->LineTo( tx , trect.bottom );

CPen tpen( 0 , 2 , RGB(0xff,0x0,0) );
CPen *tppen = pDC->SelectObject( &tpen );

MY_FLOAT tangle,tlength;
MY_FLOAT tfx,tfy;

tangle = 0;
tlength = Calculate ( tangle );
LAtoXY( tfx , tfy , tlength , tangle );

pDC->MoveTo( tx+int(0.5+tfx) , ty+int(0.5+tfy) );

for( tangle = 0.01 ; tangle < M_PI_M2 ; tangle += 0.01 )
{
tlength = Calculate( tangle );
LAtoXY( tfx , tfy , tlength , tangle );
pDC->LineTo( tx+int(0.5+tfx) , ty+int(0.5+tfy) );
}

pDC->SelectObject( tppen );
}