How to interpolate elliptically

51 Views Asked by At

Given two orthogonal axes with different weightings along each axis, how do I interpolate elliptically between the two weightings?

This is in 2d cartesian space.

For example, axis1 might be Vector(2, 1) - normalized - and axis2 is perpendicular to this. Axis1 has a weighting of 1x/unit and axis2 has a weighting of 0.5x/unit. So for each unit travelled along the x axis, we accumulate 1x and for each unit along the y axis, we accumulate 0.5x.

Given an arbitrary point in 2d cartesian space, how do I determine what the x accumulation by interpolating elliptically between the weightings of the two different axes?

Here is some pseudo code that may help illuminate what I've tried:

var delta = point - ellipseOrigin;     // Vector from ellipse origin to point
var deltaNorm = delta.ToNormalized();  // Normalized delta

var dotA = Abs(deltaNorm.Dot(axisA));  // Dot product to axisA
var dotB = Abs(deltaNorm.Dot(axisB));  // Dot product to axisB
var dotSum = dotA + dotB;

// xAlongAxisA and xAlongAxisB are the weightings along axisA
// and axisB respectively
var value = xAlongAxisA * dotA / dotSum + xAlongAxisB * dotB / dotSum;
1

There are 1 best solutions below

0
On BEST ANSWER

How about this:

1) Compute the cosine value (denoted as $cos\theta$) for the angle between vec(OP) and the axisA.
2) Then, the interpolated weight is

weight = $\sqrt{(xAlongAxisA * cos\theta)^2 + (xAlongAxisB * sin\theta)^2 }$