小弟sin函数不会用,不知道该如何把 pt1, pt2这点坐标转化成弧度,能帮忙一下吗?
void Draw(CPoint pt1, CPoint pt2, CDC * pDC)
{
....
}

解决方案 »

  1.   

    还要提供个Sin函数的幅度,否则没办法确定
      

  2.   

    幅度就是 pt1到pt2的距离
      

  3.   

    周期就是 pt2.x - pt1.x
    幅度就是 pt2.y - pt1.y
      

  4.   

    找中间的一些点,用MoveToLineTo
      

  5.   

    一般不用sin,用 tan.  atan((y2-y1)/(x2-x1))表示其与水平线即x轴的夹角
      

  6.   

    lz给的条件,根本就画不出正弘线来一个周期后,y应该是一样的,结果楼主的条件幅度是pt2.y - pt1.y
      

  7.   

    double dx, dy ;
    int    x = pt1.x,  y  ; 
    int nDiffY = pt1.y - pt2.y;
    int x1 = pt2.x-pt1.x;
    int y1 = pt2.y-pt1.y;
    double fAngle = atan2((double)y1, (double)x1);
    bool bFirst = true;
    for (x = x; x < 1024; x++)
    {
    dx  = x * fAngle;
    dy  = sin (dx) ;
    y   = pt1.y - (int)(dy * nDiffY) ;

    if(bFirst)
    pDC->MoveTo(x,y);
    pDC->LineTo (x, y) ; 
    x++;
    bFirst = false;
    }高手能否帮忙改一下?
      

  8.   

    过两点的sin线好像有多条,楼主要更限制一些。
      

  9.   

    你应该根据2点坐标求出sin相关函数表达式,再画出
    给你个画sinx的代码
    void CxxxDlg::OnPaint()
    { CRect rect;
    GetClientRect(&rect);
    const int n = 5000; CPaintDC dc(this);
    CPen pen(0, 1, RGB(0, 0, 255));
    CPen* pOldPen = dc.SelectObject(&pen); int nWidth = rect.Width();
    int nHeight = rect.Height();
    dc.SetViewportOrg(nWidth / 2,nHeight - 30);

    POINT pt[2 * n];
    for(int i = -1 * n; i < n; i++)
    {
    long cx = (i * nWidth / 2 * 32) / n;
    long cy = -100 + sin((double)cx / 32) * (-32);
    pt[i + n].x = cx;
    pt[i + n].y = cy;
    }
    dc.Polyline(pt,2 *n ); CDialog::OnPaint();
    }
      

  10.   

    我的要求就是以 pt1为原点和正弦线的中心,到pt2正好为半个正弦线,以后就以此类推。。
      

  11.   

    角速度为: w = pi / 2.0 / (pt2.x - pt1.x);
    y = sin(w * x) * (pt2.y - pt1.y) + pt1.y;