[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

1072.0. "Spirograph Problem and Program" by CHEST::LEE (IAM4C2H5COOH) Tue May 02 1989 09:46

    Hi All ,
    
    I need some help with my maths , not being as proficient as most
    of the contributors in this conference seem to be . I can Understand
    it but I can't do it . Any way Here's the problem . I wrote a Program
    to emulate the drawing Motion of SPIROGRAPH . I tried to work out
    the formula myself but I got stuck . Anyway I got the answer out
    of a book but I don't understand how they got to the answer .
    
    For those of you who don't know  SPIROGRAPH consists of a circular
    hole that you pin down on a piece of paper . Into which you place
    a smaller disc which has holes in at various radii . Placing a pencil
    in one of the wholes and keeping the Inner disc in contact with
    the outer hole ( they have teeth so they don't slip ) and moving
    the inner disc around produces Aesthically pleasing patterns on
    the paper .
    
    To mathematically model this for the computer :
    
    a     is the radius of the outer hole.
    b     is the radius of the inner disc.
    d     is the radius from the centre of the disc to the hole where
    	  the pencil is placed
    
    O     is the angle between the positive x axis and the point of
    	  contact between the disc and the outer Hole . (in radians)
    P     is the angle between the positive x axis and the position
    	  of the whole were the pencil is placed . (in radians)
    
    Therefore we plot :
    			X               Y
    	( (a-b)*cos(O)+d*cos(P) , (a-b)*sin(O)+d*sin(P) )

    The problem is :
    
    how do I relate The movement of O to P and how many
    times do I rotate O around 360 degrees until I meet up with the
    starting point . 
    
    I know this much :
    
    To gain the formula for P expressed in terms of O one works out
    the distance travelled by the point of contact for one 360 revolution
    in terms of the outer hole  and the inner disc . Once you have these
    2 equations , by a process which I can't fathom the book comes out
    with the answer
    
    P=((a-b)/b)O
    
    Any comments appreciated
    
    Phil

    P.S if you are interested The .exe is located at
    
    CHEST::$98$DUA4:[LEE.PUBLIC.PROGS]SPIROGRAPH.EXE
    
    and runs on vt125,240,330,340 series.
T.RTitleUserPersonal
Name
DateLines
1072.1Help STill neededCHEST::LEEIAM4C2H5COOHThu May 04 1989 13:4659
    Ok , Heres part of the solution I have managed to work out . Its
    a practical method but I would love to see the Theoretical proof
    of this , if indeed it exist .
    
    The Problem of how to generate the angle of rotation of the inner
    disc in relation to the angle of point of contact . Refer to .0
    for a full explaination .
    
    Take discs of vary sizes and rotate one of them around the other to build
    up data on the ratio between the size of discs used and the
    number of times the rotating disc turns on its centre around
    the stationary disc .
    
    For example . Take two discs both of radius 2 units
    The outer disc  rotates 2 twice ( 2x360 degree rad) exactly as the
    point of contact rotates once around the inner stationary disc 
    .
    
    SO ratio between the two discs is 2:2 . Number of rotations = 2
    
    Do this for ratio 2:1 ,3:1,3:2 etc.. see below
    
    where a is the radius of the station disc and r is the radius of
    the rotating disc .
    
    a		b		Ratio a:b		(a+b)/b
    
    1		1		1:1			2/1	2
    2		1		2:1			3/1	3
    3		1		3:1			4/1	4
    4		1		4:1			5/1	5
    1		2		1:2			3/2	1.5
    2		2		1:1			4/2	2
    3		2		3:2			5/2	2.5
    4		2		2:1			6/2	3
    1		3		1:3			4/3	1.333333..
    2		3		2:3			5/5	1.666666..
    3		3		1:1			6/3	2
    4		3		4:3			7/3	2.333333..
    1		4		1:4			5/4	1.25
    2		4		1:2			6/4	1.5
    3		4		3:4			7/4	1.75
    4		4		1:1			8/4	2

    And so on . Notice the colomn (a+b)/b relates exactly to the number
    of complete revloutions b turns against the posotive x axis after
    completing one revolution of a .
    
    In spirograph the b would be rotaing in the opposite direction to
    the above example
    
    This has got something to do with it but I don't no what . Please
    , I would love some Explainational proof ........
    
    PLEASE,PLEASE,PLEASE any ideas welcomed
    
    Phil    
    
    
1072.2try playing with these...CTCADM::ROTHIf you plant ice you'll harvest windFri May 05 1989 07:3756
    If the centers of the disks were fixed, then their angles would turn
    in the ratio a/b - just like gears on a shaft...

    But the inner gear is stationary so you have to subtract the angle of
    the point of contact on the inner gear

	a/b-1 = (a-b)/b

    You can get very nice patterns by drawing straight lines from one point
    to the next on the "rose" - an n-lobed pattern with the function

	x = (1+cos(n_lobes*theta))*cos(theta)
	y = (1+cos(n_lobes*theta))*sin(theta)

	n_lobes = number of lobes of pattern

    This "modulates" the amplitude of a turning radius vector.

    Choose a prime number of points over the interval 0 <= theta <= 2*PI,
    and connect the ones k points apart modulo your prime, p, where k is
    a nonzero integer less than p.

    That is,

	xold = 0
	yold = 0
	j = 0
	for i = 1 to prime do
	    j = j+k mod prime
	    theta = 2*pi*j/prime
	    xnew = (1+cos(n_lobes*theta))*cos(theta)
	    ynew = (1+cos(n_lobes*theta))*sin(theta)
	    plot line from (xold,yold) to (xnew,ynew)
	    xold = xnew
	    yold = ynew
	    end

    This same method will give nice patterns if you substitue your polar
    equations for the spirograph (which is an epicycloid/epitrochoid type
    of curve.)  Also, try simple lissajous patterns

	x = cos(m*theta)
	y = sin(n*theta)
	m, n = integers

    A further variant is to vary the color of the lines over the range
    of points; this looks very nice on a graphic display where you are
    can additively set the colors in your frame buffer.  Choosing the
    three primaries, red/green/blue for your colors gives a rainbow of colors
    where overlapping lines produce the other colors (for example, a red
    and green line will overlap to give yellow.)

    The prime number is no restriction, but gives the best looking patterns
    be eliminating any degenerate patterns.

    - Jim
1072.3More Picture GeneratorsCHEST::LEEIAM4C2H5COOHMon May 08 1989 13:4010
    Well if anyone is interested I tried Jims first Idea . To generate
    Prime numbers I took one of the Polynomial Prime number Generating
    Functions f(x)=x�+x+41 which is produces Primes for 0<=x<=39 . The
    program randomly choses the value x and the Number of Lobes as well .
    
    You can find the .exe @ . runs on vt240 ,330,340 . Have Fun ..
    
    CHEST::$98$DUA4:[LEE.PUBLIC.PROGS]SHAPESHIFTER.EXE
    
    Phil
1072.4Correction and questionIJSAPL::TWIGTKoos TwigtFri Feb 16 1990 05:0126
RE: 1072.0

>    To gain the formula for P expressed in terms of O one works out
>    the distance travelled by the point of contact for one 360 revolution
>    in terms of the outer hole  and the inner disc . Once you have these
>    2 equations , by a process which I can't fathom the book comes out
>    with the answer
>    
>    P=((a-b)/b)O
    
    I think this relation is incorrect and should be : P = -(a/b)*O
    The increment of O causes P to decline, which explains the minus sign.
    Furthermore, the point of contact between the whole and the disc
    travels a*O on the outer hole and b*(-P) on the disc, and these two are
    obviously equal.
    
    A further question is: can someone eliminate P and O from the
    expressions for X and Y (the coordinates of the pencil), resulting in a
    single expression for X and Y ? This would allow for the definition of
    a function F(X,Y) by which one could determine for each (X,Y) whether
    F(X,Y) >, = or < 0. Using this sign of F(X,Y), the entire plane could be
    filled in, using black and white (or even many different colours,
    as assigned to defined ranges of F).
    
    Koos Twigt