This file is indexed.

/usr/include/geomview/point3.h is in libgeomview-dev 1.9.4-4.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
/* Copyright (C) 1992-1998 The Geometry Center
 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
 *
 * This file is part of Geomview.
 * 
 * Geomview is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * Geomview is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with Geomview; see the file COPYING.  If not, write
 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
 * USA, or visit http://www.gnu.org.
 */


/* Authors: Charlie Gunn, Pat Hanrahan, Stuart Levy, Tamara Munzner, Mark Phillips, Celeste Fowler */

#ifndef _GV_POINT3_H_
#define _GV_POINT3_H_

/*
**	point3.c - 3D vector arithmetic module.
**
**	pat hanrahan
**
** cH: now as inline functions for efficiency
**
*/
#include <stdio.h>
#include <math.h>
#include "tolerance.h"
#include "geomtypes.h"

#define Pt3X(pt) (pt)->x
#define Pt3Y(pt) (pt)->y
#define Pt3Z(pt) (pt)->z

extern
Pt3Coord SgSgDistance(Point3 *a1, Point3 *a2,
		      Point3 *b1, Point3 *b2);

static const Point3 Pt3Origin = { 0., 0., 0. };
static inline void Pt3Print(const Point3 *v);
static inline void Pt3From(Point3 *v, double x, double y, double z);
static inline void Pt3Copy(const Point3 *v1, Point3 *v2);
static inline void Pt3Add(const Point3 *v1, const Point3 *v2, Point3 *v3);
static inline void Pt3Sub(const Point3 *v1, const Point3 *v2, Point3 *v3);
static inline void Pt3Mul(double s, const Point3 *v1, Point3 *v2);
static inline Pt3Coord Pt3Dot(const Point3 *v1, const Point3 *v2);
static inline void Pt3Cross(const Point3 *v1, const Point3 *v2, Point3 *v3);
static inline Pt3Coord Pt3TripleDot(const Point3 *v1, const Point3 *v2,
				    const Point3 *v3);
static inline void Pt3TripleCross(const Point3 *v1, const Point3 *v2,
				  const Point3 *v3, Point3 *v4);
static inline Pt3Coord Pt3Length(const Point3 *v);
static inline Pt3Coord Pt3Distance(const Point3 *v1, const Point3 *v2);
static inline Pt3Coord Pt3Angle(const Point3 *v1, const Point3 *v2);
static inline void Pt3Unit(Point3 *v);
static inline void Pt3Lerp(double t,
			   const Point3 *v1, const Point3 *v2,  Point3 *v3);
static inline void Pt3Comb(double t1, const Point3 *v1,
			   double t2, const Point3 *v2, Point3 *v3);
static inline int Pt3Equal(const Point3 *v1, const Point3 *v2);
static inline int Pt3Parallel(const Point3 *v1, const Point3 *v2);
static inline int Pt3Perpendicular(const Point3 *v1, const Point3 *v2);
static inline void Pt3Transform(Transform3 T, Point3 *p1, Point3 *p2);
static inline void Pt3TransformN(Transform3 T, Point3 *p1, Point3 *p2, int n);
static inline void NormalTransform(Transform3 T, Point3 *a, Point3 *b);
static inline void NormalTransformN(Transform3 T, Point3 *a, Point3 *b, int n);

#include "transform3.h"

/* print vector */
static inline
void Pt3Print(const Point3 *v)
{
  /* Only works if Pt3Coord is a float */
  printf("[%g %g %g]\n", v->x, v->y, v->z);
}

static inline
void Pt3From(Point3 *v, double x, double y, double z)
{
  v->x = x;
  v->y = y;
  v->z = z;
}

/* v2 = v1 */
static inline
void Pt3Copy( const Point3 *v1, Point3 *v2 )
{
  v2->x = v1->x;
  v2->y = v1->y;
  v2->z = v1->z;
}

/* v3 = v1 + v2 */
static inline
void Pt3Add( const Point3 *v1, const Point3 *v2, Point3 *v3 )
{
  v3->x = v1->x + v2->x;
  v3->y = v1->y + v2->y;
  v3->z = v1->z + v2->z;
}

/* v3 = v1 - v2 */
static inline
void Pt3Sub( const Point3 *v1, const Point3 *v2, Point3 *v3)
{
  v3->x = v1->x - v2->x;
  v3->y = v1->y - v2->y;
  v3->z = v1->z - v2->z;
}

/* v2 = s * v1  */
static inline
void Pt3Mul( double s, const Point3 *v1, Point3 *v2 )
{
  v2->x = s*v1->x;
  v2->y = s*v1->y;
  v2->z = s*v1->z;
}


/* v1 . v2 */
static inline
Pt3Coord Pt3Dot( const Point3 *v1, const Point3 *v2 )
{
  return v1->x*v2->x+v1->y*v2->y+v1->z*v2->z;
}

/* v3 = v1 x v2 */
static inline
void Pt3Cross( const Point3 *v1, const Point3 *v2, Point3 *v3 )
{
  v3->x = v1->y*v2->z-v1->z*v2->y; 
  v3->y = v1->z*v2->x-v1->x*v2->z; 
  v3->z = v1->x*v2->y-v1->y*v2->x;
}

/* v1 . (v2 x v3) */
static inline
Pt3Coord Pt3TripleDot( const Point3 *v1, const Point3 *v2, const Point3 *v3 )
{
  return v1->x*(v2->y*v3->z-v2->z*v3->y) 
    + v1->y*(v2->z*v3->x-v2->x*v3->z) 
    + v1->z*(v2->x*v3->y-v2->y*v3->x);
}

/* v4 = (v1 x v2) x v3 */
static inline
void Pt3TripleCross( const Point3 *v1, const Point3 *v2, const Point3 *v3, Point3 *v4 )
{
  Point3 v;
 
  Pt3Cross( v1, v2, &v );
  Pt3Cross( &v, v3, v4 );
}

static inline
Pt3Coord Pt3Length( const Point3 *v )
{
  return sqrt( v->x*v->x + v->y*v->y + v->z*v->z );
}

static inline
Pt3Coord Pt3Distance( const Point3 *v1, const Point3 *v2 )
{
  Point3 v12;
	
  Pt3Sub(v1,v2,&v12);

  return Pt3Length(&v12);
}

static inline
Pt3Coord Pt3Angle( const Point3 *v1, const Point3 *v2 )
{

  return(acos(Pt3Dot(v1, v2) / (Pt3Length(v1) * Pt3Length(v2))));

}

static inline
void Pt3Unit( Point3 *v )
{
  Pt3Coord len;

  len = Pt3Length(v);
  if( len != 0. && len != 1. )
    Pt3Mul( 1./len, v, v );
}


/*
 * lerp - linear interpolation
 *
 * v3 = (1-t)*v1 + t*v2
 */
static inline
void Pt3Lerp( double t, const Point3 *v1, const Point3 *v2,  Point3 *v3 )
{
  v3->x = (1.-t)*v1->x + t*v2->x;
  v3->y = (1.-t)*v1->y + t*v2->y;
  v3->z = (1.-t)*v1->z + t*v2->z;
}

static inline
void Pt3Comb( double t1, const Point3 *v1, double t2, const Point3 *v2, Point3 *v3 )
{
  v3->x = t1*v1->x + t2*v2->x;
  v3->y = t1*v1->y + t2*v2->y;
  v3->z = t1*v1->z + t2*v2->z;
}


/* vectors equal */
static inline
int Pt3Equal( const Point3 *v1, const Point3 *v2 )
{
  Pt3Coord v;
	
  v = Pt3Distance(v1, v2);

  return fz(v);
}

/* parallel vectors */
static inline
int Pt3Parallel( const Point3 *v1, const Point3 *v2 )
{
  Point3 v3;
  Pt3Coord v;
	
  Pt3Cross(v1,v2,&v3);
  v=Pt3Length(&v3);

  return fz(v);
}

/* perpendicular vectors */
static inline
int Pt3Perpendicular( const Point3 *v1, const Point3 *v2 )
{
  Pt3Coord v;

  v=Pt3Dot(v1,v2);

  return fz(v);
}

static inline
void Pt3Transform( Transform3 T, Point3 *p1, Point3 *p2 )
{
  Pt3Coord x, y, z, w;

  x = p1->x;
  y = p1->y;
  z = p1->z;
  w = (T[TMX][TMW]*x + T[TMY][TMW]*y + T[TMZ][TMW]*z + T[TMW][TMW]);
  if(w != 1.0) {
    w = 1.0 / w;
    p2->x = w * (x*T[TMX][TMX] + y*T[TMY][TMX] + z*T[TMZ][TMX] + T[TMW][TMX]);
    p2->y = w * (x*T[TMX][TMY] + y*T[TMY][TMY] + z*T[TMZ][TMY] + T[TMW][TMY]);
    p2->z = w * (x*T[TMX][TMZ] + y*T[TMY][TMZ] + z*T[TMZ][TMZ] + T[TMW][TMZ]);
  } else {
    p2->x = x*T[TMX][TMX] + y*T[TMY][TMX] + z*T[TMZ][TMX] + T[TMW][TMX];
    p2->y = x*T[TMX][TMY] + y*T[TMY][TMY] + z*T[TMZ][TMY] + T[TMW][TMY];
    p2->z = x*T[TMX][TMZ] + y*T[TMY][TMZ] + z*T[TMZ][TMZ] + T[TMW][TMZ];
  }
}

static inline
void Pt3TransformN( Transform3 T, Point3 *p1, Point3 *p2, int n )
{
  while( n-- ) 
    Pt3Transform( T, p1++, p2++ );
}

/* Behold: if T is not orthogonal, then this function has to be called
 * with T^{-tr}, or the adj(T)^{tr}, otherwise the result will be
 * wrong.
 */
static inline
void NormalTransform(Transform3 Tdual, Point3 *a, Point3 *b)
{
#if 0
  Pt3Transform(T, a, b);
  b->x -= T[TMW][TMX];
  b->y -= T[TMW][TMY];
  b->z -= T[TMW][TMZ];
#else
  Pt3Coord x, y, z;

  x = a->x;
  y = a->y;
  z = a->z;
  b->x = x*Tdual[TMX][TMX] + y*Tdual[TMY][TMX] + z*Tdual[TMZ][TMX];
  b->y = x*Tdual[TMX][TMY] + y*Tdual[TMY][TMY] + z*Tdual[TMZ][TMY];
  b->z = x*Tdual[TMX][TMZ] + y*Tdual[TMY][TMZ] + z*Tdual[TMZ][TMZ];
#endif
  Pt3Unit(b);
}

static inline
void NormalTransformN( Transform3 T, Point3 *a, Point3 *b, int n )
{
  while ( n-- )
    NormalTransform( T, a++, b++ );
}


#endif /* _GV_POINT3_H_ */

/*
 * Local Variables: ***
 * c-basic-offset: 2 ***
 * End: ***
 */