
-----------------------------------
Newguy
Mon May 12, 2008 8:34 pm

Parabola and cosine and sine
-----------------------------------
I created a program that asks the user for the starting x value and y value of the parabola, the x speed , the y speed and the force of gravity and creates the parabola according to the information entered. It works ok. Then I used the search function and found this code written by another member that used cosine and sine  to find the increment and created the arcing trajectory using that. I want to know how it works. Haven't done math in a while so I googled trig functions to get a quick refresher but the code still doesn't make sense to me. Below is my code followed by the code I found. I post you my code because I want to know how to create the parabola according to roots entered by the user and the vertex. I have taken grade 10 math and received above 90 % so I am good with math so I can handle most things, maybe grade 11 that you throw at me. Thanks for the help.

My code:

%Creates parabola according to user values
setscreen ("screenonly")
var x, y : real
var xspeed, yspeed : real
var gravity : real
put "Enter the starting x value (between 0 and 100 recommended)."
get x
put "Enter the starting y value (between 0 and 100 recommended)."
get y
put "Enter the x speed of the trajectory"
get xspeed
put "Enter the y speed of the trajectory"
get yspeed
put "Enter the force of gravity"
get gravity
cls
loop
    x += xspeed
    y += yspeed
    yspeed += gravity
    drawfilloval (round (x), round (y), 1, 1, red)
    View.Update
end loop


Code posted by a user:

const GRAVITY := -0.0001
const ANGLE := 10
var x, y, xSpeed, ySpeed : real := 0
xSpeed := cosd(ANGLE)/5
ySpeed := sind(ANGLE)/5
loop
    x += xSpeed
    y += ySpeed
    ySpeed += GRAVITY
    Draw.FillOval (round (x), round (y), 1, 1, black)
end loop 

This code I need help understanding. Especially the /5 after ANGLE.

This is how I see it and I think it is wrong. ---> cosine formula is cos(theta) = Adjacent / Hypotenuse
theta = ANGLE so 5  must be the hypotenuse right? Therefore you are trying to get adjancent size rite?        Hypotenuse --> /_|
                                                                                                                                                                              ^  Adjacent

Sine formula is sin(theta) = Opposite / Hypotenuse
theta = ANGLE so 5 must be hypotenuse right? Therefore this will get the opposite size rite?           Hypotenuse --> /_| 