使箭头跟随一个圆圈 [英] Making an arrow follow a circle

查看:112
本文介绍了使箭头跟随一个圆圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我正在编写一个GUI程序,该程序使箭头或直线随圆变,但我只是不知道该怎么做.就是这样,如果移动圆,则箭头的原点必须与圆一起移动,而箭头的终点不必移动.并且箭头必须在圆的外围.这里的一点帮助对我和你都是有益的.

PS:我知道如何画一个箭头和一个圆并进行命中测试.

Hi there,
I''m writing a GUI program that makes a point of an arrow or a line follow a circle, but I just don''t know how to make it. Is like this, if you move the circle the point of origin of the arrow must move with the circle and the point of destiny of the arrow doesn''t has to move. And the arrow must be on the periphery of the circle. A little help here would be rewarding for me and you.

PS: I know how to draw an arrow and a circle and making a hittest.

Thanks in advance!

推荐答案

我会给你一个主意,希望它足以让你自己继续前进.
I''ll give you an idea and hope it will suffice to get you going on your own.

  1. 圆是由中心点(x,y)加上半径C(x,y,r)定义的.
  2. 箭头由起点A和终点B定义,其中这些点中的每一个都是坐标(X,Y).对于箭头,将存在给定长度l的约束. L(A,B)
  3. 已被假定为已移动圆C的代码已经存在.
  4. 开始条件 :
    圆C定位在Cx,Cy中,并根据箭头的起点和长度确定箭头A的终点.提示:为此,您必须确定线形的角度A的起点到C的中心,然后在给定A的起点,直线长度和角度的情况下计算终点.
  5. 发生圆弧移动
  6. 必须确定箭头的新起点A,该起点取决于新方向(相对于圆心的角度)和箭头速度.鉴于新的起点和与圆心的夹角,将重新计算类似于点4的箭头终点.
  7. 结束条件:
    直线L的端点B之间的距离小于或等于直线C的长度加上直线C的半径.如果发生这种情况,箭头会抓住该圆圈.

  1. A circle is defined by a center point (x,y) plus a radius C(x,y,r).
  2. An arrow is defined by a starting point A and an end point B where each of these points is a coordinate (X,Y). For an arrow there will be a constraint of a given length l. L(A,B)
  3. It''s taken as a given that the code to move the circle C is already in place.
  4. Start condition:
    The circle C is positioned in Cx,Cy and given the arrows starting point and length you determine the endpoint of the arrow A. Hint: For that you''ll have to determine the angle of the line form A''s starting point to the center of C and then calculate the endpoint given the starting point of A the length of the line and the angle.
  5. Move of circle takes place
  6. The new starting point A for the arrow must be determined which depends on the new direction (angle relative to the circle''s center) and the speed of the arrow. Given that new starting point and the angle towards the circle''s center recalculate the arrows endpoint analogous to point 4.
  7. End Condition:
    The distance between the endpoint B of line L is less than or equal to the radius of circle C added to the length of line L. If this happens the arrow has caught the circle.


希望对您有所帮助!

干杯!


Hope this helps some!

Cheers!


这篇关于使箭头跟随一个圆圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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