在mfc中绕其中点旋转一条线 [英] Rotaing a Line Around its midpoint in mfc

查看:88
本文介绍了在mfc中绕其中点旋转一条线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我想在mfc。中心周围旋转一条线。

这应该旋转当我点击鼠标移动它。

继承人的代码。

请帮我把。



其中NewPoint是鼠标点击点

和m_newStart是行起点



Hi there,

I'm tring to rotate a line in mfc., around its center.
this should be rotated as i click the mouse and move it.
heres the code for it.
please help me put.

where NewPoint is the mouse click point
and m_newStart is line start point

double distY=abs(m_NewPoint.y);
double distX=abs(m_NewPoint.x);
double theta=(abs(atan(distY/distX))*180/3.14);

m_newStart.x  = MdPt.x + (StPt.x-MdPt.x)*(cos(theta)) - (StPt.y-MdPt.y)*(sin(theta));
m_newStart.y  = MdPt.y  +  (-1)*(StPt.x-MdPt.x)*(sin(theta)) - (StPt.y-MdPt.y) * cos(theta));

m_newEnd.x  = MdPt.x -  (StPt.x-MdPt.x)*(cos(theta)) + (StPt.y-MdPt.y)*(sin(theta));
m_newEnd.y  = MdPt.y  -  (-1)*(StPt.x-MdPt.x)*(sin(theta)) + (StPt.y-MdPt.y)*(cos(theta));

推荐答案

通过此代码(java)计算X和Y.在C ++中使用sin和cos(包括math.h)。

Calculate X and Y by this code (java). Use sin and cos in C++ (include math.h).
 x = center + radius * Math.sin( angle );
 y = center - radius * Math.cos( angle );
}


这篇关于在mfc中绕其中点旋转一条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆