如何计算累积和&鼠标移动的速度是明智的方向吗? [英] How to calculate cumulative & speed for mouse movements clock wise directions?

查看:69
本文介绍了如何计算累积和&鼠标移动的速度是明智的方向吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在屏幕中央有一个圆形图像。我的要求是计算

最终用户鼠标移动以及圆圈朝向时钟方向然后需要计算它的累积,速度。



一旦用户沿逆时针方向移动鼠标和圆圈,则无需计数。计算仅适用于时钟方向。



作为一个部分,我在屏幕中心完成了我的圈子。所以任何指导或正确的指示都会有所帮助。 />
谢谢



我的代码: - 在我的屏幕中央显示圆圈



Hi,
I have a circle Image on center of screen. My requirement is to calculate the
end-user mouse movements along with circle towards clock wise directions then It's required to calculate it's CUMULATIVE, SPEED.

Also once the user moves the mouse along with circle in anti-clock wise directions, then no need to count. The calculation is only for clock wise directions.

As a part I finished my circle in center of screen..So any guidance or right directions will be helpful.
Thanks

My codes :- Display Circle in Center of my Screen

protected void Page_Load(object sender, EventArgs e)
  {
        SolidBrush MyBrush = new SolidBrush(System.Drawing.Color.Brown);
        Bitmap Bmp1 = new Bitmap(150, 60);
        Graphics G = Graphics.FromImage(Bmp1);
        G.Clear(Color.White);
        Pen MyDrawingPen = new Pen(Color.FromArgb(75, Color.Chocolate), 15);
        Rectangle MyRect = new Rectangle(25, 9, 45, 40);
        G.DrawEllipse(MyDrawingPen, MyRect);
        G.FillEllipse(MyBrush, MyRect);
        string path = Server.MapPath("/DrawEllipse_1.jpg");
        Bmp1.Save(path, ImageFormat.Jpeg);
        Image1.ImageUrl = "/DrawEllipse_1.jpg";
        G.Dispose();
        Bmp1.Dispose();
}



再次感谢



我尝试了什么:



尝试计算鼠标累积,速度旋转以及圆圈,但仅用于顺时针旋转。


Thanks Again

What I have tried:

Trying to calculate the mouse cumulative, speed rotation along with circle, but only for clock wise rotation.

推荐答案

我将解释这个概念,而不是给你代码。编写代码不仅仅是复制代码并将其粘贴到项目中。理解概念并编写您试图完成的过程有助于无法估量。 (这称为规范)然后,您可以编写适合设计的代码。



从第1点开始参考下面的网格。鼠标将以顺时针方向移动网格上的其余数字。您应该对三角学有一个基本的了解,以帮助确定何时绘制圆圈。

Rather than giving you code, I will explain the concept. Writing code is more than just copying code and pasting it into your project. Understanding the concepts and writing the process of what you are attempting to accomplish helps immeasurably. (This is called a specification) You can then write the code to fit the design.

Refer to the grid below starting at point 1. The mouse will move through the remaining numbers on the grid in a clockwise direction. You should have a basic understanding of trigonometry to help identify when you are drawing a circle.
--------->-----1------>--------
|    |    |    |    |    |    |
|    |    |    |    |    |    |
-----8---------|---------2-----
|    | Q4 |    |    | Q1 |    |
^    |    |    |    |    |    V
---------------|---------------
|    |    |    |    |    |    |
|    |    |    |    |    |    |
7______________|______________3
|    |    |    |    |    |    |
|    |    |    |    |    |    |
---------------|---------------
^    | Q3 |    |    | Q2 |    V
|    |    |    |    |    |    |
-----6---------|---------4-----
|    |    |    |    |    |    |
|    |    |    |    |    |    |
---------<-----5-----<---------

哪个方向是我们去?

下面是一个用于确定顺时针方向的状态表,取当前鼠标x和y值以及之前的x和y值的差异。 Q1差异应该导致正X值和负Y值,依此类推。记下方向的历史,以了解鼠标是否继续沿着方向移动。

Which direction are we going?
Below is a state table for determing clockwise direction, take the differences of the current mouse x and y values and the previous x and y values. The Q1 difference should result in a positive X value and a negative Y value, and so on. Keep a history of the direction to know if the mouse continues to move in a clokwise direction.

Quadrant   CW Dir Rslt
-----------------------
   Q1         +X -Y
   Q2         -X -Y
   Q3         -X +Y
   Q4         +X +Y



我们的速度有多快?

用于计算鼠标坐标每次变化的速度(X ,Y)记录自上次坐标更改以来的时间。提示:使用计时器计数器作为秒表。慢圈需要更长的时间......



我会留给你使用谷歌找出如何获得鼠标坐标(mousemove事件)和设置并读取计时器来衡量事件之间的时间。



祝你好运!


How fast are we going?
For calculating the speed for every change in mouse coordinates(X,Y) record the time since the last coordinate change. Hint: use the timer counter as a stop watch. A slow circle will take longer...

I will leave it to you to use google to find out how to get the mouse coordinates (mousemove event) and set up and read a timer to measure the time between events.

Good Luck!


这篇关于如何计算累积和&amp;鼠标移动的速度是明智的方向吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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