Jump to content
IGNORED

# Sine Demo

## Recommended Posts

Tursi, how would you make this SIne Wave move down the screen unbroken? I changed some values from the originals experimenting,

but did not get it to be continuous on screen.

10 PRINT TAB(30);"SINE WAVE"

20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"

30 PRINT :: PRINT :: PRINT :: PRINT :: PRINT

50 B=0

110 FOR T=0 TO 40 STEP .25

120 A=INT(26+25*SIN(T))

130 PRINT TAB(A);

140 IF B=1 THEN 180

150 PRINT "CREATIVE"

160 B=1

170 GOTO 200

180 PRINT "COMPUTING"

190 B=0

200 NEXT T

999 END

##### Share on other sites

I remember that program.

You just have to fix the width. You only have 28 columns across the screen for PRINT. "COMPUTING" is 9 characters wide, so you need a range from 1-17 for TAB().

As I explained on the list, SIN() returns a value from -1 to +1. So your math needs to deal with that. The fact that he loop counts from 0 to 40 is mathematically arbitrary, but works just as well as carefully chosen values in this case.

So the problem boils down to line 120, which needs to convert a floating point range from -1 to +1 into an integer range from 1-17. The original range is 2 (-1 to +1), and the new range is 16 (1-17) so 16/2 gives us 8 as the ratio.

So, if we multiply the output of SIN by 8, the new range is -8 to +8. We want 1-17, so we add 9. Now we have the range we want.

The other function in there is INT, which truncates a number to an integer.

So the new 120 is:

120 A=INT(9+8*SIN(T))

And that should fit on the screen.

Feel free to experiment - always experiment. Also, there are lots of skilled people here, no need to single me out. I'm on vacation.

##### Share on other sites

Thanks. I was just replying and wanted to send pictures. I heard you were good to ask though, by someone on the group. I played around with the numbers of the SINE parameters before reading your message, but came up with the wrong numbers each time. I will mess around further and see what happens when I change things in hopes of learning something more.

Edited by orion1052003

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
• ### Recently Browsing   0 members

• No registered users viewing this page.
×
×
• Create New...