Jump to content
  • Advertisement
Sign in to follow this  
Steve5050

(Solved)Halfway Point Between Vertices

This topic is 3931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I find the halfway point between two vertices. I'm going to be putting a point on the edge halfway between two vertices. Thanks Steve [Edited by - Steve5050 on September 17, 2007 8:11:13 PM]

Share this post


Link to post
Share on other sites
Advertisement
That isn't working dmatter,thats in the center of a cube.
I'm trying to put a point on a edge.
This is in the center:
Dim M As Double
M = (mV1.x + mV2.x) * 0.5
//also tried M = (mV1.x + mV2.x) / 2
//also tried M = (mV1.x - mV2.x) / 2
Gl.glBegin(Gl.GL_POINTS)
Gl.glVertex3dv(M)
Gl.glVertex3dv(mV1.x)
Gl.glEnd()
Gl.glBegin(Gl.GL_POINTS)
Gl.glColor3f(1.0F, 0.0F, 1.0F)
Gl.glVertex3dv(mV2.x)
Gl.glEnd()

Share this post


Link to post
Share on other sites
It's not working because you're only doing it for the x-component. I actually said 'each component (x, y and z)'.

The code I gave you was only an example of how to do it for x, you must repeat that snippet for the y and z values too.

My fault, I should have been clearer.

Share this post


Link to post
Share on other sites
Quote:
Original post by Steve5050
How can I find the halfway point between two vertices.
I'm going to be putting a point on the edge halfway
between two vertices.

Thanks
Steve


To find the midpoint between two vertices on an edge just do this:

Assume (x1,y1,z1) is vertex 1, and (x2,y2,z2) is vertex 2.

MidX = (x1 + x2) * 0.5;
MidY = (y1 + y2) * 0.5;
MidZ = (z1 + z2) * 0.5;

your midpoint is located at the vertex (MidX,MidY,MidZ).

done,
cheers,
Paul.

Share this post


Link to post
Share on other sites
Dead On!
Thanks dmatter.
Dim M, M1, M2 As Single
M = (mV1.x + mV2.x) * 0.5
M1 = (mV1.y + mV2.y) * 0.5
M2 = (mV1.z + mV2.z) * 0.5
Gl.glBegin(Gl.GL_POINTS)
Gl.glVertex3f(M, M1, M2)
Gl.glVertex3dv(mV1.x)
Gl.glEnd()
Gl.glBegin(Gl.GL_POINTS)
Gl.glColor3f(1.0F, 0.0F, 1.0F)
Gl.glVertex3dv(mV2.x)
Gl.glEnd()

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!