# Is it possible to derive a function in 3D that forms a parabolic curve based on three points; start, vertex, and end point?

Hello,
I wanted to derive a position based equation that helps me draw the path calculated when I’m using two points; start, and end (I have a function that calculates the vertex point):

``````local function getVertex(x0, x1, h)
local h = h or 0 -- height between the points
local up = Vector3.new(0,1,0)

local vector = (x1 - x0)
local midPoint = x0:Lerp(x1, 0.5)

local right = vector:Cross(up)--.Unit
right = right.Magnitude == 0 and Vector3.new(1,0,0) or right.Unit

local normal = right:Cross(vector)
normal = normal.Magnitude == 0 and up or normal.Unit

return midPoint + normal * h
end

local height = 10
local a = Vector3.new()
local c = Vector3.new(0,0,8)
local b = getVertex(a, c, height)
``````

Although I have this graph and function above to guide me through a solution, I’m not too sure how I can convert the vertex equation into a 3D positional based equation using these three points, but I do know that these points are essential as I’m trying to mimic a trajectory-like curve (but not physics based, for peculiar reasons) to model out a positional function.

Where can I begin to tackle an approach to make up that positional function?

If you mean the math equation itself, you can derive an equation like:

``````f(x) = 4 * h/d * (-x^2/d + x)
``````

Through some fancy algebra
(Edit, h is height, d is distance)

To find the actual 3D position youd use a system similar to how you find the position of the vertex

Given the function f(x) with an input of x and a result of y=f(x)

1. Lerp from start to end with an alpha value of x/distance
2. Add on (end-start):Cross(up):Cross(end-start) * f(x)
1 Like

Thank you as always PapaBreadd !

Mind going over the “fancy algebra” f(x) equation you derived? Really interested on how u achieved this; everything else is perfect & I derived the positional equation I’ve been scratching my head over

You can start with the base equation (without the +c because it always starts at 0)

And imagine you have two variables d and h
You can use the vertex equation to solve for the midpoint, then double it to get the distance from start to finish, and set this equal to d, your desired distance

Then to get the maximum height, you can find the functions value at the vertex, the highest point, and set that equal to h, your desired height

Which turns to

Solve both equations for a
The double vertex solves to:

The vertex height solves to:

Set them equal and solve for b
Giving you the final b value of:

Then just plug in b into one of the original equations and solve

Solve for a

Plug into the original equation

And simplify

Which gives you the final equation

3 Likes