2 #ifndef _vectorFunctions_h_ 3 #define _vectorFunctions_h_ 12 double *
projection(
const double *v1,
const double *v2 );
26 result[0] = v1[1]*v2[2] - v1[2]*v2[1];
27 result[1] = v1[2]*v2[0] - v1[0]*v2[2];
28 result[2] = v1[0]*v2[1] - v1[1]*v2[0];
37 float invMag = 1.0f / sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
40 vec[0] = vec[0] * invMag;
41 vec[1] = vec[1] * invMag;
42 vec[2] = vec[2] * invMag;
45 std::cout<<
"\nERROR: Attempted to normalize a vector with magnitude = 0\n";
59 T result = A[0]*B[0] + A[1]*B[1] + A[2]*B[2];
71 std::cout<<
"Vertices:\n";
72 for (
int i = 0; i < numVertices; i++ ) {
74 std::cout<<
"{" << vert[x] <<
"," << vert[x+1] <<
"," << vert[x+2] <<
"}\n";
87 return sqrt((x*x) + (y*y) + (z*z));
99 return (x*x) + (y*y) + (z*z);
115 if (1-
eps < dotProd && dotProd < 1+
eps){
T magnitude(T x, T y, T z)
double angleBeteenVectors(const double *vector1, const double *vector2)
bool parallel(double *v1, double *v2)
void printVertices(T *vert, int numVertices)
T dotProduct(const T *A, const T *B)
double euclideanDistance(double *A, double *B)
T sqrMagnitude(T x, T y, T z)
T * crossProduct(const T *v1, const T *v2)
double * projection(const double *v1, const double *v2)