Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // stuff.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <Windows.h>
  6. #include <iostream>
  7. #include <string>
  8. #include <cmath>
  9.  
  10. struct vector3d
  11. {
  12.     float x;
  13.     float y;
  14.     float z;
  15. };
  16.  
  17. float distance(vector3d vec1, vector3d vec2)
  18. {
  19.     float retval;
  20.     float x = vec1.x - vec2.x;
  21.     float y = vec1.y - vec2.y;
  22.     float z = vec1.z - vec2.z;
  23.     x = pow(x, 2);
  24.     y = pow(y, 2);
  25.     z = pow(z, 2);
  26.     retval = sqrt(x + y + z);
  27.     return retval;
  28. }
  29.  
  30. bool trace(vector3d origin, vector3d target, vector3d angle)
  31. {
  32.     float x = origin.x - target.x;
  33.     float y = origin.y - target.y;
  34.  
  35.     float anglex = atan2(x,y);
  36.  
  37.     return false;
  38. }
  39.  
  40. int main()
  41. {
  42.     vector3d vec1;
  43.     vector3d vec2;
  44.     vec1.x = 5;
  45.     vec1.y = 2;
  46.     vec1.z = 20;
  47.     vec2.x = 10;
  48.     vec2.y = 3;
  49.     vec2.z = -13;
  50.     std::cout << distance(vec1, vec2) << std::endl;
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement