Pendulum

Post Reply
User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Pendulum

Post 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 :P

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Pendulum

Post 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.
The only thing that gets me down is gravity...

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Pendulum

Post by sarossell »

Thanks rbytes for posting Dutchman's code on Rosetta. I'll reach out to the webmaster and see what gives.
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Pendulum

Post 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.
smart BASIC Rocks!

- Scott : San Diego, California

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Pendulum

Post by Henko »

Deleted
Last edited by Henko on Sun Jan 01, 2017 8:43 am, edited 1 time in total.

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Pendulum

Post 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.

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Pendulum

Post by Henko »

I tried to delete the post, but was too late. Sorry.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Pendulum

Post 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.

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Pendulum

Post 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. :D
smart BASIC Rocks!

- Scott : San Diego, California

Post Reply