I'm trying to develop a C++ function to normalize a 4 element vector. I think that the vector math inside of the function is correct, but I'm not quite sure how to get the normalized vector elements out of the function (without using global variables).
// NORMALIZATION FUNCTION //
double normalizeThis(double q0,double q1,double q2,double q3){
double mag; // unnormalized vector magnitude variable
mag = pow((pow(q0,2)+pow(q1,2)+pow(q2,2)+pow(q3,2)),0.5); // calculating magnitude
q0 = q0/mag; q1 = q1/mag; q2 = q2/mag; q3 = q3/mag; // normalization!!
return q0; q1; q2; q3;
}