source: trunk/src/testing/app/volvis/VectorMath.h @ 4

Revision 4, 17.3 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/********************************************************************************
2 * Volatile - Volume Visualization Software for SAGE
3 * Copyright (C) 2004 Electronic Visualization Laboratory,
4 * University of Illinois at Chicago
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 *  * Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *  * Redistributions in binary form must reproduce the above
14 *    copyright notice, this list of conditions and the following disclaimer
15 *    in the documentation and/or other materials provided with the distribution.
16 *  * Neither the name of the University of Illinois at Chicago nor
17 *    the names of its contributors may be used to endorse or promote
18 *    products derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * Direct questions, comments etc about Volatile to www.evl.uic.edu/cavern/forum
33 *********************************************************************************/
34
35
36#ifndef __VectorMath_defined
37#define __VectorMath_defined
38
39#ifdef WIN32
40#include <windows.h>
41#endif
42
43#if defined(__APPLE__)
44#include <GLUT/glut.h>
45#else
46#include <GL/glut.h>
47#endif
48
49
50#include <math.h>
51#include <stdio.h>
52#include <iostream>
53#include <limits.h>
54#define EPSILON 2e-07
55#define V_PI    3.1415926535897932384626433832795
56
57#if 0 //matrix representation for mat[16], same as OpenGl matrix rep
58
59+-          -+
60|0  4  8   12|
61|1  5  9   13|
62|2  6  10  14|
63|3  7  11  15|
64+-          -+
65
66#endif
67
68/*
69******** NRRD_AFFINE(i,x,I,o,O)
70**
71** given intervals [i,I], [o,O] and a value x which may or may not be
72** inside [i,I], return the value y such that y stands in the same
73** relationship to [o,O] that x does with [i,I].  Or:
74**
75**    y - o         x - i
76**   -------   =   -------
77**    O - o         I - i
78**
79** It is the callers responsibility to make sure I-i and O-o are
80** both greater than zero
81*/
82
83#define CLAMP(x) ((((x)>0) ? (((x)<1) ? x : 1) : 0))
84#define MAX(x,y) (((x)>(y)) ? (x) : (y))
85#define MIN(x,y) (((x)<(y)) ? (x) : (y))
86#define ABS(x) ((x)<0 ? (-x) : (x))
87#define NOTPOW2(num) ((num) & (num - 1))
88
89inline double CLAMP_ARB(const double c, const double x, const double C)
90{
91        return ((((x)>c) ? (((x)<(C)) ? x : (C)) : c));
92}
93
94inline double affine(const double i, const double x, const double I,
95                                         const double o, const double O)
96{
97        return  ( ((O)-(o))*((x)-(i)) / ((I)-(i)) + (o) );
98}
99
100// make a vector all zeros -----------------------------------------
101inline void zeroV3(GLfloat* in)
102{
103        in[0] = in[1] = in[2] = 0;
104}
105
106inline void setV3(GLfloat* v, float x, float y, float z)
107{
108  v[0] = x;
109  v[1] = y;
110  v[2] = z;
111}
112
113// negate all components of a vector -------------------------------
114inline void negateV3(GLfloat* in)
115{
116        in[0] = -in[0];
117        in[1] = -in[1];
118        in[2] = -in[2];
119}
120
121
122// copy vector 'out' = 'in';---------------------------------------
123inline void copyV3(GLfloat* out, GLfloat* in)
124{
125        out[0] = in[0];
126        out[1] = in[1];
127        out[2] = in[2];
128}
129
130inline void copyV3(GLfloat* out, GLdouble* in)
131{
132        out[0] = (float)in[0];
133        out[1] = (float)in[1];
134        out[2] = (float)in[2];
135}
136
137inline void copyV3(GLdouble* out, GLfloat* in)
138{
139        out[0] = in[0];
140        out[1] = in[1];
141        out[2] = in[2];
142}
143
144// out = inl - inr -----------------------------------------------
145inline void subV3(GLfloat* out, GLfloat* inl, GLfloat* inr)
146{
147        out[0] = inl[0] - inr[0];
148        out[1] = inl[1] - inr[1];
149        out[2] = inl[2] - inr[2];
150}
151
152inline void subV3(GLdouble* out, GLdouble* inl, GLdouble* inr)
153{
154        out[0] = inl[0] - inr[0];
155        out[1] = inl[1] - inr[1];
156        out[2] = inl[2] - inr[2];
157}
158
159// out = inl + inr ---------------------------------------------
160inline void addV3(GLfloat *out, GLfloat inl[3], GLfloat inr[3])
161{
162        out[0] = inl[0] + inr[0];
163        out[1] = inl[1] + inr[1];
164        out[2] = inl[2] + inr[2];
165}
166
167inline void addV3(GLdouble *out, GLdouble inl[3], GLdouble inr[3])
168{
169        out[0] = inl[0] + inr[0];
170        out[1] = inl[1] + inr[1];
171        out[2] = inl[2] + inr[2];
172}
173
174// one *= s --------------------------------------------------
175inline void scaleV3(float s, GLfloat *one)
176{
177        one[0] *= s;
178        one[1] *= s;
179        one[2] *= s;
180}
181
182inline void scaleV3(double s, GLdouble *one)
183{
184        one[0] *= s;
185        one[1] *= s;
186        one[2] *= s;
187}
188
189// out = in * s --------------------------------------------
190inline void cscaleV3(GLfloat *out, float s, GLfloat in[3])
191{
192        out[0] = s*in[0];
193        out[1] = s*in[1];
194        out[2] = s*in[2];
195}
196
197inline void cscaleV3(GLdouble *out, double s, GLdouble in[3])
198{
199        out[0] = s*in[0];
200        out[1] = s*in[1];
201        out[2] = s*in[2];
202}
203
204// set a matrix 'm' to the identity -----------------------
205inline void identityMatrix(GLfloat m[16])
206{
207        m[0]=1; m[4]=0; m[8]= 0; m[12]=0;
208        m[1]=0; m[5]=1; m[9]= 0; m[13]=0;
209        m[2]=0; m[6]=0; m[10]=1; m[14]=0;
210        m[3]=0; m[7]=0; m[11]=0; m[15]=1;
211}
212
213inline void identityMatrix(GLdouble m[16])
214{
215        m[0]=1; m[4]=0; m[8]= 0; m[12]=0;
216        m[1]=0; m[5]=1; m[9]= 0; m[13]=0;
217        m[2]=0; m[6]=0; m[10]=1; m[14]=0;
218        m[3]=0; m[7]=0; m[11]=0; m[15]=1;
219}
220
221// vector matrix multiplication [4] vector ----------------------
222// out = mat * in
223inline void translateV4(GLfloat out[4], GLfloat mat[16], GLfloat in[4])
224{
225        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12]*in[3];
226        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13]*in[3];
227        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14]*in[3];
228        out[3] = mat[3]*in[0] + mat[7]*in[1] + mat[11]*in[2] + mat[15]*in[3];
229}
230
231//3 vector with implict w=1 mult matrix to 4 vector
232inline void translateV4_3W(GLfloat out[4], GLfloat mat[16], GLfloat in[3])
233{
234        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12];
235        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13];
236        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14];
237        out[3] = mat[3]*in[0] + mat[7]*in[1] + mat[11]*in[2] + mat[15];
238}
239
240inline void translateV4(GLdouble out[4], GLdouble mat[16], GLdouble in[4])
241{
242        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12]*in[3];
243        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13]*in[3];
244        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14]*in[3];
245        out[3] = mat[3]*in[0] + mat[7]*in[1] + mat[11]*in[2] + mat[15]*in[3];
246}
247
248// vector matrix multiplicaiton [3] vector with no translation ---
249// (only rotation) out = mat * in;
250inline void translateV3(GLfloat *out, GLfloat mat[16], GLfloat in[3])
251{
252        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2];// + mat[12];
253        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2];// + mat[13];
254        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2];// + mat[14];
255}
256
257inline void translateV3(GLdouble *out, GLdouble mat[16], GLdouble in[3])
258{
259        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2];// + mat[12];
260        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2];// + mat[13];
261        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2];// + mat[14];
262}
263
264inline void translateV3(GLfloat *out, GLdouble mat[16], GLfloat in[3])
265{
266        out[0] = (float)(mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2]);// + mat[12];
267        out[1] = (float)(mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2]);// + mat[13];
268        out[2] = (float)(mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2]);// + mat[14];
269}
270
271// [3] vector * matrix --------------------------------------------
272// out = mat * in (with translation)
273inline void translateV3W(GLfloat *out, GLfloat mat[16], GLfloat in[3])
274{
275        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12];
276        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13];
277        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14];
278}
279
280inline void translateV3W(GLfloat *out, GLdouble mat[16], GLfloat in[3])
281{
282        out[0] = (float)(mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12]);
283        out[1] = (float)(mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13]);
284        out[2] = (float)(mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14]);
285}
286
287inline void translateV3W(GLdouble *out, GLdouble mat[16], GLdouble in[3])
288{
289        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12];
290        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13];
291        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14];
292}
293
294//transformation of 3 vector with implicit w=1 and homoginization
295inline void translateV3WD(GLfloat *out, GLfloat mat[16], GLfloat in[3])
296{
297        out[0] = (float)(mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12]);
298        out[1] = (float)(mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13]);
299        out[2] = (float)(mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14]);
300        float w= (float)(mat[3]*in[0] + mat[7]*in[1] + mat[11]*in[2] + mat[15]);
301        out[0]/=w;
302        out[1]/=w;
303        out[2]/=w;
304}
305
306// legacy call
307inline void transMatrixV3(GLfloat *out, GLfloat mat[16], GLfloat in[3])
308{
309
310        out[0] = mat[0]*in[0] + mat[4]*in[1] + mat[8]* in[2] + mat[12];
311        out[1] = mat[1]*in[0] + mat[5]*in[1] + mat[9]* in[2] + mat[13];
312        out[2] = mat[2]*in[0] + mat[6]*in[1] + mat[10]*in[2] + mat[14];
313}
314
315// dot product of two [4] vecotrs --------------------------
316inline GLfloat dotV4(GLfloat one[4], GLfloat two[4])
317{
318        return one[0]*two[0] + one[1]*two[1] + one[2]*two[2] + one[3]*two[3];
319}
320
321inline GLdouble dotV4(GLdouble one[4], GLdouble two[4])
322{
323        return one[0]*two[0] + one[1]*two[1] + one[2]*two[2] + one[3]*two[3];
324}
325
326// dot product of two [3] vectors ------------------------
327inline GLfloat dotV3(GLfloat one[4], GLfloat two[4])
328{
329        return one[0]*two[0] + one[1]*two[1] + one[2]*two[2];
330}
331
332inline GLdouble dotV3(GLdouble one[4], GLdouble two[4])
333{
334        return one[0]*two[0] + one[1]*two[1] + one[2]*two[2];
335}
336
337// compute the length of a [3] vector --------------------
338inline GLfloat normV3(GLfloat *one)
339{
340        return (GLfloat)sqrt( one[0]*one[0] + one[1]*one[1] + one[2]*one[2]);
341}
342
343inline GLdouble normV3(GLdouble *one)
344{
345        return sqrt( one[0]*one[0] + one[1]*one[1] + one[2]*one[2]);
346}
347
348// normalize a [4] vector --------------------------------
349inline void normalizeV4(GLfloat v[4])
350{
351        GLfloat len = (float)sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]);
352        if(len > 0){
353                v[0] /= len;
354                v[1] /= len;
355                v[2] /= len;
356                v[3] /= len;
357        }
358}
359
360inline void normalizeV4(GLdouble v[4])
361{
362        GLfloat len = (float)sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]);
363        if(len > 0){
364                v[0] /= len;
365                v[1] /= len;
366                v[2] /= len;
367                v[3] /= len;
368        }
369}
370
371// normalize a [3] vector ---------------------------------
372inline void normalizeV3(GLfloat v[3])
373{
374        GLfloat len = (float)sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
375        if(len > 0){
376                v[0] /= len;
377                v[1] /= len;
378                v[2] /= len;
379        }
380}
381
382inline void normalizeV3(GLdouble v[3])
383{
384        GLfloat len = (float)sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
385        if(len > 0){
386                v[0] /= len;
387                v[1] /= len;
388                v[2] /= len;
389        }
390}
391
392// divide out the 'W' part of a [4] vector ----------------
393inline void homogV4(GLfloat v[4])
394{
395        v[0] /= v[3];
396        v[1] /= v[3];
397        v[2] /= v[3];
398        v[3] = 1;
399}
400
401inline void homogV4(GLdouble v[4])
402{
403        v[0] /= v[3];
404        v[1] /= v[3];
405        v[2] /= v[3];
406        v[3] = 1;
407}
408
409// compute cross product of [3] vector -------------------
410// out = one X two;
411inline void crossV3(GLfloat *out, GLfloat *one, GLfloat *two)
412{
413        out[0] = one[1]*two[2] - one[2]*two[1];
414        out[1] = one[2]*two[0] - one[0]*two[2];
415        out[2] = one[0]*two[1] - one[1]*two[0];
416}
417
418inline void crossV3(GLdouble *out, GLdouble *one, GLdouble *two)
419{
420        out[0] = one[1]*two[2] - one[2]*two[1];
421        out[1] = one[2]*two[0] - one[0]*two[2];
422        out[2] = one[0]*two[1] - one[1]*two[0];
423}
424
425
426//returns 2^n such that 2^n < number < 2^(n+1)
427inline int makepow2_max(int val) {
428    if (NOTPOW2(val)) {
429                int power = 0;
430                if(!val)
431                        return 0;
432                while(val >>= 1)
433                        power++;
434                return(1 << (power+1));
435        }
436        else
437                return val;
438}
439
440//returns 2^n such that 2^n < number < 2^(n+1)
441inline int makepow2_min(int val) {
442    if (NOTPOW2(val)) {
443                int power = 0;
444                if(!val)
445                        return 0;
446                while(val >>= 1)
447                        power++;
448                return(1 << power);
449        }
450        else
451                return val;
452}
453
454
455
456inline void printV3(double v[3])
457{
458        std::cerr << " " << v[0] << "," << v[1] << "," << v[2];
459}
460
461inline void printV3(float v[3])
462{
463        std::cerr << " " << v[0] << "," << v[1] << "," << v[2];
464}
465
466inline void printV4(float v[3])
467{
468        std::cerr << " " << v[0] << "," << v[1] << "," << v[2] << "," << v[3];
469}
470
471
472
473//=====================================================================================
474//---------------------- Quantize -----------------------------------------------------
475//=====================================================================================
476
477inline
478void quantize(unsigned char *dout, int sx, int sy, int sz, unsigned short *din){
479
480        unsigned short max = 0;
481        unsigned short min = USHRT_MAX;
482    int i, j, k;
483        for(i = 0; i<sz; ++i){
484                for(j = 0; j<sy; ++j){
485                        for(k = 0; k<sx; ++k){
486                                max = MAX(max, din[i*sx*sy + j*sx + k]);
487                                min = MIN(min, din[i*sx*sy + j*sx + k]);
488
489                        }
490                }
491        }
492        for(i = 0; i<sz; ++i){
493                for(j = 0; j<sy; ++j){
494                        for(k = 0; k<sx; ++k){
495                                dout[i*sx*sy + j*sx + k] = (unsigned char)affine(min,din[i*sx*sy + j*sx + k], max, 0, 255);
496                        }
497                }
498        }
499}
500
501inline
502void quantize(unsigned char *dout, int sx, int sy, int sz, short *din){
503
504        short max = SHRT_MIN;
505        short min = SHRT_MAX;
506    int i, j, k;
507        for(i = 0; i<sz; ++i){
508                for(j = 0; j<sy; ++j){
509                        for(k = 0; k<sx; ++k){
510                                max = MAX(max, din[i*sx*sy + j*sx + k]);
511                                min = MIN(min, din[i*sx*sy + j*sx + k]);
512
513                        }
514                }
515        }
516        for(i = 0; i<sz; ++i){
517                for(j = 0; j<sy; ++j){
518                        for(k = 0; k<sx; ++k){
519                                dout[i*sx*sy + j*sx + k] = (unsigned char)affine(min,din[i*sx*sy + j*sx + k], max, 0, 255);
520                        }
521                }
522        }
523}
524
525inline
526void quantize(unsigned char *dout, int sx, int sy, int sz, int *din){
527
528    int i, j, k;
529        int max = INT_MIN;
530        int min = INT_MAX;
531        for(i = 0; i<sz; ++i){
532                for(j = 0; j<sy; ++j){
533                        for(k = 0; k<sx; ++k){
534                                max = MAX(max, din[i*sx*sy + j*sx + k]);
535                                min = MIN(min, din[i*sx*sy + j*sx + k]);
536
537                        }
538                }
539        }
540        for(i = 0; i<sz; ++i){
541                for(j = 0; j<sy; ++j){
542                        for(k = 0; k<sx; ++k){
543                                dout[i*sx*sy + j*sx + k] = (unsigned char)affine(min,din[i*sx*sy + j*sx + k], max, 0, 255);
544                        }
545                }
546        }
547}
548
549inline
550void quantize(unsigned char *dout, int sx, int sy, int sz, unsigned int *din){
551
552        unsigned int max = 0;
553        unsigned int min = UINT_MAX;
554    int i, j, k;
555        for(i = 0; i<sz; ++i){
556                for(j = 0; j<sy; ++j){
557                        for(k = 0; k<sx; ++k){
558                                max = MAX(max, din[i*sx*sy + j*sx + k]);
559                                min = MIN(min, din[i*sx*sy + j*sx + k]);
560
561                        }
562                }
563        }
564        for(i = 0; i<sz; ++i){
565                for(j = 0; j<sy; ++j){
566                        for(k = 0; k<sx; ++k){
567                                dout[i*sx*sy + j*sx + k] = (unsigned char)affine(min,din[i*sx*sy + j*sx + k], max, 0, 255);
568                        }
569                }
570        }
571}
572
573inline
574void quantize(unsigned char *dout, int sx, int sy, int sz, float *din)
575{
576        float max = -10000000000.0;
577        float min = 10000000000.0;
578    int i, j, k;
579        for(i = 0; i<sz; ++i){
580                for(j = 0; j<sy; ++j){
581                        for(k = 0; k<sx; ++k){
582                                max = MAX(max, din[i*sx*sy + j*sx + k]);
583                                min = MIN(min, din[i*sx*sy + j*sx + k]);
584                        }
585                }
586        }
587        for(i = 0; i<sz; ++i){
588                for(j = 0; j<sy; ++j){
589                        for(k = 0; k<sx; ++k){
590                                dout[i*sx*sy + j*sx + k] = (unsigned char)affine(min, din[i*sx*sy + j*sx + k], max, 0, 255);
591                        }
592                }
593        }
594}
595
596//for trackball
597inline void vZero(float *v)
598{
599  v[0] = 0.0;
600  v[1] = 0.0;
601  v[2] = 0.0;
602}
603
604inline void vSet(float *v, float x, float y, float z)
605{
606  v[0] = x;
607  v[1] = y;
608  v[2] = z;
609}
610
611inline void vSub(const float *src1, const float *src2, float *dst)
612{
613  dst[0] = src1[0] - src2[0];
614  dst[1] = src1[1] - src2[1];
615  dst[2] = src1[2] - src2[2];
616}
617
618inline void vCopy(const float *v1, float *v2)
619{
620  for (int i = 0 ; i < 3 ; i++)
621    v2[i] = v1[i];
622}
623
624inline void vCross(const float *v1, const float *v2, float *cross)
625{
626  float temp[3];
627
628  temp[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]);
629  temp[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]);
630  temp[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]);
631  vCopy(temp, cross);
632}
633
634inline float vLength(const float *v)
635{
636  return (float)(sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]));
637}
638
639inline void vScale(float *v, float div)
640{
641  v[0] *= div;
642  v[1] *= div;
643  v[2] *= div;
644}
645
646inline void vNormal(float *v)
647{
648  vScale(v,(float)(1.0/vLength(v)));
649}
650
651inline float vDot(const float *v1, const float *v2)
652{
653  return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
654}
655
656inline void vAdd(const float *src1, const float *src2, float *dst)
657{
658  dst[0] = src1[0] + src2[0];
659  dst[1] = src1[1] + src2[1];
660  dst[2] = src1[2] + src2[2];
661}
662
663#endif
664
665
666
667
668
669
670
671
Note: See TracBrowser for help on using the repository browser.