Is it possible to create a hyperbola on HS?

I was wondering if it was possible to create a graph of a hyperbola on Hopscotch. It’s either not possible or really hard, because hyperbolas aren’t functions, which makes them a lot more confusing to code.

I attempted to make one (didn’t go very well) by isolating the y of the hyperbola equation so I could put it into the y in the set position block. But I had no idea what to put for the x position, so I just put self x position + 3, which I’m sure is wrong.

Does anyone have any thoughts?

9 Likes

two clones
one draws bottom half
other draws top half

i believe that would work
but i havent worked with hyperbolas in a while

8 Likes

oh yeah, that seems right, I’ll test it out right now

6 Likes

wait so what would the equation be for half a hyperbola?

e: oh nevermind I just found it

6 Likes

I think I’m doing something wrong because it’s not working

the equation should be y=√([a^2+x^2]/a)

6 Likes

I looked up the standard formula for a hyperbola, did the do-undo method, and got to the following equations for the X and Y:

x=\frac{1+\frac{y}{b}^2}{a^2}

y=\frac{1+\frac{x}{a}^2}{b^2}

6 Likes

interesting! i just plugged the equations into desmos, this is what they look like:

I’ll see if I can get your equations to work in hopscotch

6 Likes

Btw, you can simply your y equation to the following:

y=\sqrt{x^2+a}

This is because \frac{a^2}{a} = a because one of the a’s cancel each other.

7 Likes

Yeah, the stage origin is in the bottom left corner, not the center. To fix this, just add width/2 and height/2 to their appropriate places…

4 Likes

this looks correct - just add +512 to the x and +384 to the y of the graph - to center it on the screen

6 Likes

do I add it to the starting position block? because I tried it and it didn’t work… I also tried to add it to the set position block in the draw a trail thing and it didn’t work either, unless I’m doing it completely wrong

4 Likes

Try subtracting it from everywhere you use the x positions & y position vars.

5 Likes

okay so I added +w/2 to both x positions and +h/2 to both y positions but now all it does is draw a straight line

3 Likes

oh I found the issue, I was supposed to subtract 512 from the self x position variable

now I have half of a hyperbola lol

thanks for the help!

who should I mark as solution?

5 Likes

why is the function discontinued on the left? /gq /conf

4 Likes

i actually don’t know. making the a and b values negative doesn’t change anything, and when I put the exact equation in desmos, the function is complete

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.