File: intersect.c

package info (click to toggle)
glut 3.7-25
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge, squeeze
  • size: 13,036 kB
  • ctags: 47,177
  • sloc: ansic: 148,716; makefile: 44,180; ada: 2,062; yacc: 473; fortran: 290; lex: 131; csh: 52; sed: 49
file content (67 lines) | stat: -rw-r--r-- 2,264 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * FUNCTION:
 * This file contains a number of utilities useful to 3D graphics in
 * general, and to the generation of tubing and extrusions in particular
 * 
 * HISTORY:
 * Written by Linas Vepstas, August 1991
 */

#include "gutil.h"
#include "intersect.h"

/* ========================================================== */
/* 
 * The macro and subroutine INTERSECT are designed to compute the
 * intersection of a line (defined by the points v1 and v2) and a plane
 * (defined as plane which is normal to the vector n, and contains the
 * point p).  Both sect the array "sect", which is the point of
 * interesection.
 * 
 * The subroutine returns a value indicating if the specified inputs
 * represented a degenerate case. Valid is TRUE if the computed
 * intersection is valid, else it is FALSE.
 */


/* ========================================================== */

void intersect (gleDouble sect[3],	/* returned */
                gleDouble p[3],	/* input */
                gleDouble n[3],	/* input */
                gleDouble v1[3],	/* input */
                gleDouble v2[3])	/* input */
{
   INTERSECT (sect, p, n, v1, v2);
}

/* ========================================================== */
/* 
 * The macro and subroutine BISECTING_PLANE compute a normal vecotr that
 * describes the bisecting plane between three points (v1, v2 and v3).  
 * This bisecting plane has the following properties:
 * 1) it contains the point v2
 * 2) the angle it makes with v21 == v2 - v1 is equal to the angle it 
 *    makes with v32 == v3 - v2 
 * 3) it is perpendicular to the plane defined by v1, v2, v3.
 *
 * Having input v1, v2, and v3, it returns a vector n.
 * Note that n is NOT normalized (is NOT of unit length).
 * 
 * The subroutine returns a value indicating if the specified inputs
 * represented a degenerate case. Valid is TRUE if the computed
 * intersection is valid, else it is FALSE.
 */

int bisecting_plane (gleDouble n[3],	/* returned */
                      gleDouble v1[3],	/* input */
                      gleDouble v2[3],	/* input */
                      gleDouble v3[3])	/* input */
{
   int valid;

   BISECTING_PLANE (valid, n, v1, v2, v3);
   return (valid);
}

/* ========================================================== */