OpenGL Distance to object

/ Published in: Other
Save to your folder(s)

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

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.