# (Solved)Halfway Point Between Vertices

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

## 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 on other sites
How can you find the half point between two numbers?

##### Share on other sites
Just take the mean average of each component (x, y and z) of the two vertices.

xmid = (x1 + x2) * 0.5;

##### Share on other sites
Ha Funny,
I trying to put a point on an edge.
How do I do it?
v1.x / v2.x

That doesn't work.

##### Share on other sites
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 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 on other sites
Quote:
 Original post by Steve5050How can I find the halfway point between two vertices.I'm going to be putting a point on the edge halfwaybetween two vertices.ThanksSteve

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 on other sites
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 on other sites
Thanks everybody.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633725
• Total Posts
3013567
×