Posted By

antonmills on 01/26/10


Tagged

distance opengl


Versions (?)

OpenGL Distance to object


 / Published in: Other
 

Works out the distance between two objects in 3D space, you'll need the Vertex3D struct also in my snipppets

  1. static inline GLfloat Vertex3DCalculateDistanceBetweenVertices (Vertex3D first, Vertex3D second)
  2. {
  3. GLfloat deltaX = second.x - first.x;
  4. GLfloat deltaY = second.y - first.y;
  5. GLfloat deltaZ = second.z - first.z;
  6. return sqrtf(deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ );
  7. };

Report this snippet  

You need to login to post a comment.