Points between two vector3 points?

Hi there,

i am wondering what would be the best way to calculate points between two vector3 points with a defined distance?

Thanks a lot for ideas!!!

Cheers

Vector maths is the way to go

Let A and B be two points, let P be any point lying along the line through AB, let the displacement of P from A be d.

Let U be the unit vector = (B.subtract(A)).normalize()

then P = A.add(U.scale(d))

1 Like

Hi, i am doing something like this now

    for (let tupleIndex = 0; tupleIndex < pointTuple.length; tupleIndex++) {
      // get the division count based on length per side
      const distance = Vector3.Distance(
        pointTuple[tupleIndex][0],
        pointTuple[tupleIndex][1]
      );
      const divisions = Math.round(distance / gridSize);

      //divide all edges.. push to sensorpoints
      for (let index = 0; index < divisions; index++) {
        const newSensorPoint = Vector3.Lerp(
          pointTuple[tupleIndex][0],
          pointTuple[tupleIndex][1],
          (1 / divisions) * index
        );

        sensorPoints.push(newSensorPoint);
      }
    }

does using Vector3.Lerp makes sense there? i am trying to make this usable for hundereds/thousands of points, so speed may be importand… (i actually have no idea wether this is slow or not…)

Thanks a lot!

If you didn’t use Vector3.Lerp you would have to write your own Lerp. Best way is to do a simple simulation in a playground with manually or randomly generated points and see how it goes.

If point are evenly spaced on the line subtract end points and scale by 1/count. Like this:

1 Like

Thanks! that seems to be way cleaner!
ill give it a try :slight_smile: