Making a curve with specifiable depth and distance between x intersections

30 Views Asked by At

I'm working on game development, and I want to make a U-Shaped graph where I can specify the distance between the x intersections, and the depth of the graph. The closest thing I have is this:

https://www.desmos.com/calculator/efsp6ncsdt

This sort of works, in that they are proportional, but the values are not specific. The whole x-multiplier component I worked out through recording the distance between the intersections with increasingly small multipliers, but only works exactly for a specific depth. Thanks to anyone who can help

2

There are 2 best solutions below

1
On BEST ANSWER

I would start by something like $$ y=ax^{2k}-d $$ Already, we have $d$ as the correct depth. $k$ is the exponent, it defines the "steepness" of the sides. So perhaps something like $k=2,3$ or $4$ should do. Now, we only have to figure out how to calculate the distance between the $x$-intersections. This is not too difficult, because immediately we see the roots $$ x = \pm \sqrt[2k]{ \frac{d}{a} } $$ so the distance (or width, $w$) is $$ 2 \sqrt[2k]{ \frac{d}{a} } = w $$ Now we only have to solve for $a$ and we're done.

0
On

Here is a quadratic solution with your notations:

$$y=\dfrac{4d}{w^2}(x-a)(x-a+w)$$