1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
float dist3(float ux, float uy, float uz, float vx, float vy, float vz);
int main()
{
cout << "The distance between (1, 2, 3) and (0, 0, 0) = " << dist3(0, 0, 0, 1, 2, 3) << endl;
system("Pause");
}
float dist3(float ux, float uy, float uz, float vx, float vy, float vz)
{
float answer = 0.0f;
float distance = 0.0f;
distance = (vx - ux) * (vx - ux) + (vy - uy) * (vy - uy) + (vz - uz) * (vz - uz);
answer = sqrt(distance);
return answer;
}
|