In that graph we have two points (0, 2) and (20, 10), at 15 in x axis; y would be 8.
As a human I know how to do that, all I do is keep looking above 15 until I see the line, then look left of the line until I see what the y value is. But how do I do that with math?
EDIT:
Answer in lua. Note: Function is sensitive to order of points.
local function getY(p1: Vector2, p2: Vector2, x: number)
local m = (p2.Y - p1.Y) / (p2.X - p1.X)
return m * x + (p1.Y - (m * p1.X))
end
print(getY(Vector2.new(0, 2), Vector2.new(20, 10), 15)) -- Prints 8 as expected
He probably draws a line based on the way he wishes something scales (level, power, currency etc) and then he wants a way to generate the formula for it.