
Maths function
Hi guys,
I have two points in space at: x,y,z & x1, y1,z1 and need to know how far apart they are from each other.
I know I could work this out manually but I was wondering if there is an inbuilt function in c++ that will do this for me.
Any ideas? I've tried to look in the doc but being fairly new not had any luck.
Thanks

en ... .... .....
i think there is not ........

No, there's no builtin function for this.
If you stretch it, you could use valarrays:
Code:
valarray<double> v = ... (x,y,z)
valarray<double> u = ... (x1,x2,x3)
//Distance vector between points
valarray v0 = vu;
//Raise each element to the power of two, add the elements
//and take the square root from the result
double distance = sqrt( pow(v0,2).sum() );
Even though abs() is overloaded for valarraysy, one cannot do:
Code:
double distance = abs(v0); //abs returns a valarray
