Lerp larger than 1

how do you find a point at any distance along the line made by 2 points, given just the distance?

I am just trying to rewrite Lerp for values larger than 1 and smaller than 0. this didn’t work I don’t know why:

    //points a1 , b1 
    //percentage to lerp = ( distab0 / distab1 ); (i.e. 0.5 is halfway)

// var xp1 =  Vector3.Lerp(a1,b1, ( distab0 / distab1 ));//works fine

var xp1 =  ((a1-b1) *( distab0 / distab1 ) + a1);

Uhm you just need this:

// UnityScript
function LerpWithoutClamp(A : Vector3, B : Vector3, t : float) : Vector3
{
    return A + (B-A)*t;
}


//C#
Vector3 LerpWithoutClamp(Vector3 A, Vector3 B, float t)
{
    return A + (B-A)*t;
}

The only difference to Vector3.Lerp is that this line is missing:

t = Mathf.Clamp01(t);

Calculate the direction of the line (in this case the difference vector)

var dir : Vector3 = Vector3.Normalize(a2 -a1);

Than scale it by the distance.

var xp1 = dir * distance;

How about something like this?

// get the direction
var dir : Vector3 = (a2 - a1)

// calculate distance between points
var distance : float = dir.magnitude;

// normalize the direction
dir = dir.normalized;

// calculate point t% between a1 and a2
var xp1 : Vector3 = a1 + dir * (distance * t);

So, 100% of distance should get you the point a2, because we’re adding the normalize (unit length) direction between a1 and a2, and adding distance * 100%. A value of t larger than 1 will move beyond a2. It should work for values of t less than 0 as well.