Interpolation Between Two Vectors - Vector3 Lerp

Hello!

I need to linearly interpolate between two vectors along an edge in a specific way. Rather than attempt to explain this issue myself and cause confusion I will instead include a snippet from the documentation of the algorithm I am attempting to implement:

“Exactly where a vertex is placed along an edge is determined by interpolation. The vertex should be placed where the density value is approximately zero. For example, if the density at end A of the edge is 0.1 and at end B is -0.3, the vertex would be placed 25 percent of the way from A to B.”

I need to linearly interpolate between two points given the above consideration of the float density values associated with each point. What I need to know is how I would go about getting t in “static function Lerp (from : Vector3, to : Vector3, t : float) : Vector3” given the above constraints. My mathematics is ropy and this is a hard one to explain so I would appreciate any input.

Thanks!

Given your float values A and B at vectors vA and vB, t would be calculated as:

t = A / (A - B)

where your lerping from vA to vB. Example code:

Vector3 vA;
Vector3 vB;
float A;
float B;

float t = A / (A - B);

Vector3 NewPoint = Vector3.lerp(vA, vB, t);

Let me know if this helps, or if you have any issues with it, as I’ve only tested the above on paper.

What about t=.25? In your case t doesn’t look like it’s changing (and is not really a time) and and might be calculated by t= (smallest weight) / (span between weights). The interpolation in this case would be applied the “edge end” (vertex?) with the least weight. Hope this helps… it’s a little hard to tell what’s going on.