Subject: Random Dot Sinewave Carpet

From: [email-masked] (Simon)
Date: 15 Jul 92 21:02:11 GMT

What follows was the first RDS that I made.  After I posted
some later RDS's, I got many questions about how to make
these, so I thought that I would explain a simple one by
showing the generic code that produced it.  (More complete C
code for a torus was recently posted to this newsgroup by someone
else.)  I hope this shows the principle involved in generating
RDSs.  The following is not in an actual language, it's just
heuristic.

    C Code to generate a Sinewave Carpet
    C First lay down a random patch 100 pixels wide
    C Assume the screen size is 600 x 400

    for i 1 100
      for j 1 400
          point(i,j)=Round(Rand)  C Rand generates a random number
      endfor                      C between 0 and 1 and Round makes
    endfor                        C it 0 or 1

    C Now generate the rest of the patern and introduce a sine
    C wave modulation.  

    for i 101 600
      for j 1 400
          point(i,j)=point(i-100+B*sin(i/A),j) 
      endfor
    endfor

    C If point(i,j) is zero, don't put a point, if it's one, do.

It's that simple.  Have fun.

The following is a large amplitude sinewave in a random dot
stereogram.  It is a postscript file.
---------------------------CUT HERE--------------------------------
%!
%% Martin Simon 7-92 Sinewave

[ rest omitted ]