Koalanet21
New member
- Joined
- Jun 16, 2020
- Messages
- 12
If I were to do your assignment, I wouldView attachment 28183
Here's my (probably really simple) problem.
Let's say I already know the coordinates of (xA, yA) and I also know the coordinates of (xB, yB)
What is the formula to determine the coordinates of the red dot (xC, yC)?
This dot is at 1/5 of the segment w starting from (xA, ya)
Since point C is 1/5 of the way from A to B, the same is true of its coordinates. So find [MATH]x_B-x_A[/MATH], divide by 5, and add that to [MATH]x_A[/MATH]. Then do the same with the y.View attachment 28183
Here's my (probably really simple) problem.
Let's say I already know the coordinates of (xA, yA) and I also know the coordinates of (xB, yB)
What is the formula to determine the coordinates of the red dot (xC, yC)?
This dot is at 1/5 of the segment w starting from (xA, ya)
A particularly nice form is \((1-a)s + ae\); in the example, we just add 4/5 of \(x_A\) and 1/5 of \(x_B\), and likewise with y.This is an application of linear interpolation. Fundamentally, it's a matter of moving from one position to another by some proportion of the total difference. It appears in animation, color blending and just about anything else you could imagine.
A general formula for linear interpolation is this:
[MATH]result = s + a(e - s)[/MATH]
Where:
In the example provided:
- [MATH]s[/MATH] is the starting position
- [MATH]e[/MATH] is the ending position
- [MATH]a[/MATH] is the proportion of the total difference from [MATH]s[/MATH] in the direction of [MATH]e[/MATH]
- [MATH]xC = xA + \frac{1}{5}(xB - xA)[/MATH]
- [MATH]yC = yA + \frac{1}{5}(yB - yA)[/MATH]