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
|
#if 0
//<copyright>
//
// Copyright (c) 1992,93,94,95,96,97
// Institute for Information Processing and Computer Supported New Media (IICM),
// Graz University of Technology, Austria.
//
// This file is part of VRweb.
//
// VRweb is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// VRweb 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with VRweb; see the file LICENCE. If not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
//</copyright>
#endif
/*
* File: vectors.h
*
* Author: Michael Hofer (until May 92) and Michael Pichler
*
* Created: 12 Mar 92
*
* Changed: 21 Feb 97 Michael Pichler
*
* $Id: vectors.h,v 1.3 1997/03/06 13:21:37 mpichler Exp $
*
*/
#ifndef ge3d_vectors_h
#define ge3d_vectors_h
typedef struct
{ float x, y;
} point2D, vector2D;
typedef struct
{ float x, y, z;
} vector3D, point3D;
typedef float matrix4D [4][4];
/* this was defined as "matrix" in earlier versions,
* but has been changed to "matrix4D" to avoid conflicts
* with other libraries using the type "matrix"
*/
/* macros for 3D-vector operations */
/* comments in pseudo language */
/* initialisation/assignment. p := (X, Y, Z) */
#define init3D(p, X, Y, Z) \
(p).x = (X), (p).y = (Y), (p).z = (Z)
/* initialisation/assignment. p := (X, Y) */
#define init2D(p, X, Y) \
(p).x = (X), (p).y = (Y)
/* addition. a + b -> c */
#define add3D(a, b, c) (c).x = (a).x + (b).x, \
(c).y = (a).y + (b).y, \
(c).z = (a).z + (b).z
/* subtraction. a - b -> c */
#define sub3D(a,b,c) (c).x = (a).x - (b).x, \
(c).y = (a).y - (b).y, \
(c).z = (a).z - (b).z
/* negation. a = - a */
#define neg3D(a) (a).x = - (a).x, \
(a).y = - (a).y, \
(a).z = - (a).z
/* increment. a += b */
#define inc3D(a, b) \
(a).x += (b).x, (a).y += (b).y, (a).z += (b).z
/* decrement. a -= b */
#define dec3D(a, b) \
(a).x -= (b).x, (a).y -= (b).y, (a).z -= (b).z
/* scale. a *= s */
#define scl3D(a, s) (a).x *= (s), \
(a).y *= (s), \
(a).z *= (s)
/* dotproduct. return <a.b> */
#define dot3D(a, b) ((a).x * (b).x + (a).y * (b).y + (a).z * (b).z)
#define dot2D(a, b) ((a).x * (b).x + (a).y * (b).y)
/* norm. return |a| */
#define norm3D(a) sqrt (dot3D (a, a))
#define norm2D(a) sqrt (dot2D (a, a))
/* crossproduct. a X b -> c */
/* important: make sure that c is not identical to a or b! */
#define crp3D(a, b, c) (c).x = (a).y * (b).z - (a).z * (b).y, \
(c).y = (a).z * (b).x - (a).x * (b).z, \
(c).z = (a).x * (b).y - (a).y * (b).x
/* parametric line equation. a + t*b -> c */
#define pol3D(a, t, b, c) (c).x = (a).x + (t) * (b).x, \
(c).y = (a).y + (t) * (b).y, \
(c).z = (a).z + (t) * (b).z
/* linear combination (interpolation). s*a + t*b -> c */
#define lcm3D(s, a, t, b, c) \
(c).x = (s) * (a).x + (t) * (b).x, \
(c).y = (s) * (a).y + (t) * (b).y, \
(c).z = (s) * (a).z + (t) * (b).z
#endif
|