29 #define HUGE_VAL 1.7976931348623157e+308
54 float dx, dy, dz, u_d[3];
55 float a[3], incr, min_incr, tlen, len;
56 int outside, above, below, edge, istep;
61 G_debug(3,
"gs_los_intersect1():");
73 istep = edge = below = 0;
79 min_incr = incr / 1000.0;
107 while (incr > min_incr) {
116 above = (a[
Z] >
b[
Z]);
127 while (outside || above) {
139 above = (a[
Z] >
b[
Z]);
164 if ((edge) && (
b[
Z] - (a[
Z] + dz * 2.0) > incr * u_d[
Z])) {
165 G_debug(3,
" looking under surface");
195 float p1, p2, u_d[3];
196 int above, ret, num, i, usedx;
198 float bgn[3], end[3], a1[3];
203 G_debug(3,
"gs_los_intersect");
261 G_debug(3,
" %d points to check", num);
267 usedx = (fabs(u_d[
X]) > fabs(u_d[
Y]));
297 if (a[
Z] < points[0][
Z]) {
312 for (i = 1; i < num; i++) {
314 incr = ((points[i][
X] - a1[
X]) / u_d[
X]);
317 incr = ((points[i][
Y] - a1[
Y]) / u_d[
Y]);
320 a[
X] = a1[
X] + (incr * u_d[
X]);
321 a[
Y] = a1[
Y] + (incr * u_d[
Y]);
322 a[
Z] = a1[
Z] + (incr * u_d[
Z]);
323 above = (a[
Z] >= points[i][
Z]);
338 incr = ((a[
X] -
b[
X]) / u_d[
X]);
341 incr = ((a[
Y] -
b[
Y]) / u_d[
Y]);
345 1.0, a[
Z], 0.0,
b[
Z], &p1, &p2))) {
346 point[
X] = points[i - 1][
X] + (u_d[
X] * incr * p1);
347 point[
Y] = points[i - 1][
Y] + (u_d[
Y] * incr * p1);
353 G_debug(3,
" line of sight error %d", ret);
385 int ph_num,
double *tresult,
int *pn)
387 double tnear, tfar,
t, vn, vd;
388 int fnorm_num, bnorm_num;
396 vd =
DOT3(dir, phdrn[ph_num]);
397 vn =
DOT3(org, phdrn[ph_num]) + phdrn[ph_num][
W];
471 float n, s, w, e,
b,
t;
478 tlfront[
X] = tlfront[
Y] = 0.0;
486 planes[0][
X] = planes[0][
Y] = 0.0;
488 planes[0][
W] = -(
DOT3(planes[0], tlfront));
491 planes[1][
X] = planes[1][
Y] = 0.0;
493 planes[1][
W] = -(
DOT3(planes[1], brback));
496 planes[2][
Y] = planes[2][
Z] = 0.0;
498 planes[2][
W] = -(
DOT3(planes[2], tlfront));
501 planes[3][
Y] = planes[3][
Z] = 0.0;
503 planes[3][
W] = -(
DOT3(planes[3], brback));
506 planes[4][
X] = planes[4][
Z] = 0.0;
508 planes[4][
W] = -(
DOT3(planes[4], tlfront));
511 planes[5][
X] = planes[5][
Z] = 0.0;
513 planes[5][
W] = -(
DOT3(planes[5], brback));
533 double dist, maxdist;
int G_debug(int, const char *,...) __attribute__((format(printf
void GS_v3mult(float *, float)
Multiple vectors.
int gs_get_yrange(float *, float *)
Get y-range.
int GS_get_zrange(float *, float *, int)
Get z-extent for all loaded surfaces.
int gsd_get_cplanes(Point4 *)
Get cplaces.
void GS_v3add(float *, float *)
Sum vectors.
int segs_intersect(float, float, float, float, float, float, float, float, float *, float *)
Line intersect.
void GS_v3eq(float *, float *)
Copy vector values.
int gs_get_xrange(float *, float *)
Get x-range.
Point3 * gsdrape_get_allsegments(geosurf *, float *, float *, int *)
Get all segments.
int viewcell_tri_interp(geosurf *, typbuff *, Point3, int)
ADD.
typbuff * gs_get_att_typbuff(geosurf *, int, int)
Get attribute data buffer.
int GS_v3dir(float *, float *, float *)
Get a normalized direction from v1 to v2, store in v3.
float GS_distance(float *, float *)
Calculate distance.
geosurf * gs_get_surf(int)
Get geosurf struct.
void gs_get_databounds_planes(Point4 *planes)
Get data bounds for plane.
int gs_los_intersect1(int surfid, float(*los)[3], float *point)
Crude method of intersecting line of sight with closest part of surface.
int gs_setlos_enterdata(Point3 *los)
int gs_los_intersect(int surfid, float **los, float *point)
Crude method of intersecting line of sight with closest part of surface.
#define HUGE_VAL
Values needed for Ray-Convex Polyhedron Intersection Test below originally by Eric Haines,...
int RayCvxPolyhedronInt(Point3 org, Point3 dir, double tmax, Point4 *phdrn, int ph_num, double *tresult, int *pn)
Ray-Convex Polyhedron Intersection Test.