
-----------------------------------
14fenix
Fri Sep 26, 2003 2:26 pm

Basic gravity equation.
-----------------------------------
This is a very simple program thats like a sort of hwk for my compsci class yet Im stumped because I keep gettin "Argument is the wrong type" message. All the program has to be is a ball falling towards the ground, each pixel = 1 m and the acceleration is 32 / t ** -2. 

Any help?? Pretty n00bish question but I gotta start somewhere. Here is my code so far



setscreen ("graphics")
var x, y, t, a, ymax : real
ymax := 399
t := 0
x := 20
a := 32 / t ** 2
loop
    y := ymax - 9.8 * a * t ** -2
    drawfilloval (20, y, 6, 6, 5)
    t := t + 1
    delay (1000)
end loop



Thanks.

-----------------------------------
PaddyLong
Fri Sep 26, 2003 3:56 pm


-----------------------------------
it's because the draw methods take integer parameters, and you are trying to give real ...
as a solution to this, use round(someReal) to turn it into an integer ...

in your case, you would change
drawfilloval (20, y, 6, 6, 5) 
to be
drawfilloval (20, round(y), 6, 6, 5) 

however, you have other problems in your program and I will give you a hint to start t at 0.1 rather than 0 or change your equation for solving a

-----------------------------------
Tony
Fri Sep 26, 2003 4:45 pm


-----------------------------------
yeah, your equation is really messed up. Your acceleration is constant = 9.81. You dont need acceleration variable.


D = Vi*T + (1/2)(A)(T^2)


Knowing physics really comes in handy when you're programming physics related stuff.

So your code should be:


for t:1..10
     Draw.FillOval(100,maxy - round(4.9*t*t),5,5,red)
end for


a bit of expanation here:

since Vi is 0, first part of formula is 0.

4.9 is (1/2) or acceleration (which is 9.81)

*t*t is time squared. pow() (** in turing) is a function and will slow down your program. If the power is a constant integer, write it out - program works faster.

-----------------------------------
14fenix
Fri Sep 26, 2003 5:18 pm


-----------------------------------
Wow its amazing how simple it really was lol. Im using a Turing handbook from school that gave me the weird acceleration equation so I thought I'd use it but I did know gravity = -9.8 m/s^2

Thanks a lot.

-----------------------------------
krishon
Fri Sep 26, 2003 5:20 pm


-----------------------------------
well the gravity varies depending on the location, but only by like .02 or .01 so no huge difference....but in rocket science that's a different matter

-----------------------------------
vexd
Sat Sep 27, 2003 9:15 pm


-----------------------------------
/\d = 1/2*A */\t ** 2 + V1 * /\t


^ best equation :P

-----------------------------------
thoughtful
Sat Oct 11, 2003 8:50 pm

Try this
-----------------------------------
Try this code 

var x : int := 100
for decreasing t : 10 .. 1
    Draw.FillOval (x, maxy - round (4.9 * t * t), 5, 5, red)
    x := x + 15
    delay (30)
end for
for t : 1 .. 10
    Draw.FillOval (x, maxy - round (4.9 * t * t), 5, 5, red)
    x := x + 15
    delay (30)
end for


-----------------------------------
Prince
Sat Oct 11, 2003 9:52 pm


-----------------------------------
/\d = 1/2*A */\t ** 2 + V1 * /\t


^ best equation :P
what equation is that? :?

-----------------------------------
Tony
Sat Oct 11, 2003 10:16 pm


-----------------------------------
change in distance equals to initial velocity multiplied by change in time plus half of acceleration multipled by time squared.

 :lol: 

you can find distance traveled by accelerating object using acceleration and time  :wink:

-----------------------------------
rizzix
Sat Oct 11, 2003 10:26 pm


-----------------------------------
lol thats a delta symbol o ok. sheesh i was wondering what he meant by that  :lol:

nice avatar

-----------------------------------
rizzix
Sat Oct 11, 2003 10:45 pm


-----------------------------------
ok i just realised i'm using a mac so to show off:

Option + j = &#8710; (delta)
Option + d = &#8706; (partial differential)
Option + m = Âµ (mu)
Option + w = &#8721; (sigma)
Option + b = &#8747; (integral)
Option + x = &#8776; (aprox equal to)
Option + r = Â®
Option + g = Â©
Option + 2 = â„¢
Option + f = Æ’
Option + s = ÃŸ (beta)
Option + z = &#937; (omega)
Option + p = &#960; (pie)
Option + 5 = &#8734; (infinity)
Option + v = &#8730; (square root)
Option + Command + k = Â° (degrees)
Option + , = &#8804;
Option + . = &#8805;
Option + / = Ã·
Option + = = &#8800;  (not equal to)


a lot more but these are the most useful ones

-----------------------------------
Tony
Sat Oct 11, 2003 10:50 pm


-----------------------------------
what encoding are you using? cuz symbols are all screwed up for me

-----------------------------------
rizzix
Sat Oct 11, 2003 10:55 pm


-----------------------------------
oh! unicode.. it shows all.. thus i always use it (default encoding)

anyhow i switched to the western ISO encoding.. it seems it's more popularly used by windows users :/

-----------------------------------
Mazer
Sun Oct 12, 2003 8:27 am


-----------------------------------

a lot more but these are the most useful ones

well that's good. hey maybe someday people will actually be able to pronounce (and draw) those letters without pissing me off.  :lol: hah, but that will never happen
