# how to add a point between 2 points in vex

## Recommended Posts

I have a point {0,0,0}  and another one in {1,0,0}  how can I add one or more points (equidistant) between this 2 points?  I know I can use addpoint({.5, 0,0})  but how can I get the new position?  should I delete the first P with the second? or there is an function for that?

thanks =)

##### Share on other sites
Posted (edited)

First find the vector from point one to point two and then divide by two:
newpointpos = ( vector two - vector one ) * 0.5

So with two add nodes and a wrangle it would look something like this:

Regards
Bonsak

Edited by bonsak

##### Share on other sites

that's what I was missing the division!  lol  thanks!!!I was hitting my head against the wall this time.

thanks!

##### Share on other sites

this is strange I am know the math should be right, but it seems vex evaluation from 0,0,0?  why is that? I even put a slider so I can see the point moving from point A to point B  but  it does it from 0,0,0?

is that suppose to be like that?

between_points.hip

##### Share on other sites
Posted (edited)

just use lerp

lerp(A,B,0.5);

means linearly interpolate b/n A and B with 'percentage' as 0.5 (ie. half way)

Yes from Origin is correct, you simply missed the part that you have to add the 1st point as 'offset'.

To me lerp is far simpler

Edited by Noobini

##### Share on other sites

aja,  need to move the first point from the origin =)

vector one = point(0, "P", 0);
vector two = point(1, "P", 0);
vector newpoint = (two-one)*ch("perc");

## Create an account

Register a new account