Revision 1045 branches/simulator/projects/simulator/simulator/core/world.c
| world.c (revision 1045) | ||
|---|---|---|
| 61 | 61 |
point_t p1 = ray->p; |
| 62 | 62 |
point_t p2 = {ray->p.x+cos(ray->d),ray->p.y+sin(ray->d)};
|
| 63 | 63 |
|
| 64 |
#if DEBUG |
|
| 65 |
printf("(%g,%g) --> (%g,%g) with (%g,%g) --> (%g,%g)\n",p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y);
|
|
| 66 |
#endif |
|
| 64 |
//printf("(%g,%g) --> (%g,%g) with (%g,%g) --> (%g,%g)\n",p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y);
|
|
| 67 | 65 |
denom = (p2.y-p1.y)*(p4.x-p3.x)-(p2.x-p1.x)*(p4.y-p3.y); |
| 68 | 66 |
if (denom == 0) {
|
| 69 | 67 |
return RAY_MISS; |
| ... | ... | |
| 84 | 82 |
xint = p3.x+ua*(p4.x-p3.x); |
| 85 | 83 |
yint = p3.y+ua*(p4.y-p3.y); |
| 86 | 84 |
dist = sqrt((xint-p1.x)*(xint-p1.x)+(yint-p1.y)*(yint-p1.y)); |
| 87 |
#if DEBUG |
|
| 88 |
printf("Got: %g\n", dist);
|
|
| 89 |
#endif |
|
| 90 | 85 |
return dist; |
| 91 | 86 |
|
| 92 | 87 |
} |
Also available in: Unified diff