0

I am trying to code a kind of parabolic curve to show on an LCD screen, however I can't seem to work it out. I need to be able draw it from the same spot at the bottom of the screen, but change its how aggressively curves. The closest I have is:

for (int i = 48; i > 0; i--){
y = i;
x = 70 - 5y^(0.33);
}

This code makes the first y value equal to 48 and counts down to 0. However this is not useful as I don't know the significance of each number, I have just made them up by trial and error (I have been working on this curve for literally a week now and simple maths like this isn't make sense to me anymore).

Can anyone tell me how I could produce a parabolic like curve from the same point where I can alter how much it curves with variables?

Here is a layout of the desired screen:

enter image description here

david_10001
  • 171
  • 5
  • It's not very clear what you want exactly. Indeed, you have a parabola here, and the coefficient of the 2nd degree term (currently equal to $5$) is "how aggresively it curves". When you change the terms, you can see that 40 is the distance from the axis to the highest point of the parabola. If you want to move the thing around (without changing its form), I suggest replacing $$ x \to x + x_0 $$ and $$ y \to y + y_0 $$ and playing around with $x_0$ and $y_0$.So the equation you would get is $$ x = 5(y-y_0)^2 + \underbrace{40}_{=-x_0} $$ – Matti P. Jun 04 '18 at 09:58
  • Yes see if I change the 5, the whole curve shifts. It changes how "aggressive" it is, but it also moves the starting point of the graph. I'll try your suggestion. – david_10001 Jun 04 '18 at 10:00
  • Well that's odd, because if $y=0 \Rightarrow x = ay^2 + 40 = 40$ so it doesn't depend on the coefficient ... So what I'm saying is that changing the value of $5$ shouldn't affect the starting point (which should currently be at $x= 40, y= 0$). – Matti P. Jun 04 '18 at 10:04
  • Yes that's why it is messing with me. I can't understand it. At least it's not me, maybe I should take the question down until I work out why the program is not giving understandable results. – david_10001 Jun 04 '18 at 10:09
  • In programming, keep in mind that $(0,0)$ is the top left of the screen. Not the bottom left like in math. – Badr B Jun 04 '18 at 10:13
  • Yes that's why it's a little confusing. And my apologies, I forgot to add my photo. It's a little hard to understand without. – david_10001 Jun 04 '18 at 10:15
  • Ah, so the picture is the current output or the desired output? – Badr B Jun 04 '18 at 10:19
  • Desired. Currently my curve turns in the other direction (towards the right). – david_10001 Jun 04 '18 at 10:20
  • Perhaps try -5y^2+70? It seems like your x and y variables are flipped, but I'm assuming you're drawing points as $(x, y)$ which would make this a square root function. – Badr B Jun 04 '18 at 10:25
  • Yes that is correct. I am currently using ^0.33 which serves as a cubed root. I'll try your above equation with 2 and 0.33 but I'm not getting anything display on the screen – david_10001 Jun 04 '18 at 10:33

0 Answers0