#include "vector4.h" void setVector4 (Vector4 v, float a, float b, float c, float d) { v[0]=a; v[1]=b; v[2]=c; v[3]=d; } void copyVector4 (Vector4 v, Vector4 res) { int i; for (i=0; i<4; i++) res[i] = v[i]; } void crossProductVector4 (Vector4 v1, Vector4 v2, Vector4 res) { res[0] = v1[1]*v2[2] - v1[2]*v2[1]; res[1] = v1[2]*v2[0] - v1[0]*v2[2]; res[2] = v1[0]*v2[1] - v1[1]*v2[0]; res[3] = 0.; } void normalizeVector4 (Vector4 v) { float norm = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); if (norm != 0.) { v[0] /= norm; v[1] /= norm; v[2] /= norm; } } void sumVector4 (Vector4 v1, Vector4 v2, Vector4 res) { res[0] = v1[0]+v2[0]; res[1] = v1[1]+v2[1]; res[2] = v1[2]+v2[2]; res[3] = v1[3]; } void diffVector4 (Vector4 v1, Vector4 v2, Vector4 res) { res[0] = v1[0]-v2[0]; res[1] = v1[1]-v2[1]; res[2] = v1[2]-v2[2]; res[3] = 0.; } void multFloatVector4 (float f, Vector4 v, Vector4 res) { res[0] = f*v[0]; res[1] = f*v[1]; res[2] = f*v[2]; res[3] = v[3]; }