- Home /
Get the point between 2 other points using weights
Hello. I have another algorithm issue.
I have 2 weights.
Weight 1 (W1) is between 0 and 1.
Weight 2 (W2) is the "opposite" of W1. W2 = Mathf.Abs(W1 - 1.0f)
I have 2 points.
When W1 is 1.0 the final point is Point 1.
When W2 is 1.0 the final point is Point 2.
When W1 and W2 is 0.5 the final point is the midpoint of Point 1 and Point 2.
Answer by alexi123454 · Jul 22, 2015 at 05:01 PM
How many dimensions is your point? If it's 2 dimensional, you can use Vector2.Lerp(Point1, Point2, W2). For 3 dimensional points, you can use the same function with Vector3.
If you don't want to use the built in functions, the mathematics behind it are as such:
vectorBetweenPoints = Point2 - Point1;
finalValue = Point1 + (vectorBetweenPoints * W2);
Oh yes. Thank you that is perfect. (By the way I am using Vector3).
That's correct. Since you're saying that W2 being at 1.0 should be the second point, you should use W2 in the math.
You could use W1 ins$$anonymous$$d, if you switch things around so that Point2 is the first value, and Point1 as the second value.
Your answer
![](https://koobas.hobune.stream/wayback/20220611232528im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Algorithm Help 3 Answers
Generating Triangles Given a Set of Points 1 Answer
A* Algorithm help? 0 Answers
Perlin Noise for 3d Voxel Terrain 1 Answer