[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

319.0. "Pendulum curves" by PIPA::JANZEN () Wed Jul 17 1985 22:51

5 REM Thomas E. Janzen 17 July 1985 Digital Equipment Corporation
10 REM This program runs on a VT125 or a VT240 REM under VAX VMS BASIC 2.3.  It
20 REM draws (directly on the terminal screen) curves that resemble those drawn 
30 REM by typical science museum exhibits of two pendula, one with a table for 
40 REM holding a piece of paper (2), and one with an arm that holds a pen over
50 REM the other's paper (1).  For the purposes of this program, each pendu
60 REM -lum's movements are resolved into two perpendicular components, both 
70 REM sinusoidal.  Each pendulum is simple, and on an ideal universal joint.
80 REM Therefore two components of a pendulum have the same period, but each 
90 REM component may start with any phase.  The two pendula may have different 
100 REM periods.  For practical reasons, a period less than .5 should be speci-
110 REM fied.  A decay exponent, DECAY, is a damping effect, and may be dif-
120 REM ferent on each pendulum, causing them to swing smaller arcs as time pro-
130 REM gresses.  Amplitude, A, if less than 1, will prevent the image from
140 REM leaving the screen.  
150 REM The screen has data space boundaries Xmin=Ymin=-2, Xmax=Ymax=2
160 DIM DECAY(2),FREQ(2),PHI(4),OMEGA(2),A(4)
170 PRINT "Enter the ratio of the frequencies of Pendulum 1 to Pendulum 2: ";
180 INPUT RATIO
190 PRINT "Enter the frequency in hertz of Pendulum 1 (about 1 max): ";
200 INPUT FREQ(1)
210 FREQ(1)=1*FREQ(1)
220 E=2.7182818
230 D=0
240 FREQ(2) = FREQ(1)/RATIO
250 FOR N=1 TO 2 STEP 1
260 OMEGA(N) = 2 * PI * FREQ(N)
270 NEXT N
280 FOR N=1 TO 2 STEP 1
290 PRINT "Enter the Peak Amplitude of Pendulum ";N;"(X)(about 1 max): ";
300 INPUT A((N*2)-1)
310 PRINT "Enter the Peak Amplitude of Pendulum ";N;"(Y)(about 1 max): ";
320 INPUT A(N*2)
330 NEXT N
340 FOR N = 1 TO 2 STEP 1
350 PRINT "Enter the starting phase of Pendulum ";N;"(X) (radians): ";
360 INPUT PHI((N*2)-1)
370 PRINT "Enter the starting phase of Pendulum ";N;"(Y) (radians): ";
380 INPUT PHI(N*2)
390 NEXT N
400 FOR N=1 TO 2 STEP 1
410 PRINT "Enter decay value for Pendulum ";N;" (zero to about .5): ";
420 INPUT DECAY(N)
430 NEXT N
435 REM ERASE THE SCREEN VT100 STYLE
437 PRINT CHR$(27);"[2J"
440 REM CSI = ESC [
450 REM TO ENTER REGIS MODE ON VT125 OR VT240 send a DCS 1 p 
460 REM DCS = ESC P
470 PRINT CHR$(27);"P1p"
475 PRINT "S(E)";
480 FOR N=1 TO 2400 step 1
490 T=N/37
500 REM X1 is Amplitude for the X direction of Pendulum 1.
510 X1=A(1)*E**(-DECAY(1)*T)*SIN(OMEGA(1)*T+PHI(1))
520 REM X2 is Amplitude for the X direction of Pendulum 2.
530 X2=A(3)*E**(-DECAY(2)*T)*SIN(OMEGA(2)*T+PHI(3))
540 X=X1-X2
550 REM Y1 is Amplitude for the Y direction of Pendulum 1.
560 Y1=A(2)*E**(-DECAY(1)*T)*SIN(OMEGA(1)*T+PHI(2))
570 REM Y2 is Amplitude for the Y direction of Pendulum 2.
580 Y2=A(4)*E**(-DECAY(2)*T)*SIN(OMEGA(2)*T+PHI(4))
590 Y=Y1-Y2
600 REM VT125 has 768*480 pixels in left-handed coordinates.
610 SCREENX = INTEGER(INT((X+2)*.75*768/4))+INTEGER(INT(.5*(768-.75*768)))
620 REM Flip over the Y because Screen Y coordinates are upsidedown.
630 SCREENY = 480-INTEGER(INT((Y+2)*480/4))
640 REM For the first point, move the graphics cursor invisibly.
650 IF N=1 THEN PRINT "p[";SCREENX;",";SCREENY;"]"
660 PRINT "v[";SCREENX;",";SCREENY;"]"
670 NEXT N
680 REM ST exit regis mode
690 REM ST = ESC \
700 PRINT CHR$(27);"\"
710 END
T.RTitleUserPersonal
Name
DateLines
319.1PIPA::JANZENWed Jul 24 1985 13:0014
here are good numbers:
1.37
1
1
1
1
1
0
3.5
5.5
2
.01
.02
Tom
319.2PIPA::JANZENSat Jul 27 1985 17:2627
People without a good sense for physics seem to be having trouble
making this program do interesting things, so i include some numbers for
good pictures here.  Also, a Regis person suggested improvements in the
program to eliminate redundant characters.  for example, the "v" in
the vector command v[ x , y ] is needed only the first time, that is,
when n = 2 in the big loop.  Also, the should be a semicolon after
the vector command since without it you send extra linefeeds/CR.
Without a BASIC book, I get run-time errors on a print using statement
to get rid of the spaces in the numbers, screenx and screeny, but my
friend recommended that too.  Also, I estimated the speed of the
program and it now interogates the user for the length of the run.

here are some good numbers for pendula.


Flower
 1.22 1 1 1 1 1 0 2 3 1 0 0 end.
ball of string
 1.01 1 1 1 1 1 0 1 2 4.5 0 0
 45 seconds.  a modified program includes the length of run in seconds.
end.

Xtal
 1.22 100 1 1 1 1 0 4 2 6 0 0
 2 seconds.

Tom
319.3PIPA::JANZENSat Jul 27 1985 17:296
space.txt
 1.01 1 1 1 1 1 0 1 2 4.5 0 0 56.5 end.
lissajous
 10 1 0 1.9 1.9 0 0 0 0 0 0 0 end.

Tom
319.4SPRITE::OSMANMon Jul 29 1985 17:3312
I have a hard time transfering all those numbers from my screen to either
file or head, and then back to the program in order to try out the pictures.

How about a version of the program that lets me optionally select a choice
such as "ball" or "lissajous" or "xtal", and the program draws it.

Or perhaps merely a version of the program that does 30 seconds of each
of the ten or so acknowledged "nice pictures".

Thanks.

/Eric
319.5VAXINE::LPIPERMon Jul 29 1985 17:567
WELL, MY HAT IS CERTAINLY OFF TO THOSE WHO CAN CREATE PROGRAMS SUCH AS THIS!

BEING A PERSON THAT HAS A HARD TIME PROGRAMMING A MICROWAVE OVEN, I AM IMPRESSEDWITH ALL OF THIS, BUT I DID LEARN SOMETHING FROM COPYING (AND USING) THIS PROG-
RAM.  

JUST THOUGHT THAT TOM JANZEN MIGHT LIKE TO HEAR (SEE?) THE ABOVE.
319.6PIPA::JANZENTue Jul 30 1985 16:229
re: -1
After dead silence for so long, I enjoyed your response.
I wish the mathies would say something, but it's probably too close to the
physical world for them.  I worked hard to make the program close to
the actual pendula in the musuem, and to be very general.
I'll let you know here if I make other versions.
You can send me mail if you want the current version, which asks
for the stuff mentioned a few replies back.
Tom
319.7BAGELS::ROSENBAUMWed Jul 31 1985 02:5513
I've enjoyed it as well.

Re: .4:

	What I did, was extract the note into a file, edit a little (remove
the header, put each number on a separate line, and then:

		$define/user sys$input file.ext  (your extracted filename)
		$Run pend			 (or whatever you call it)
 
Actually i wrote a two line command procedure that does the above.

__Rich
319.8PIPA::JANZENWed Jul 31 1985 17:0519
The new pendula programs are as follows:
PIPA""::STD:[JANZEN.PUBLIC]PENDULA.BAS
PIPA""::STD:[JANZEN.PUBLIC]EASYPEND.BAS

PENDULA.BAS has been improved as follows:
o  The source code is formatted for for better visual acuity.
o  The code is more compact.
o  Extraneous and redundant characters have been eliminated.
o  The user is asked for the length of the run of the program.
0  The coordinates have been squared up.  Circles are circular now.
Note that the user should time the program on their system and adjust 
the variable SPEED accordingly although this isn't necessary to run it.

EASYPEND.BAS now, as requested, has a menu of four drawings to draw.
The four figures are, flower, ball (sort of), spiral, and a lissajous pattern.

Behold, a circle : 1 1 0 2 2 0 0 0 1.57 0   0   0 5
Oila,   a spiral:  1 1 0 2 2 0 0 0 1.57 0 .02 .02 60
Meanwhile, I'm quitting.  I'm getting dizzy. have fun, Tom
319.9SPRITE::OSMANThu Aug 01 1985 17:5610
Thanks! I tried EASYPEND and it's really nice.  What you may want to consider
is one more menu item called CUSTOM, which when selected lets the user
type in their own numbers.

That way, you'll only need one version of the program.

Good work.

/Eric
                 
319.10PIPA::JANZENThu Aug 08 1985 15:526
These programs have been incrementally improved again.
The image is centered on the screen.
A program has been added, pipa::std:[janzen.public]looppend.bas
which runs without intervention through 21 images.
easypend.bas also has the 21 images instead of 4.
Tom
319.11SPRITE::OSMANTue Aug 13 1985 16:297
I get

%COPY-E-OPENIN, error opening PIPA::STD:[JANZEN.PUBLIC]OOPPEND.BAS; as input
-RMS-E-FNF, file not found

What's the correct name ?

319.12R2ME2::GILBERTTue Aug 13 1985 18:571
It's spelled LoopPend in .10, but your error message has OopPend.
319.13PIPA::JANZENWed Aug 14 1985 21:384
try reading [janzen.public]help.txt first.
I also have a spectular color one of a fixed figure if you ask nicely through
mail.
Tom
319.14SPRITE::OSMANThu Aug 15 1985 21:1610
	$ mail
	MAIL> SEND
	To:  PIPA::JANZEN
	Subj: Be that color one for the vt241 ?
	Message, end with Ctrl/Z
	If so, could you please tell us where it is ?  Thanks.
	^Z
	MAIL>

319.156263::JANZENFri Dec 27 1985 20:037
Many improved and various versions of the programs are currently
in 
{cougar,tiger,pldvax,angora,morris}::userl:[janzen.public]*.bas
Please don't try to take other stuff that is not *.bas.
I think pend.dat is OK to take, and so is help.txt.
I may be moving to std disk soon on the same cluster.
Tom
319.16bouncing balls...MUNICH::GESCHWINDNERWas hatt'n de' Pappa da.....Thu Mar 08 1990 11:0666
Maybe this reply should better go to the TERMINAL_ART conference, but 
after I saw this entry here it might be nice posting this little program
here. It draws lines between two 'bouncing balls' (not what you mean)
on the screen in ReGis. You can define speed (in pixels) of the points
and the amount of lines staying on the screen before they get deleted again.
If you choose speed 1 and 2 on a vt3xx and let a 1000+ lines printed
you'll see even some interference between the drawn and deleted lines.

Have Fun
   Patrik

P.S. its BASIC..... and you have to stop it by ^Y(^C)....
p.p.s. If someone is interested in.. the game could be continued with more
       then 2 points....


     open "tt:" for output as file #1
     input "speed point 1 ";m
     input "speed point 2 ";n 
     input "lines to rem. ";x
     dim a$(x)

     print #1,"\Pps(e)s(m0(l0),m1(l25),m2(l50),m3(l75))"
     print #1,"w(v,n0,p11111111(m2),s0,m1,a0,i(W))t(a0,d0,s1,h2,i0)w(s0)s(i(D))"
                                
     ix=1 \ kx=1 \ jy=1 \ ly=1  ! Direction setup forward

     i=400 \ j=240              ! Start point 1
     k=400 \ l=300              ! Start point 2
                                             
     a=1
 loop:
     a$="p["+str$(i)+","+str$(j)+"]v(s)["+str$(k)+","+str$(l)+"](e)"
     print #1,"w(i3)";a$

     a$(a)=a$                   
     b=a+1
     b=b-x if b>x 
     print #1,"w(i0)"+a$(b)
     a=a+1 
     a=1 if a>x 
        
     i=i+m*ix
     j=j+m*jy
     k=k+n*kx
     l=l+n*ly

     if i<0 or i>750 
        then ix=ix*-1
             i=i+m*ix
     end if
     if j<0 or j>480 
        then jy=jy*-1 
             j=j+m*jy
     end if
     if k<0 or k>750 
        then kx=kx*-1
             k=k+n*kx
     end if
     if l<0 or l>480 
        then ly=ly*-1 
             l=l+n*ly
     end if
     goto loop
     end

319.17It should be added to TERMINAL_ART VMSDEV::HALLYBThe Smart Money was on GoliathThu Mar 08 1990 15:054
    Cute!  I used 11,7,888 and the screen appeared to be filled with TWO
    growing bands of lines -- one white, the other black.
    
      John
319.18For those who like curves more...MUNICH::GESCHWINDNERWas hatt'n de' Pappa da.....Fri Mar 09 1990 09:2083
re: .16

For those who like curves more than straight lines.....

Patrik

     open "tt:" for output as file #1
     input "speed point 1 ";p1s
     input "speed point 2 ";p2s

     input "lines to rem. ";x
     dim a$(x)

     ! Bring Terminal into ReGis mode and set up masks

     print #1,"\Pps(e)s(m0(l0),m1(l25),m2(l50),m3(l75))"
     print #1,"w(v,n0,p11111111(m2),s0,m1,a0,i(W))t(a0,d0,s1,h2,i0)w(s0)s(i(D))"
      
     ! Points initial location and direction setup forward 

     p1x=400 
     p1y=240 
     p1xd=1 
     p1yd=1
     p2x=600 
     p2y=400 
     p2xd=1 
     p2yd=1
     a=1

     ! build string to print triangle

 loop:
     p1xp=int(390+390*cos(p1x/780*2*pi))
     p1yp=int(240+240*cos(p1y/480*2*pi))
     p2xp=int(390+390*cos(p2x/780*2*pi))
     p2yp=int(240+240*cos(p2y/480*2*pi))

     a$="p["+str$(p1xp)+","+str$(p1yp)+"]v(s)["+str$(p2xp)+","+str$(p2yp)+"](e)"
     print #1,"w(i3)";a$

     a$(a)=a$                      ! Remember drawn line
     b=a+1
     b=b-x if b>x
     print #1,"w(i0)"+a$(b)        ! line to be erased
     a=a+1
     a=1 if a>x                    ! next entry in line memory
   
     ! move points

     p1x=p1x+p1s*p1xd \ p1y=p1y+p1s*p1yd
     p2x=p2x+p2s*p2xd \ p2y=p2y+p2s*p2yd
     p3x=p3x+p3s*p3xd \ p3y=p3y+p3s*p3yd

     ! Check for screen limits and reverse direction if neccessary

     if p1x<0 or p1x>750 
        then p1xd=p1xd*-1
             p1x=p1x+p1s*p1xd
     end if
     if p1y<0 or p1y>480 
        then p1yd=p1yd*-1 
             p1y=p1y+p1s*p1yd
     end if
     if p2x<0 or p2x>750 
        then p2xd=p2xd*-1 
             p2x=p2x+p2s*p2xd
     end if
     if p2y<0 or p2y>480 
        then p2yd=p2yd*-1 
             p2y=p2y+p2s*p2yd
     end if
     if p3x<0 or p3x>750 
        then p3xd=p3xd*-1 
             p3x=p3x+p3s*p3xd
     end if
     if p3y<0 or p3y>480 
        then p3yd=p3yd*-1 
             p3y=p3y+p3s*p3yd
     end if    
     goto loop
     end