root / branches / simulator / projects / simulator / rayHits.c @ 1067
History  View  Annotate  Download (504 Bytes)
1 
#include <stdlib.h> 

2 
#include <math.h> 
3  
4 
double Xr, Yr, Tr, Xc, Yc, Rc; // (X,Y,theta for ray) (X,Y,radius for circle) 
5  
6 
boolean rayHits(double Xr,double Yr,double Tr,double Xc,double Yc,double Rc) 
7 
{ 
8 
double m, b, D, t;

9 
m = tan(Tr); 
10 
b= m * Xr + Yr; 
11 
D = (abs(Yc  m * Xc  b)) / (sqrt(m * m + 1);

12  
13 
if (D < Rc )

14 
{ 
15 
return true; 
16 
} 
17 
else

18 
{ 
19 
return false; 
20 
} 
21  
22 
return false; 
23 
} 
24  
25  
26 
/*

27 
*

28 
*

29 
*

30 
*

31 
*

32 
*

33 
*

34 
*

35 
*/

36  
37 
double a, b, c, t1, t2;

38  
39 
t1 = ( 
40  
41 
((Xr  Xc)^2 + 2*cos(Tr)*( 