CPoint pointCenter,pointA,pointB;
pointA 以 pointCenter为中心旋转角度 X 后的点 pointB是多少?谢谢各位

解决方案 »

  1.   

    我实验写一个:            //平移pointCenter到(0,0)点
                pointA.X -= pointCenter.X;
                pointA.Y -= pointCenter.Y;            //绕原点旋转pointA获得pointB的坐标
                double radin = angle * 3.1415926 / 180.0; //角度转弧度
                double sin = Math.Sin(radin);
                double cos = Math.Cos(radin);            pointB.X = pointA.X * cos - pointA.Y * sin;
                pointB.Y = pointA.X * sin + pointA.Y * cos;            //平移回去
                pointB.X += pointCenter.X;
                pointB.Y += pointCenter.Y;           
      

  2.   

    既然自己都知道是三角函数的问题,查一下不就好了。Google也能查出来。
      

  3.   

    #define M_PI       3.14159265358979323846
    #define DegToRad(degree) ((degree) * (M_PI / 180.0f))    
    void MyDraw(HWND hwnd)
    {
    RECT device;
    GetClientRect(hwnd,&device);
    int cx,cy;
    cx=device.right;
    cy=device.bottom;

    if (cx<cy)
    {
    cy=cx;
    }
    else
    {
    cx=cy;
    }
    if (cx%2)
    {
    cy=--cx;
    } HDC hdc;
    hdc=GetDC(hwnd);  SetMapMode(hdc,MM_ANISOTROPIC);  int r=100;

    // scale & xlate
    SetWindowExtEx(hdc,2*r,2*r,NULL);
    SetViewportExtEx(hdc,cx,-cy,NULL); SetWindowOrgEx  (hdc, 0, 0,NULL);
    SetViewportOrgEx(hdc,cx/2,cy/2,NULL); // x,y axes
    MoveToEx(hdc,-r,0,NULL);
    LineTo  (hdc, r,0);
    MoveToEx(hdc,0,r,NULL);
    LineTo  (hdc,0,-r); // 100-unit circle
    MoveToEx(hdc,r,0,NULL);
    AngleArc(hdc,0,0,r,0,360); // eg. for unit circle, in page space, (1,0) counter-clockwise rotate 30 degrees, becomes (cos30,sin30) 
    // we can calculate corresponding coordinate in device page by lptodp POINT p;
    p.x=(int)(cos(DegToRad(30)) * r);
    p.y=(int)(sin(DegToRad(30)) * r); MoveToEx(hdc,0,0,NULL);
    LineTo(hdc,p.x,p.y); // (86,49) ->(   532,146) LPtoDP(hdc,&p,1);}