BRL-CAD
plane.h
Go to the documentation of this file.
1/* P L A N E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20
21/*----------------------------------------------------------------------*/
22/** @addtogroup bg_plane
23 *
24 * Plane structures (from src/librt/plane.h) and plane/line/point calculations
25 *
26 * TODO - this API may need to be simplified. A lot of the closest point
27 * calculations, for example, should probably just concern themselves with the
28 * calculation itself and leave any tolerance based questions to a separate
29 * step.
30 */
31/** @{ */
32/* @file plane.h */
33
34#ifndef BG_PLANE_H
35#define BG_PLANE_H
36
37#include "common.h"
38#include "vmath.h"
39#include "bn/tol.h"
40#include "bg/defines.h"
41
42__BEGIN_DECLS
43
44
45#define MAXPTS 4 /**< All we need are 4 points */
46#define pl_A pl_points[0] /**< Synonym for A point */
47
49 size_t pl_npts; /**< number of points on plane */
50 point_t pl_points[MAXPTS]; /**< Actual points on plane */
51 vect_t pl_Xbasis; /**< X (B-A) vector (for 2d coords) */
52 vect_t pl_Ybasis; /**< Y (C-A) vector (for 2d coords) */
53 vect_t pl_N; /**< Unit-length Normal (outward) */
54 fastf_t pl_NdotA; /**< Normal dot A */
55 fastf_t pl_2d_x[MAXPTS]; /**< X 2d-projection of points */
56 fastf_t pl_2d_y[MAXPTS]; /**< Y 2d-projection of points */
57 fastf_t pl_2d_com[MAXPTS]; /**< pre-computed common-term */
58 struct plane_specific *pl_forw; /**< Forward link */
59 char pl_code[MAXPTS+1]; /**< Face code string. Decorative. */
60};
61
62/**
63 * Describe the tri_specific structure.
64 */
66 point_t tri_A; /**< triangle vertex (A) */
67 vect_t tri_BA; /**< B - A (second point) */
68 vect_t tri_CA; /**< C - A (third point) */
69 vect_t tri_wn; /**< facet normal (non-unit) */
70 vect_t tri_N; /**< unit normal vector */
71 fastf_t *tri_normals; /**< unit vertex normals A, B, C (this is malloced storage) */
72 int tri_surfno; /**< solid specific surface number */
73 struct tri_specific *tri_forw; /**< Next facet */
74};
75
77
78/**
79 * A more memory conservative version
80 */
82 float tri_A[3]; /**< triangle vertex (A) */
83 float tri_BA[3]; /**< B - A (second point) */
84 float tri_CA[3]; /**< C - A (third point) */
85 float tri_wn[3]; /**< facet normal (non-unit) */
86 float tri_N[3]; /**< unit normal vector */
87 signed char *tri_normals; /**< unit vertex normals A, B, C (this is malloced storage) */
88 int tri_surfno; /**< solid specific surface number */
89 struct tri_float_specific *tri_forw;/**< Next facet */
90};
91
93
94
95/**
96 *@brief
97 * Calculate the square of the distance of closest approach for two
98 * lines.
99 *
100 * The lines are specified as a point and a vector each. The vectors
101 * need not be unit length. P and d define one line; Q and e define
102 * the other.
103 *
104 * @return 0 - normal return
105 * @return 1 - lines are parallel, dist[0] is set to 0.0
106 *
107 * Output values:
108 * dist[0] is the parametric distance along the first line P + dist[0] * d of the PCA
109 * dist[1] is the parametric distance along the second line Q + dist[1] * e of the PCA
110 * dist[3] is the square of the distance between the points of closest approach
111 * pt1 is the point of closest approach on the first line
112 * pt2 is the point of closest approach on the second line
113 *
114 * This algorithm is based on expressing the distance squared, taking
115 * partials with respect to the two unknown parameters (dist[0] and
116 * dist[1]), setting the two partials equal to 0, and solving the two
117 * simultaneous equations
118 */
119BG_EXPORT extern int bg_distsq_line3_line3(fastf_t dist[3],
120 point_t P,
121 vect_t d,
122 point_t Q,
123 vect_t e,
124 point_t pt1,
125 point_t pt2);
126
127/**
128 * Find the distance from a point P to a line described by the
129 * endpoint A and direction dir, and the point of closest approach
130 * (PCA).
131 *
132 @code
133 // P
134 // *
135 // /.
136 // / .
137 // / .
138 // / . (dist)
139 // / .
140 // / .
141 // *------*-------->
142 // A PCA dir
143 @endcode
144 * There are three distinct cases, with these return codes -
145 * 0 => P is within tolerance of point A. *dist = 0, pca=A.
146 * 1 => P is within tolerance of line. *dist = 0, pca=computed.
147 * 2 => P is "above/below" line. *dist=|PCA-P|, pca=computed.
148 *
149 * TODO: For efficiency, a version of this routine that provides the
150 * distance squared would be faster.
151 */
152BG_EXPORT extern int bg_dist_pnt3_line3(fastf_t *dist,
153 point_t pca,
154 const point_t a,
155 const point_t p,
156 const vect_t dir,
157 const struct bn_tol *tol);
158
159/**
160 * calculate intersection or closest approach of a line and a line
161 * segment.
162 *
163 * returns:
164 * -2 -> line and line segment are parallel and collinear.
165 * -1 -> line and line segment are parallel, not collinear.
166 * 0 -> intersection between points a and b.
167 * 1 -> intersection outside a and b.
168 * 2 -> closest approach is between a and b.
169 * 3 -> closest approach is outside a and b.
170 *
171 * dist[0] is actual distance from p in d direction to
172 * closest portion of segment.
173 * dist[1] is ratio of distance from a to b (0.0 at a, and 1.0 at b),
174 * dist[1] may be less than 0 or greater than 1.
175 * For return values less than 0, closest approach is defined as
176 * closest to point p.
177 * Direction vector, d, must be unit length.
178 *
179 */
180BG_EXPORT extern int bg_dist_line3_lseg3(fastf_t *dist,
181 const fastf_t *p,
182 const fastf_t *d,
183 const fastf_t *a,
184 const fastf_t *b,
185 const struct bn_tol *tol);
186
187/**
188 * Calculate closest approach of two lines
189 *
190 * returns:
191 * -2 -> lines are parallel and do not intersect
192 * -1 -> lines are parallel and collinear
193 * 0 -> lines intersect
194 * 1 -> lines do not intersect
195 *
196 * For return values less than zero, dist is not set. For return
197 * values of 0 or 1, dist[0] is the distance from p1 in the d1
198 * direction to the point of closest approach for that line. Similar
199 * for the second line. d1 and d2 must be unit direction vectors.
200 *
201 * XXX How is this different from bg_isect_line3_line3() ?
202 * XXX Why are the calling sequences just slightly different?
203 * XXX Can we pick the better one, and get rid of the other one?
204 * XXX If not, can we document how they differ?
205 */
206BG_EXPORT extern int bg_dist_line3_line3(fastf_t dist[2],
207 const point_t p1,
208 const point_t p2,
209 const vect_t d1,
210 const vect_t d2,
211 const struct bn_tol *tol);
212
213/**
214 *@brief
215 * Find the distance from a point P to a line segment described by the
216 * two endpoints A and B, and the point of closest approach (PCA).
217 @verbatim
218 *
219 * P
220 * *
221 * /.
222 * / .
223 * / .
224 * / . (dist)
225 * / .
226 * / .
227 * *------*--------*
228 * A PCA B
229 @endverbatim
230 *
231 * @return 0 P is within tolerance of lseg AB. *dist isn't 0: (SPECIAL!!!)
232 * *dist = parametric dist = |PCA-A| / |B-A|. pca=computed.
233 * @return 1 P is within tolerance of point A. *dist = 0, pca=A.
234 * @return 2 P is within tolerance of point B. *dist = 0, pca=B.
235 * @return 3 P is to the "left" of point A. *dist=|P-A|, pca=A.
236 * @return 4 P is to the "right" of point B. *dist=|P-B|, pca=B.
237 * @return 5 P is "above/below" lseg AB. *dist=|PCA-P|, pca=computed.
238 *
239 * This routine was formerly called bn_dist_pnt_lseg().
240 *
241 * XXX For efficiency, a version of this routine that provides the
242 * XXX distance squared would be faster.
243 */
244BG_EXPORT extern int bg_dist_pnt3_lseg3(fastf_t *dist,
245 point_t pca,
246 const point_t a,
247 const point_t b,
248 const point_t p,
249 const struct bn_tol *tol);
250
251/**
252 * PRIVATE: This is a new API and should be considered unpublished.
253 *
254 * Find the square of the distance from a point P to a line segment described
255 * by the two endpoints A and B.
256 *
257 * P
258 * *
259 * /.
260 * / .
261 * / .
262 * / . (dist)
263 * / .
264 * / .
265 * *------*--------*
266 * A PCA B
267 *
268 * There are six distinct cases, with these return codes -
269 * Return code precedence: 1, 2, 0, 3, 4, 5
270 *
271 * 0 P is within tolerance of lseg AB. *dist = 0.
272 * 1 P is within tolerance of point A. *dist = 0.
273 * 2 P is within tolerance of point B. *dist = 0.
274 * 3 PCA is within tolerance of A. *dist = |P-A|**2.
275 * 4 PCA is within tolerance of B. *dist = |P-B|**2.
276 * 5 P is "above/below" lseg AB. *dist=|PCA-P|**2.
277 *
278 * If both P and PCA and not within tolerance of lseg AB use
279 * these return codes -
280 *
281 * 3 PCA is to the left of A. *dist = |P-A|**2.
282 * 4 PCA is to the right of B. *dist = |P-B|**2.
283 *
284 * This function is a test version of "bn_distsq_pnt3_lseg3".
285 *
286 */
287BG_EXPORT extern int bg_distsq_pnt3_lseg3_v2(fastf_t *distsq,
288 const fastf_t *a,
289 const fastf_t *b,
290 const fastf_t *p,
291 const struct bn_tol *tol);
292
293/**
294 * @brief
295 * Check to see if three points are collinear.
296 *
297 * The algorithm is designed to work properly regardless of the order
298 * in which the points are provided.
299 *
300 * @return 1 If 3 points are collinear
301 * @return 0 If they are not
302 */
303BG_EXPORT extern int bg_3pnts_collinear(point_t a,
304 point_t b,
305 point_t c,
306 const struct bn_tol *tol);
307
308/**
309 * @return 1 if the two points are equal, within the tolerance
310 * @return 0 if the two points are not "the same"
311 */
312BG_EXPORT extern int bg_pnt3_pnt3_equal(const point_t a,
313 const point_t b,
314 const struct bn_tol *tol);
315
316/**
317 *@brief
318 * Find the distance from a point P to a line segment described by the
319 * two endpoints A and B, and the point of closest approach (PCA).
320 @verbatim
321 * P
322 * *
323 * /.
324 * / .
325 * / .
326 * / . (dist)
327 * / .
328 * / .
329 * *------*--------*
330 * A PCA B
331 @endverbatim
332 * There are six distinct cases, with these return codes -
333 * @return 0 P is within tolerance of lseg AB. *dist isn't 0: (SPECIAL!!!)
334 * *dist = parametric dist = |PCA-A| / |B-A|. pca=computed.
335 * @return 1 P is within tolerance of point A. *dist = 0, pca=A.
336 * @return 2 P is within tolerance of point B. *dist = 0, pca=B.
337 * @return 3 P is to the "left" of point A. *dist=|P-A|**2, pca=A.
338 * @return 4 P is to the "right" of point B. *dist=|P-B|**2, pca=B.
339 * @return 5 P is "above/below" lseg AB. *dist=|PCA-P|**2, pca=computed.
340 *
341 *
342 * Patterned after bg_dist_pnt3_lseg3().
343 */
344BG_EXPORT extern int bg_dist_pnt2_lseg2(fastf_t *dist_sq,
345 fastf_t pca[2],
346 const point_t a,
347 const point_t b,
348 const point_t p,
349 const struct bn_tol *tol);
350
351/**
352 *@brief
353 * Intersect two 3D line segments, defined by two points and two
354 * vectors. The vectors are unlikely to be unit length.
355 *
356 *
357 * @return -3 missed
358 * @return -2 missed (line segments are parallel)
359 * @return -1 missed (collinear and non-overlapping)
360 * @return 0 hit (line segments collinear and overlapping)
361 * @return 1 hit (normal intersection)
362 *
363 * @param[out] dist
364 * The value at dist[] is set to the parametric distance of the
365 * intercept dist[0] is parameter along p, range 0 to 1, to
366 * intercept. dist[1] is parameter along q, range 0 to 1, to
367 * intercept. If within distance tolerance of the endpoints,
368 * these will be exactly 0.0 or 1.0, to ease the job of caller.
369 *
370 * CLARIFICATION: This function 'bn_isect_lseg3_lseg3'
371 * returns distance values scaled where an intersect at the start
372 * point of the line segment (within tol->dist) results in 0.0
373 * and when the intersect is at the end point of the line
374 * segment (within tol->dist), the result is 1.0. Intersects
375 * before the start point return a negative distance. Intersects
376 * after the end point result in a return value > 1.0.
377 *
378 * Special note: when return code is "0" for co-linearity, dist[1] has
379 * an alternate interpretation: it's the parameter along p (not q)
380 * which takes you from point p to the point (q + qdir), i.e., it's
381 * the endpoint of the q linesegment, since in this case there may be
382 * *two* intersections, if q is contained within span p to (p + pdir).
383 *
384 * @param p point 1
385 * @param pdir direction-1
386 * @param q point 2
387 * @param qdir direction-2
388 * @param tol tolerance values
389 */
390BG_EXPORT extern int bg_isect_lseg3_lseg3(fastf_t *dist,
391 const point_t p, const vect_t pdir,
392 const point_t q, const vect_t qdir,
393 const struct bn_tol *tol);
394
395BG_EXPORT extern int bg_lseg3_lseg3_parallel(const point_t sg1pt1, const point_t sg1pt2,
396 const point_t sg2pt1, const point_t sg2pt2,
397 const struct bn_tol *tol);
398
399/**
400 * Intersect two line segments, each in given in parametric form:
401 *
402 * X = p0 + pdist * pdir_i (i.e. line p0->p1)
403 * and
404 * X = q0 + qdist * qdir_i (i.e. line q0->q1)
405 *
406 * The input vectors 'pdir_i' and 'qdir_i' must NOT be unit vectors
407 * for this function to work correctly. The magnitude of the direction
408 * vectors indicates line segment length.
409 *
410 * The 'pdist' and 'qdist' values returned from this function are the
411 * actual distance to the intersect (i.e. not scaled). Distances may
412 * be negative, see below.
413 *
414 * @return -2 no intersection, lines are parallel.
415 * @return -1 no intersection
416 * @return 0 lines are co-linear (pdist and qdist returned) (see below)
417 * @return 1 intersection found (pdist and qdist returned) (see below)
418 *
419 * @param p0 point 1
420 * @param u direction 1
421 * @param q0 point 2
422 * @param v direction 2
423 * @param tol tolerance values
424 * @param[out] s (distances to intersection) (see below)
425 * @param[out] t (distances to intersection) (see below)
426 *
427 * When return = 1, pdist is the distance along line p0->p1 to the
428 * intersect with line q0->q1. If the intersect is along p0->p1 but
429 * in the opposite direction of vector pdir_i (i.e. occurring before
430 * p0 on line p0->p1) then the distance will be negative. The value
431 * if qdist is the same as pdist except it is the distance along line
432 * q0->q1 to the intersect with line p0->p1.
433 *
434 * When return code = 0 for co-linearity, pdist and qdist have a
435 * different meaning. pdist is the distance from point p0 to point q0
436 * and qdist is the distance from point p0 to point q1. If point q0
437 * occurs before point p0 on line segment p0->p1 then pdist will be
438 * negative. The same occurs for the distance to point q1.
439 */
440BG_EXPORT extern int bg_isect_line3_line3(fastf_t *s, fastf_t *t,
441 const point_t p0,
442 const vect_t u,
443 const point_t q0,
444 const vect_t v,
445 const struct bn_tol *tol);
446
447/**
448 * @brief
449 * Returns non-zero if the 3 lines are collinear to within tol->dist
450 * over the given distance range.
451 *
452 * Range should be at least one model diameter for most applications.
453 * 1e5 might be OK for a default for "vehicle sized" models.
454 *
455 * The direction vectors do not need to be unit length.
456 */
457BG_EXPORT extern int bg_2line3_colinear(const point_t p1,
458 const vect_t d1,
459 const point_t p2,
460 const vect_t d2,
461 double range,
462 const struct bn_tol *tol);
463
464/**
465 * @brief
466 * Intersect a point P with the line segment defined by two distinct
467 * points A and B.
468 *
469 * @return -2 P on line AB but outside range of AB,
470 * dist = distance from A to P on line.
471 * @return -1 P not on line of AB within tolerance
472 * @return 1 P is at A
473 * @return 2 P is at B
474 * @return 3 P is on AB, dist = distance from A to P on line.
475 @verbatim
476 B *
477 |
478 P'*-tol-*P
479 | / _
480 dist / /|
481 | / /
482 | / / AtoP
483 |/ /
484 A * /
485
486 tol = distance limit from line to pt P;
487 dist = distance from A to P'
488 @endverbatim
489*/
490BG_EXPORT extern int bg_isect_pnt2_lseg2(fastf_t *dist,
491 const point_t a,
492 const point_t b,
493 const point_t p,
494 const struct bn_tol *tol);
495
496/**
497 *@brief
498 * Intersect a line in parametric form:
499 *
500 * X = P + t * D
501 *
502 * with a line segment defined by two distinct points A and B=(A+C).
503 *
504 * XXX probably should take point B, not vector C. Sigh.
505 *
506 * @return -4 A and B are not distinct points
507 * @return -3 Lines do not intersect
508 * @return -2 Intersection exists, but outside segment, < A
509 * @return -1 Intersection exists, but outside segment, > B
510 * @return 0 Lines are co-linear (special meaning of dist[1])
511 * @return 1 Intersection at vertex A
512 * @return 2 Intersection at vertex B (A+C)
513 * @return 3 Intersection between A and B
514 *
515 * Implicit Returns -
516 * @param dist When explicit return >= 0, t is the parameter that describes
517 * the intersection of the line and the line segment.
518 * The actual intersection coordinates can be found by
519 * solving P + t * D. However, note that for return codes
520 * 1 and 2 (intersection exactly at a vertex), it is
521 * strongly recommended that the original values passed in
522 * A or B are used instead of solving P + t * D, to prevent
523 * numeric error from creeping into the position of
524 * the endpoints.
525 *
526 * @param p point of first line
527 * @param d direction of first line
528 * @param a point of second line
529 * @param c direction of second line
530 * @param tol tolerance values
531 */
532BG_EXPORT extern int bg_isect_line2_lseg2(fastf_t *dist,
533 const point_t p,
534 const vect_t d,
535 const point_t a,
536 const vect_t c,
537 const struct bn_tol *tol);
538
539/**
540 *@brief
541 * Intersect two 2D line segments, defined by two points and two
542 * vectors. The vectors are unlikely to be unit length.
543 *
544 * @return -2 missed (line segments are parallel)
545 * @return -1 missed (collinear and non-overlapping)
546 * @return 0 hit (line segments collinear and overlapping)
547 * @return 1 hit (normal intersection)
548 *
549 * @param dist The value at dist[] is set to the parametric distance of the
550 * intercept.
551 *@n dist[0] is parameter along p, range 0 to 1, to intercept.
552 *@n dist[1] is parameter along q, range 0 to 1, to intercept.
553 *@n If within distance tolerance of the endpoints, these will be
554 * exactly 0.0 or 1.0, to ease the job of caller.
555 *
556 * Special note: when return code is "0" for co-linearity, dist[1] has
557 * an alternate interpretation: it's the parameter along p (not q)
558 * which takes you from point p to the point (q + qdir), i.e., its
559 * the endpoint of the q linesegment, since in this case there may be
560 * *two* intersections, if q is contained within span p to (p + pdir).
561 * And either may be -10 if the point is outside the span.
562 *
563 * @param p point 1
564 * @param pdir direction1
565 * @param q point 2
566 * @param qdir direction2
567 * @param tol tolerance values
568 */
569BG_EXPORT extern int bg_isect_lseg2_lseg2(fastf_t *dist,
570 const point_t p,
571 const vect_t pdir,
572 const point_t q,
573 const vect_t qdir,
574 const struct bn_tol *tol);
575
576/**
577 * Intersect two lines, each in given in parametric form:
578 @verbatim
579
580 X = P + t * D
581 and
582 X = A + u * C
583
584 @endverbatim
585 *
586 * While the parametric form is usually used to denote a ray (i.e.,
587 * positive values of the parameter only), in this case the full line
588 * is considered.
589 *
590 * The direction vectors C and D need not have unit length.
591 *
592 * @return -1 no intersection, lines are parallel.
593 * @return 0 lines are co-linear
594 *@n dist[0] gives distance from P to A,
595 *@n dist[1] gives distance from P to (A+C) [not same as below]
596 * @return 1 intersection found (t and u returned)
597 *@n dist[0] gives distance from P to isect,
598 *@n dist[1] gives distance from A to isect.
599 *
600 * @param dist When explicit return > 0, dist[0] and dist[1] are the
601 * line parameters of the intersection point on the 2 rays. The
602 * actual intersection coordinates can be found by substituting either
603 * of these into the original ray equations.
604 *
605 * @param p point of first line
606 * @param d direction of first line
607 * @param a point of second line
608 * @param c direction of second line
609 * @param tol tolerance values
610 *
611 * Note that for lines which are very nearly parallel, but not quite
612 * parallel enough to have the determinant go to "zero", the
613 * intersection can turn up in surprising places. (e.g. when
614 * det=1e-15 and det1=5.5e-17, t=0.5)
615 */
616BG_EXPORT extern int bg_isect_line2_line2(fastf_t *dist,
617 const point_t p,
618 const vect_t d,
619 const point_t a,
620 const vect_t c,
621 const struct bn_tol *tol);
622
623/**
624 * @brief
625 * Returns distance between two points.
626 */
627BG_EXPORT extern double bg_dist_pnt3_pnt3(const point_t a,
628 const point_t b);
629
630/**
631 * Check to see if three points are all distinct, i.e., ensure that
632 * there is at least sqrt(dist_tol_sq) distance between every pair of
633 * points.
634 *
635 * @return 1 If all three points are distinct
636 * @return 0 If two or more points are closer together than dist_tol_sq
637 */
638BG_EXPORT extern int bg_3pnts_distinct(const point_t a,
639 const point_t b,
640 const point_t c,
641 const struct bn_tol *tol);
642
643/**
644 * Check to see if the points are all distinct, i.e., ensure that
645 * there is at least sqrt(dist_tol_sq) distance between every pair of
646 * points.
647 *
648 * @return 1 If all the points are distinct
649 * @return 0 If two or more points are closer together than dist_tol_sq
650 */
651BG_EXPORT extern int bg_npnts_distinct(const int npts,
652 const point_t *pts,
653 const struct bn_tol *tol);
654
655/**
656 * Find the equation of a plane that contains three points. Note that
657 * normal vector created is expected to point out (see vmath.h), so
658 * the vector from A to C had better be counter-clockwise (about the
659 * point A) from the vector from A to B. This follows the BRL-CAD
660 * outward-pointing normal convention, and the right-hand rule for
661 * cross products.
662 *
663 @verbatim
664 *
665 * C
666 * *
667 * |\
668 * | \
669 * ^ N | \
670 * | \ | \
671 * | \ | \
672 * |C-A \ | \
673 * | \ | \
674 * | \ | \
675 * \| \
676 * *---------*
677 * A B
678 * ----->
679 * B-A
680 @endverbatim
681 *
682 * If the points are given in the order A B C (e.g.,
683 * *counter*-clockwise), then the outward pointing surface normal:
684 *
685 * N = (B-A) x (C-A).
686 *
687 * @return 0 OK
688 * @return -1 Failure. At least two of the points were not distinct,
689 * or all three were collinear.
690 *
691 * @param[out] plane The plane equation is stored here.
692 * @param[in] a point 1
693 * @param[in] b point 2
694 * @param[in] c point 3
695 * @param[in] tol Tolerance values for doing calculation
696 */
697BG_EXPORT extern int bg_make_plane_3pnts(plane_t plane,
698 const point_t a,
699 const point_t b,
700 const point_t c,
701 const struct bn_tol *tol);
702
703/**
704 *@brief
705 * Given the description of three planes, compute the point of intersection, if
706 * any. The direction vectors of the planes need not be of unit length.
707 *
708 * Find the solution to a system of three equations in three unknowns:
709 @verbatim
710 * Px * Ax + Py * Ay + Pz * Az = -A3;
711 * Px * Bx + Py * By + Pz * Bz = -B3;
712 * Px * Cx + Py * Cy + Pz * Cz = -C3;
713 *
714 * OR
715 *
716 * [ Ax Ay Az ] [ Px ] [ -A3 ]
717 * [ Bx By Bz ] * [ Py ] = [ -B3 ]
718 * [ Cx Cy Cz ] [ Pz ] [ -C3 ]
719 *
720 @endverbatim
721 *
722 * @return 0 OK
723 * @return -1 Failure. Intersection is a line or plane.
724 *
725 * @param[out] pt The point of intersection is stored here.
726 * @param a plane 1
727 * @param b plane 2
728 * @param c plane 3
729 */
730
731BG_EXPORT extern int bg_make_pnt_3planes(point_t pt,
732 const plane_t a,
733 const plane_t b,
734 const plane_t c);
735
736/**
737 * Intersect an infinite line (specified in point and direction vector
738 * form) with a plane that has an outward pointing normal. The
739 * direction vector need not have unit length. The first three
740 * elements of the plane equation must form a unit length vector.
741 *
742 * @return -2 missed (ray is outside halfspace)
743 * @return -1 missed (ray is inside)
744 * @return 0 line lies on plane
745 * @return 1 hit (ray is entering halfspace)
746 * @return 2 hit (ray is leaving)
747 *
748 * @param[out] dist set to the parametric distance of the intercept
749 * @param[in] pt origin of ray
750 * @param[in] dir direction of ray
751 * @param[in] plane equation of plane
752 * @param[in] tol tolerance values
753 */
754BG_EXPORT extern int bg_isect_line3_plane(fastf_t *dist,
755 const point_t pt,
756 const vect_t dir,
757 const plane_t plane,
758 const struct bn_tol *tol);
759
760/**
761 *@brief
762 * Given two planes, find the line of intersection between them, if
763 * one exists. The line of intersection is returned in parametric
764 * line (point & direction vector) form.
765 *
766 * In order that all the geometry under consideration be in "front" of
767 * the ray, it is necessary to pass the minimum point of the model
768 * RPP. If this convention is unnecessary, just pass (0, 0, 0) as
769 * rpp_min.
770 *
771 * @return 0 success, line of intersection stored in 'pt' and 'dir'
772 * @return -1 planes are coplanar
773 * @return -2 planes are parallel but not coplanar
774 * @return -3 error, should be intersection but unable to find
775 *
776 * @param[out] pt Starting point of line of intersection
777 * @param[out] dir Direction vector of line of intersection (unit length)
778 * @param[in] a plane 1 (normal must be unit length)
779 * @param[in] b plane 2 (normal must be unit length)
780 * @param[in] rpp_min minimum point of model RPP
781 * @param[in] tol tolerance values
782 */
783BG_EXPORT extern int bg_isect_2planes(point_t pt,
784 vect_t dir,
785 const plane_t a,
786 const plane_t b,
787 const vect_t rpp_min,
788 const struct bn_tol *tol);
789BG_EXPORT extern int bg_isect_2lines(fastf_t *t,
790 fastf_t *u,
791 const point_t p,
792 const vect_t d,
793 const point_t a,
794 const vect_t c,
795 const struct bn_tol *tol);
796
797/**
798 *@brief
799 * Intersect a line in parametric form:
800 *
801 * X = P + t * D
802 *
803 * with a line segment defined by two distinct points A and B.
804 *
805 *
806 * @return -4 A and B are not distinct points
807 * @return -3 Intersection exists, < A (t is returned)
808 * @return -2 Intersection exists, > B (t is returned)
809 * @return -1 Lines do not intersect
810 * @return 0 Lines are co-linear (t for A is returned)
811 * @return 1 Intersection at vertex A
812 * @return 2 Intersection at vertex B
813 * @return 3 Intersection between A and B
814 *
815 * @par Implicit Returns -
816 *
817 * t When explicit return >= 0, t is the parameter that describes the
818 * intersection of the line and the line segment. The actual
819 * intersection coordinates can be found by solving P + t * D.
820 * However, note that for return codes 1 and 2 (intersection exactly
821 * at a vertex), it is strongly recommended that the original values
822 * passed in A or B are used instead of solving P + t * D, to prevent
823 * numeric error from creeping into the position of the endpoints.
824 *
825 * XXX should probably be called bg_isect_line3_lseg3()
826 * XXX should probably be changed to return dist[2]
827 */
828BG_EXPORT extern int bg_isect_line_lseg(fastf_t *t, const point_t p,
829 const vect_t d,
830 const point_t a,
831 const point_t b,
832 const struct bn_tol *tol);
833
834/**
835 * Given a parametric line defined by PT + t * DIR and a point A,
836 * return the closest distance between the line and the point.
837 *
838 * 'dir' need not have unit length.
839 *
840 * Find parameter for PCA along line with unitized DIR:
841 * d = VDOT(f, dir) / MAGNITUDE(dir);
842 * Find distance g from PCA to A using Pythagoras:
843 * g = sqrt(MAGSQ(f) - d**2)
844 *
845 * Return -
846 * Distance
847 */
848BG_EXPORT extern double bg_dist_line3_pnt3(const point_t pt,
849 const vect_t dir,
850 const point_t a);
851
852/**
853 * Given a parametric line defined by PT + t * DIR and a point A,
854 * return the square of the closest distance between the line and the
855 * point.
856 *
857 * 'dir' need not have unit length.
858 *
859 * Return -
860 * Distance squared
861 */
862BG_EXPORT extern double bg_distsq_line3_pnt3(const point_t pt,
863 const vect_t dir,
864 const point_t a);
865
866/**
867 *@brief
868 * Given a parametric line defined by PT + t * DIR, return the closest
869 * distance between the line and the origin.
870 *
871 * 'dir' need not have unit length.
872 *
873 * @return Distance
874 */
875BG_EXPORT extern double bg_dist_line_origin(const point_t pt,
876 const vect_t dir);
877
878/**
879 *@brief
880 * Given a parametric line defined by PT + t * DIR and a point A,
881 * return the closest distance between the line and the point.
882 *
883 * 'dir' need not have unit length.
884 *
885 * @return Distance
886 */
887BG_EXPORT extern double bg_dist_line2_point2(const point_t pt,
888 const vect_t dir,
889 const point_t a);
890
891/**
892 *@brief
893 * Given a parametric line defined by PT + t * DIR and a point A,
894 * return the closest distance between the line and the point,
895 * squared.
896 *
897 * 'dir' need not have unit length.
898 *
899 * @return
900 * Distance squared
901 */
902BG_EXPORT extern double bg_distsq_line2_point2(const point_t pt,
903 const vect_t dir,
904 const point_t a);
905
906/**
907 *@brief
908 * Returns the area of a triangle. Algorithm by Jon Leech 3/24/89.
909 */
910BG_EXPORT extern double bg_area_of_triangle(const point_t a,
911 const point_t b,
912 const point_t c);
913
914/**
915 *@brief
916 * Intersect a point P with the line segment defined by two distinct
917 * points A and B.
918 *
919 * @return -2 P on line AB but outside range of AB,
920 * dist = distance from A to P on line.
921 * @return -1 P not on line of AB within tolerance
922 * @return 1 P is at A
923 * @return 2 P is at B
924 * @return 3 P is on AB, dist = distance from A to P on line.
925 @verbatim
926 B *
927 |
928 P'*-tol-*P
929 | / _
930 dist / /|
931 | / /
932 | / / AtoP
933 |/ /
934 A * /
935
936 tol = distance limit from line to pt P;
937 dist = parametric distance from A to P' (in terms of A to B)
938 @endverbatim
939 *
940 * @param p point
941 * @param a start of lseg
942 * @param b end of lseg
943 * @param tol tolerance values
944 * @param[out] dist parametric distance from A to P' (in terms of A to B)
945 */
946BG_EXPORT extern int bg_isect_pnt_lseg(fastf_t *dist,
947 const point_t a,
948 const point_t b,
949 const point_t p,
950 const struct bn_tol *tol);
951
952BG_EXPORT extern double bg_dist_pnt_lseg(point_t pca,
953 const point_t a,
954 const point_t b,
955 const point_t p,
956 const struct bn_tol *tol);
957
958/**
959 *@brief
960 * Transform a bounding box (RPP) by the given 4x4 matrix. There are
961 * 8 corners to the bounding RPP. Each one needs to be transformed
962 * and min/max'ed. This is not minimal, but does fully contain any
963 * internal object, using an axis-aligned RPP.
964 */
965BG_EXPORT extern void bg_rotate_bbox(point_t omin,
966 point_t omax,
967 const mat_t mat,
968 const point_t imin,
969 const point_t imax);
970
971/**
972 *@brief
973 * Transform a plane equation by the given 4x4 matrix.
974 */
975BG_EXPORT extern void bg_rotate_plane(plane_t oplane,
976 const mat_t mat,
977 const plane_t iplane);
978
979/**
980 *@brief
981 * Test if two planes are identical. If so, their dot products will
982 * be either +1 or -1, with the distance from the origin equal in
983 * magnitude.
984 *
985 * @return -1 not coplanar, parallel but distinct
986 * @return 0 not coplanar, not parallel. Planes intersect.
987 * @return 1 coplanar, same normal direction
988 * @return 2 coplanar, opposite normal direction
989 */
990BG_EXPORT extern int bg_coplanar(const plane_t a,
991 const plane_t b,
992 const struct bn_tol *tol);
993
994
995
996/**
997 *@brief
998 * Test if a set of points are coplanar. Note: if 0 < pt_cnt <=3 the point(s)
999 * are trivially coplanar, and 1 will be returned.
1000 *
1001 * @return -1 error
1002 * @return 0 not coplanar
1003 * @return 1 coplanar
1004 */
1005BG_EXPORT extern int bg_coplanar_pts(const point_t *pts,
1006 int pt_cnt,
1007 const struct bn_tol *tol);
1008
1009
1010/**
1011 * Using two perpendicular vectors (x_dir and y_dir) which lie in the
1012 * same plane as 'vec', return the angle (in radians) of 'vec' from
1013 * x_dir, going CCW around the perpendicular x_dir CROSS y_dir.
1014 *
1015 * Trig note -
1016 *
1017 * theta = atan2(x, y) returns an angle in the range -pi to +pi.
1018 * Here, we need an angle in the range of 0 to 2pi. This could be
1019 * implemented by adding 2pi to theta when theta is negative, but this
1020 * could have nasty numeric ambiguity right in the vicinity of theta =
1021 * +pi, which is a very critical angle for the applications using this
1022 * routine.
1023 *
1024 * So, an alternative formulation is to compute gamma = atan2(-x, -y),
1025 * and then theta = gamma + pi. Now, any error will occur in the
1026 * vicinity of theta = 0, which can be handled much more readily.
1027 *
1028 * If theta is negative, or greater than two pi, wrap it around.
1029 * These conditions only occur if there are problems in atan2().
1030 *
1031 * @return vec == x_dir returns 0,
1032 * @return vec == y_dir returns pi/2,
1033 * @return vec == -x_dir returns pi,
1034 * @return vec == -y_dir returns 3*pi/2.
1035 *
1036 * In all cases, the returned value is between 0 and bg_twopi.
1037 */
1038BG_EXPORT extern double bg_angle_measure(vect_t vec,
1039 const vect_t x_dir,
1040 const vect_t y_dir);
1041
1042/**
1043 *@brief
1044 * Return the parametric distance t of a point X along a line defined
1045 * as a ray, i.e. solve X = P + t * D. If the point X does not lie on
1046 * the line, then t is the distance of the perpendicular projection of
1047 * point X onto the line.
1048 */
1049BG_EXPORT extern double bg_dist_pnt3_along_line3(const point_t p,
1050 const vect_t d,
1051 const point_t x);
1052
1053/**
1054 *@brief
1055 * Return the parametric distance t of a point X along a line defined
1056 * as a ray, i.e. solve X = P + t * D. If the point X does not lie on
1057 * the line, then t is the distance of the perpendicular projection of
1058 * point X onto the line.
1059 */
1060BG_EXPORT extern double bg_dist_pnt2_along_line2(const point_t p,
1061 const vect_t d,
1062 const point_t x);
1063
1064/**
1065 *
1066 * @return 1 if left <= mid <= right
1067 * @return 0 if mid is not in the range.
1068 */
1069BG_EXPORT extern int bg_between(double left,
1070 double mid,
1071 double right,
1072 const struct bn_tol *tol);
1073
1074/**
1075 * @return 0 No intersection
1076 * @return 1 Intersection, 'inter' has intersect point.
1077 */
1078BG_EXPORT extern int bg_does_ray_isect_tri(const point_t pt,
1079 const vect_t dir,
1080 const point_t V,
1081 const point_t A,
1082 const point_t B,
1083 point_t inter);
1084
1085/**
1086 *@brief
1087 * Classify a halfspace, specified by its plane equation, against a
1088 * bounding RPP.
1089 *
1090 * @return BG_CLASSIFY_INSIDE
1091 * @return BG_CLASSIFY_OVERLAPPING
1092 * @return BG_CLASSIFY_OUTSIDE
1093 */
1094BG_EXPORT extern int bg_hlf_class(const plane_t half_eqn,
1095 const vect_t min, const vect_t max,
1096 const struct bn_tol *tol);
1097
1098
1099#define BG_CLASSIFY_UNIMPLEMENTED 0x0000
1100#define BG_CLASSIFY_INSIDE 0x0001
1101#define BG_CLASSIFY_OVERLAPPING 0x0002
1102#define BG_CLASSIFY_OUTSIDE 0x0003
1103
1104
1105/**
1106 *@brief
1107 * Calculates the point that is the minimum distance from all the
1108 * planes in the "planes" array. If the planes intersect at a single
1109 * point, that point is the solution.
1110 *
1111 * The method used here is based on:
1112
1113 * An expression for the distance from a point to a plane is:
1114 * VDOT(pt, plane)-plane[H].
1115 * Square that distance and sum for all planes to get the "total"
1116 * distance.
1117 * For minimum total distance, the partial derivatives of this
1118 * expression (with respect to x, y, and z) must all be zero.
1119 * This produces a set of three equations in three unknowns (x, y, z).
1120
1121 * This routine sets up the three equations as [matrix][pt] = [hpq]
1122 * and solves by inverting "matrix" into "inverse" and
1123 * [pt] = [inverse][hpq].
1124 *
1125 * There is likely a more economical solution rather than matrix
1126 * inversion, but bg_mat_inv was handy at the time.
1127 *
1128 * Checks if these planes form a singular matrix and returns.
1129 *
1130 * @return 0 - all is well
1131 * @return 1 - planes form a singular matrix (no solution)
1132 */
1133BG_EXPORT extern int bg_isect_planes(point_t pt,
1134 const plane_t planes[],
1135 const size_t pl_count);
1136
1137
1138/**
1139 * @brief
1140 * Given an origin and a normal, create a plane_t.
1141 */
1142BG_EXPORT extern int bg_plane_pt_nrml(plane_t *p, point_t pt, vect_t nrml);
1143
1144/**
1145 * @brief
1146 * Calculates the best fit plane for a set of points
1147 *
1148 * Use SVD algorithm from Soderkvist to fit a plane to vertex points
1149 * https://www.ltu.se/cms_fs/1.51590!/svd-fitting.pdf
1150 *
1151 * Returns a center point and a normal direction for the plane
1152 */
1153BG_EXPORT extern int bg_fit_plane(point_t *c, vect_t *n, size_t npnts, point_t *pnts);
1154
1155/**
1156 * @brief
1157 * Find the closest U,V point on the plane p to 3d point pt.
1158 */
1159BG_EXPORT extern int bg_plane_closest_pt(fastf_t *u, fastf_t *v, plane_t p, point_t pt);
1160
1161/**
1162 * @brief
1163 * Return the 3D point on the plane at parametric coordinates u, v.
1164 */
1165BG_EXPORT extern int bg_plane_pt_at(point_t *pt, plane_t p, fastf_t u, fastf_t v);
1166
1167
1168
1169__END_DECLS
1170
1171#endif /* BG_PLANE_H */
1172/** @} */
1173/*
1174 * Local Variables:
1175 * mode: C
1176 * tab-width: 8
1177 * indent-tabs-mode: t
1178 * c-file-style: "stroustrup"
1179 * End:
1180 * ex: shiftwidth=4 tabstop=8
1181 */
Header file for the BRL-CAD common definitions.
int bg_make_pnt_3planes(point_t pt, const plane_t a, const plane_t b, const plane_t c)
Given the description of three planes, compute the point of intersection, if any. The direction vecto...
int bg_pnt3_pnt3_equal(const point_t a, const point_t b, const struct bn_tol *tol)
int bg_isect_line3_line3(fastf_t *s, fastf_t *t, const point_t p0, const vect_t u, const point_t q0, const vect_t v, const struct bn_tol *tol)
int bg_plane_pt_nrml(plane_t *p, point_t pt, vect_t nrml)
Given an origin and a normal, create a plane_t.
int bg_isect_line_lseg(fastf_t *t, const point_t p, const vect_t d, const point_t a, const point_t b, const struct bn_tol *tol)
Intersect a line in parametric form:
int bg_coplanar(const plane_t a, const plane_t b, const struct bn_tol *tol)
Test if two planes are identical. If so, their dot products will be either +1 or -1,...
double bg_dist_pnt3_along_line3(const point_t p, const vect_t d, const point_t x)
Return the parametric distance t of a point X along a line defined as a ray, i.e. solve X = P + t * D...
int bg_isect_2lines(fastf_t *t, fastf_t *u, const point_t p, const vect_t d, const point_t a, const vect_t c, const struct bn_tol *tol)
int bg_plane_closest_pt(fastf_t *u, fastf_t *v, plane_t p, point_t pt)
Find the closest U,V point on the plane p to 3d point pt.
int bg_isect_planes(point_t pt, const plane_t planes[], const size_t pl_count)
Calculates the point that is the minimum distance from all the planes in the "planes" array....
double bg_dist_line_origin(const point_t pt, const vect_t dir)
Given a parametric line defined by PT + t * DIR, return the closest distance between the line and the...
int bg_distsq_pnt3_lseg3_v2(fastf_t *distsq, const fastf_t *a, const fastf_t *b, const fastf_t *p, const struct bn_tol *tol)
int bg_isect_line3_plane(fastf_t *dist, const point_t pt, const vect_t dir, const plane_t plane, const struct bn_tol *tol)
void bg_rotate_plane(plane_t oplane, const mat_t mat, const plane_t iplane)
Transform a plane equation by the given 4x4 matrix.
double bg_dist_line2_point2(const point_t pt, const vect_t dir, const point_t a)
Given a parametric line defined by PT + t * DIR and a point A, return the closest distance between th...
double bg_dist_pnt2_along_line2(const point_t p, const vect_t d, const point_t x)
Return the parametric distance t of a point X along a line defined as a ray, i.e. solve X = P + t * D...
double bg_dist_pnt3_pnt3(const point_t a, const point_t b)
Returns distance between two points.
int bg_hlf_class(const plane_t half_eqn, const vect_t min, const vect_t max, const struct bn_tol *tol)
Classify a halfspace, specified by its plane equation, against a bounding RPP.
double bg_area_of_triangle(const point_t a, const point_t b, const point_t c)
Returns the area of a triangle. Algorithm by Jon Leech 3/24/89.
int bg_3pnts_distinct(const point_t a, const point_t b, const point_t c, const struct bn_tol *tol)
int bg_lseg3_lseg3_parallel(const point_t sg1pt1, const point_t sg1pt2, const point_t sg2pt1, const point_t sg2pt2, const struct bn_tol *tol)
int bg_make_plane_3pnts(plane_t plane, const point_t a, const point_t b, const point_t c, const struct bn_tol *tol)
double bg_dist_pnt_lseg(point_t pca, const point_t a, const point_t b, const point_t p, const struct bn_tol *tol)
int bg_2line3_colinear(const point_t p1, const vect_t d1, const point_t p2, const vect_t d2, double range, const struct bn_tol *tol)
Returns non-zero if the 3 lines are collinear to within tol->dist over the given distance range.
int bg_isect_pnt2_lseg2(fastf_t *dist, const point_t a, const point_t b, const point_t p, const struct bn_tol *tol)
Intersect a point P with the line segment defined by two distinct points A and B.
#define MAXPTS
Definition: plane.h:45
int bg_3pnts_collinear(point_t a, point_t b, point_t c, const struct bn_tol *tol)
Check to see if three points are collinear.
double bg_distsq_line3_pnt3(const point_t pt, const vect_t dir, const point_t a)
double bg_dist_line3_pnt3(const point_t pt, const vect_t dir, const point_t a)
int bg_isect_lseg2_lseg2(fastf_t *dist, const point_t p, const vect_t pdir, const point_t q, const vect_t qdir, const struct bn_tol *tol)
Intersect two 2D line segments, defined by two points and two vectors. The vectors are unlikely to be...
int bg_between(double left, double mid, double right, const struct bn_tol *tol)
void bg_rotate_bbox(point_t omin, point_t omax, const mat_t mat, const point_t imin, const point_t imax)
Transform a bounding box (RPP) by the given 4x4 matrix. There are 8 corners to the bounding RPP....
int bg_fit_plane(point_t *c, vect_t *n, size_t npnts, point_t *pnts)
Calculates the best fit plane for a set of points.
int bg_dist_pnt2_lseg2(fastf_t *dist_sq, fastf_t pca[2], const point_t a, const point_t b, const point_t p, const struct bn_tol *tol)
Find the distance from a point P to a line segment described by the two endpoints A and B,...
int bg_coplanar_pts(const point_t *pts, int pt_cnt, const struct bn_tol *tol)
Test if a set of points are coplanar. Note: if 0 < pt_cnt <=3 the point(s) are trivially coplanar,...
int bg_dist_pnt3_lseg3(fastf_t *dist, point_t pca, const point_t a, const point_t b, const point_t p, const struct bn_tol *tol)
Find the distance from a point P to a line segment described by the two endpoints A and B,...
int bg_does_ray_isect_tri(const point_t pt, const vect_t dir, const point_t V, const point_t A, const point_t B, point_t inter)
int bg_isect_line2_line2(fastf_t *dist, const point_t p, const vect_t d, const point_t a, const vect_t c, const struct bn_tol *tol)
int bg_isect_line2_lseg2(fastf_t *dist, const point_t p, const vect_t d, const point_t a, const vect_t c, const struct bn_tol *tol)
Intersect a line in parametric form:
double bg_angle_measure(vect_t vec, const vect_t x_dir, const vect_t y_dir)
int bg_npnts_distinct(const int npts, const point_t *pts, const struct bn_tol *tol)
double bg_distsq_line2_point2(const point_t pt, const vect_t dir, const point_t a)
Given a parametric line defined by PT + t * DIR and a point A, return the closest distance between th...
int bg_isect_pnt_lseg(fastf_t *dist, const point_t a, const point_t b, const point_t p, const struct bn_tol *tol)
Intersect a point P with the line segment defined by two distinct points A and B.
int bg_dist_line3_lseg3(fastf_t *dist, const fastf_t *p, const fastf_t *d, const fastf_t *a, const fastf_t *b, const struct bn_tol *tol)
int bg_plane_pt_at(point_t *pt, plane_t p, fastf_t u, fastf_t v)
Return the 3D point on the plane at parametric coordinates u, v.
int bg_isect_lseg3_lseg3(fastf_t *dist, const point_t p, const vect_t pdir, const point_t q, const vect_t qdir, const struct bn_tol *tol)
Intersect two 3D line segments, defined by two points and two vectors. The vectors are unlikely to be...
int bg_dist_pnt3_line3(fastf_t *dist, point_t pca, const point_t a, const point_t p, const vect_t dir, const struct bn_tol *tol)
int bg_distsq_line3_line3(fastf_t dist[3], point_t P, vect_t d, point_t Q, vect_t e, point_t pt1, point_t pt2)
Calculate the square of the distance of closest approach for two lines.
int bg_dist_line3_line3(fastf_t dist[2], const point_t p1, const point_t p2, const vect_t d1, const vect_t d2, const struct bn_tol *tol)
int bg_isect_2planes(point_t pt, vect_t dir, const plane_t a, const plane_t b, const vect_t rpp_min, const struct bn_tol *tol)
Given two planes, find the line of intersection between them, if one exists. The line of intersection...
void float float int * n
Definition: tig.h:74
void int char int int double * min
Definition: tig.h:182
void int * c
Definition: tig.h:139
void float * x
Definition: tig.h:72
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition: vmath.h:345
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition: vmath.h:366
fastf_t plane_t[ELEMENTS_PER_PLANE]
Definition of a plane equation.
Definition: vmath.h:393
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Definition: tol.h:72
char pl_code[MAXPTS+1]
Definition: plane.h:59
fastf_t pl_2d_x[MAXPTS]
Definition: plane.h:55
fastf_t pl_2d_com[MAXPTS]
Definition: plane.h:57
size_t pl_npts
Definition: plane.h:49
struct plane_specific * pl_forw
Definition: plane.h:58
vect_t pl_Xbasis
Definition: plane.h:51
vect_t pl_Ybasis
Definition: plane.h:52
fastf_t pl_NdotA
Definition: plane.h:54
point_t pl_points[MAXPTS]
Definition: plane.h:50
fastf_t pl_2d_y[MAXPTS]
Definition: plane.h:56
vect_t pl_N
Definition: plane.h:53
float tri_A[3]
Definition: plane.h:82
float tri_BA[3]
Definition: plane.h:83
signed char * tri_normals
Definition: plane.h:87
float tri_wn[3]
Definition: plane.h:85
float tri_N[3]
Definition: plane.h:86
struct tri_float_specific * tri_forw
Definition: plane.h:89
float tri_CA[3]
Definition: plane.h:84
int tri_surfno
Definition: plane.h:72
fastf_t * tri_normals
Definition: plane.h:71
vect_t tri_N
Definition: plane.h:70
vect_t tri_BA
Definition: plane.h:67
vect_t tri_CA
Definition: plane.h:68
vect_t tri_wn
Definition: plane.h:69
point_t tri_A
Definition: plane.h:66
struct tri_specific * tri_forw
Definition: plane.h:73
fundamental vector, matrix, quaternion math macros