Page 1 of 1
Pendulum
Posted: Sat Dec 31, 2016 4:38 pm
by Dutchman
One of Rosetta's tasks is a pendulum.
Code: Select all
'Pendulum
' --- constants
g=9.81 ' accelleration of gravity
l=1 ' length of pendulum
GET SCREEN SIZE sw,sh
pivotx=sw/2
pivoty=150
' --- initialise graphics
GRAPHICS
DRAW COLOR 1,0,0
FILL COLOR 0,0,1
DRAW SIZE 2
' --- initialise pendulum
theta=1 ' initial displacement in radians
speed=0
' --- loop
DO
bobx=pivotx+100*l*SIN(theta)
boby=pivoty-100*l*COS(theta)
GOSUB Plot
PAUSE 0.01
accel=g*SIN(theta)/l/100
speed=speed+accel
theta=theta+speed
UNTIL 0
END
' --- subroutine
Plot:
REFRESH OFF
GRAPHICS CLEAR 1,1,0.5
DRAW LINE pivotx,pivoty TO bobx,boby
FILL CIRCLE bobx,boby SIZE 10
REFRESH ON
RETURN
Please post it on Rosetta if you can.
I do not want to take the threshold to find my way there
Re: Pendulum
Posted: Sat Dec 31, 2016 5:10 pm
by rbytes
I have posted it for you. If you check the smart Basic page on Rosetta, the link to your item is listed under A for Animating a Pendulum.
I wanted to include a screenshot, but it seems that image uploads have not been working since last summer. Maybe sarossel can track down the webmaster and get him to take a look.
Re: Pendulum
Posted: Sat Dec 31, 2016 5:37 pm
by sarossell
Thanks rbytes for posting Dutchman's code on Rosetta. I'll reach out to the webmaster and see what gives.
Re: Pendulum
Posted: Sat Dec 31, 2016 5:45 pm
by sarossell
Really cool Dutchman. I don't know why I was surprised at how smoothly and realistically it displays, but I was. I still have condescending echoes in my head from narrow-minded C programmers telling me that BASIC is slow and useless. I'm getting over that very quickly.
Re: Pendulum
Posted: Sun Jan 01, 2017 8:25 am
by Henko
Deleted
Re: Pendulum
Posted: Sun Jan 01, 2017 8:33 am
by Dutchman
Henko wrote:Ah! C programmers are narrow minded. Good to know.
That is NOT what has been said
Many users of that error-prone language however despise BASIC.
Re: Pendulum
Posted: Sun Jan 01, 2017 8:44 am
by Henko
I tried to delete the post, but was too late. Sorry.
Re: Pendulum
Posted: Sun Jan 01, 2017 9:25 am
by Mr. Kibernetik
Each language has its purpose.
If someone will try to create an effectively running BASIC then he ends up in a C-like BASIC, which is not BASIC anymore.
But genuine BASIC is very simple in usage, but it cannot be used for professional coding.
This can be compared to cars. C is a sport car. It is very fast to run but it requires a professional usage. Even starting an engine can be a difficult procedure. But using a sport car for everyday run may be not so easy.
BASIC is a family car. It is very easy to handle by anyone, but it is slow and cannot be compared with sport car on a track.
The main idea is that not everybody needs a fast running racing car, but only C language is popular nowadays. Many tasks can be performed in BASIC, and it will take much less efforts to do.
Re: Pendulum
Posted: Sun Jan 01, 2017 5:19 pm
by sarossell
Ah, what I should have said was "narrow-minded programmers who HAPPEN TO program strictly in C." Many of my consulting jobs were for U.S. military contractors populated by myopic managers who hired programmers like Marines. If it wasn't "C++ Oorah!" it was crap in their eyes. I don't have anything against the language (or any other language for that matter - that would be silly). Each tool for its job.