1 //------------------------------------------------------------------------------
3 //------------------------------------------------------------------------------
4 // GLVU : Copyright 1997 - 2002
5 // The University of North Carolina at Chapel Hill
6 //------------------------------------------------------------------------------
7 // Permission to use, copy, modify, distribute and sell this software and its
8 // documentation for any purpose is hereby granted without fee, provided that
9 // the above copyright notice appear in all copies and that both that copyright
10 // notice and this permission notice appear in supporting documentation.
11 // Binaries may be compiled with this software without any royalties or
14 // The University of North Carolina at Chapel Hill makes no representations
15 // about the suitability of this software for any purpose. It is provided
16 // "as is" without express or implied warranty.
18 //============================================================================
20 //============================================================================
25 void Set3fv(float v[3], float x, float y, float z)
32 void Copy3fv(float A[3], const float B[3]) // A=B
39 void ScalarMult3fv(float c[3], const float a[3], float s) // c=a*s
46 void ScalarDiv3fv(float v[3], float s)
53 void Add3fv(float c[3], const float a[3], const float b[3]) // c = a + b
60 void Subtract3fv(float c[3], const float a[3], const float b[3]) // c = a - b
67 void Negate3fv(float a[3], const float b[3]) // a = -b
74 float Length3fv(const float v[3])
76 return( (float)sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) );
79 void Normalize3fv(float v[3])
81 float l = Length3fv(v);
87 float DotProd3fv(const float a[3], const float b[3])
89 return( a[0]*b[0] + a[1]*b[1] + a[2]*b[2] );
92 void CrossProd3fv(float* C, const float* A, const float* B) // C = A X B
94 Set3fv(C, A[1]*B[2]-A[2]*B[1], A[2]*B[0]-A[0]*B[2], A[0]*B[1]-A[1]*B[0]);