计算线与弧之间的交点

时间:2019-12-25 22:30:34

标签: c trigonometry sdl-2 intersection

我正在用sdl2 / sdl_gfx在c语言中实现一个小游戏,您需要通过将小光标移动到白色圆圈下方(它绕圆圈移动)来避免弧形出现在中心(中间)。

我的问题很简单:什么可以有效检测光标是否与圆弧相交?

对于每个圆弧都有:中心点(x,y),起始和终止半径,半径。 哪些参数是:

int arcRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)

对于我的光标(圆圈下面的小三角形),我有:三角形的坐标。

int filledTrigonRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a)

有了这些信息,我考虑使用三角形的线来检测它是否与圆弧相交。但是我不知道如何用其中涉及的数学来实现它。

enter image description here

注意:弧正在移动,其坐标每帧更新一次。我只需要知道检测交叉点的实现即可。

1 个答案:

答案 0 :(得分:0)

解决了!!!!!!!

Notes This topic

相关问题