Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 计算直线和圆弧之间的交点_C_Trigonometry_Sdl 2_Intersection - Fatal编程技术网

C 计算直线和圆弧之间的交点

C 计算直线和圆弧之间的交点,c,trigonometry,sdl-2,intersection,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

我正在用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)
有了这些信息,我考虑使用三角形的直线来检测它是否与圆弧相交。但是我不知道如何用数学来实现它


注意:圆弧正在移动,并且它们的坐标会在每一帧更新。我只需要知道检测交叉口的实现。

解决了它


你说你有弧的中心点坐标。所以它们不是同心的?我这样问是因为对我来说(可能太近视了),弧线在小whitle圆盘上看起来是同心的。是的,它们都有相同的中心点。屏幕中间你能计算出圆弧中心到光标的距离吗?如果这非常接近弧的半径,这意味着什么?但是坐标是多余的,这似乎表明你没有正确地理解目标-或者没有正确地解释目标,也没有足够详细,这似乎更有可能。@Hazel:or
arcRGBA
需要中心点,即使所有圆弧都具有相同的.Hmmm,真正的目标是:1)光标是否位于圆弧扇区(饼状楔形)或2)三角形光标是否与圆弧(外缘)相交?这个答案确实解决了#1,但提出的问题“计算直线和圆弧之间的交点”看起来像#2,但在这里没有解决。当与圆弧中心点的距离相同时(圆弧半径相同),它确实解决了。@ScottHunter