Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #902

Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?

From luser- -droog <mijoryx@yahoo.com>
Newsgroups comp.lang.postscript
Subject Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Date 2012-08-23 23:58 -0700
Organization http://groups.google.com
Message-ID <67041f2e-e3e3-44e6-99ee-3d4accbaed25@googlegroups.com> (permalink)
References (2 earlier) <3d013aa0-e8c0-4db9-8a03-ed29b2eba2cf@googlegroups.com> <fg280ctdmlnb.61z3ivwjxw33$.dlg@40tude.net> <3cb138c8-2147-48a6-b90a-91c8cc7e6d29@googlegroups.com> <c50v0wb3pdm3$.hes4quvy1zz1.dlg@40tude.net> <5638890b-933f-4f37-9635-7fbd3daec2c5@googlegroups.com>

Show all headers | View raw


On Friday, August 24, 2012 1:11:09 AM UTC-5, luser- -droog wrote:
> On Friday, August 24, 2012 12:45:13 AM UTC-5, tlvp wrote:
> 
> > On Thu, 23 Aug 2012 13:00:15 -0700 (PDT), luser- -droog wrote:
> 
> > 
> 
> > 
> 
> > 
> 
> > > I've made a little progress here. It still generates the points
> 
> > 
> 
> > > with the O(n^3) brute force algorithm, but it saves the points
> 
> > 
> 
> > > to a data file called "stein.pts" so subsequent pages are much
> 
> > 
> 
> > > less agonizing.
> 
> > 
> 
> > 
> 
> > 
> 
> > Ah, yes, why carry out the same calculations at every re-run-through?
> 
> > 
> 
> >  
> 
> > 
> 
> > > Rotations and projections are applied to each point, and then
> 
> > 
> 
> > > it draws a little circle to represent the projected point.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > %!
> 
> > 
> 
> > > % Point-field sampling
> 
> > 
> 
> > > % with data caching (in a file),
> 
> > 
> 
> > > % point-wise axial rotations,
> 
> > 
> 
> > > % and perspective projection. ...
> 
> > 
> 
> > 
> 
> > 
> 
> > Details suppressed in this reply, as I don't speak to them directly.
> 
> > 
> 
> > 
> 
> > 
> 
> > >  ...   showpage
> 
> > 
> 
> > > } for
> 
> > 
> 
> > 
> 
> > 
> 
> > That's neat, luser -drug, many thanks; and the rapid succession of images
> 
> > 
> 
> > helps fill in some details the imagination requires.
> 
> > 
> 
> > 
> 
> > 
> 
> > What are the chances, though, that, in each successive sweeping out of the
> 
> > 
> 
> > next image, the color used at each given moment can be somehow keyed to
> 
> > 
> 
> > that moment? By that I mean (dividing the time-parametrization interval for
> 
> > 
> 
> > each sweeping out into 4 main subintervals [0, 1/4], [1/4, .5], [.5, .3/4],
> 
> > 
> 
> > and [3/4, 1], to use the colors [rgb] = [FF, (4t)xFF, 0] for t in [0, 1/4],
> 
> > 
> 
> > the colors [rgb] = [(2 - 4t)xFF, FF, 0] for t in [1/4, .5],
> 
> > 
> 
> > the colors [rgb] = [0, FF, (4t - 2)xFF] for t in [.5, .3/4], and
> 
> > 
> 
> > thecolors [rgb] = [0, (4 - 4t]xFF, FF] for t in [3/4, 1],
> 
> > 
> 
> > thereby swooping through the visible spectrum from red = [FF 0 0] through
> 
> > 
> 
> > [FF FF 0] through green = [0 FF 0] through [0 FF FF] to blue = [0 0 FF] on
> 
> > 
> 
> > each "sweep".
> 
> > 
> 
> > 
> 
> > 
> 
> > I can't quite isolate that sweep-time parameter in your depiction of the
> 
> > 
> 
> > routine, or I'd try to see what that coloration-effect achieves, myself.
> 
> > 
> 
> 
> 
> Yeah, parametrization is the next step. 
> 
> And real matrix transformations.
> 
> Should be able to radically improve the speed
> 
> and clarity. I might scale it back to just 2 cylinders
> 
> until I get a better handle on it.


Well, here's one way to add color.
The generator is really just a triple loop

  for x = -2.2 .. 2.2 step 1/res
    for y = -2.2 .. 2.2 step 1/res
      for z = -2.2 .. 2.2 step 1/res
        if (f(x,y,z)) { plot(x,y,z) }

So the "sweep" is along the x-axis of the object
(ie. pre-rotation). So if we snag the x coord
and shift and scale it to 0..1, we can get a 
rainbow with sethsbcolor (my go-to color trick).
The nice benefit is that it turns pale blue 
right in the center where the cross section becomes
a circle. Everywhere else it's a truncated circle
or a square.

I've also reduced the number and size of the points
and tweaked the fuzz to get more moire. 

49(1)01:43 AM:ps 0> cat 3d2.ps
%!
% Point-field sampling
% with data caching (in a file),
% point-wise axial rotations,
% and perspective projection
% and color.

/fuzz 10000 def %the "grain" of eq
/oldeq /eq load def
/eq {
    fuzz mul round exch fuzz mul round oldeq
} def

/max {
    2 copy lt { exch } if pop
} def

%x y z  f  bool
/f {
    dup mul 3 1 roll    %z^2 x y
    dup mul 3 1 roll    %y^2 z^2 x
    dup mul 3 1 roll    %x^2 y^2 z^2
    2 index 2 index add %x^2 y^2 z^2  x^2+y^2
    3 index 2 index add %x^2 y^2 z^2  x^2+y^2  x^2+z^2
    3 index 3 index add %x^2 y^2 z^2  x^2+y^2  x^2+z^2  y^2+z^2
    max                 %x^2 y^2 z^2  x^2+y^2  max(x^2+z^2,y^2+z^2)
    max                 %x^2 y^2 z^2  max(x^2+y^2, max(x^2+z^2,y^2+z^2))
    4 1 roll pop pop pop %max(...)
    4 eq
} def


/filename (stein.pts) def

/low -2.2 def
/hi 2.2 def
/pointsize { dt .3 mul } def

%generate data by brute force, cache in file, plot
/pointfieldtocache {
    /res exch def
    /dt 1 res div def
    /fuzz res .2 mul def
        %fuzz affects the "closeness" of
        %the equality test. a lower fuzz will allow more
        %values to be equal.
        % 'res' gives thin lines
        % 'res .5 mul' gives wider "ribbons"

/outfile filename (w) file def
/outbuf 128 string def
    low dt hi {
        low dt hi {
            low dt hi { % xW yW zW "world" coords
                3 copy f {
                    3 copy 3 -1 1 { -1 roll
                        outbuf cvs outfile exch writestring
                        outfile (\n) writestring
                    } for %dump points to file
                    2 index 2.2 add 4.4 div .5 .6 sethsbcolor
                    3 copy project
                    %2 copy exch = =
                    %2 copy transform exch = =  ()=
                    2 copy 2 copy moveto pointsize 0 360 arc moveto
                    fill
                    /flushpage where {pop flushpage} if
                } if
                pop
            } for
            pop
        } for
        pop
    } for
outfile closefile
} def

%plot cached data from file
/pointfieldfromcache {
    /res exch def
    /dt 1 res div def
    /infile filename (r) file def
    /it 1 def
        %cvx exec
    %count 3 idiv {

    {
        {
            /it it 1 add def
            infile token not {stop} if % bail-out
            infile token not {stop} if % on any datafile issues
            infile token not {stop} if
                    %3 copy
                    2 index 2.2 add 4.4 div .5 .6 sethsbcolor
                    project
                    2 copy 2 copy moveto pointsize 0 360 arc moveto
            it res mod 0 oldeq {
                fill /flushpage where {pop flushpage} if
            } if
        } loop
    } stopped pop
    %} repeat
} def

/pointfield { %check if there's a readable data file
    { filename (r) file closefile } stopped not
    //pointfieldfromcache %yes! read it.
    { pop pop pointfieldtocache } ifelse %no! make one.
} def

% x y z ang -> x y' z'
/rotx {
    /theta exch def
    /z exch def
    /y exch def
    y theta cos mul
    z theta sin mul sub
    y theta sin mul
    z theta cos mul add
} def

% x y z ang -> x' y z'
/roty {
    /theta exch def
    /z exch def
    /y exch def
    /x exch def
    x theta cos mul
    z theta sin mul add
    y
    x theta sin mul neg
    z theta cos mul add
} def

% x y z ang -> x' y' z
/rotz {
    /theta exch def
    /z exch def
    /y exch def
    /x exch def
    x theta cos mul
    y theta sin mul sub
    x theta sin mul
    y theta cos mul add
    z
} def

% Eye coords
/ex .2 def %a little x-y skew adds "drama"
/ey .2 def
/ez 5 def

% x y z -> X Y
/project {
ang roty
ang .25 mul rotx
    /z exch def
    /y exch def
    /x exch def
    1 ez z sub div
    x ez mul z ex mul sub
    1 index mul
    y ez mul z ey mul sub
    3 2 roll mul
} def

10 10 360 {
    /ang exch def
    %matrix currentmatrix
    300 400 translate
    100 100 scale
    30 pointfield
    %setmatrix fill
    /flushpage where {pop flushpage} if
    showpage
} for

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

ping luser- -droog: SVG or PS project for you? tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-07-17 04:48 -0400
  Re: ping luser- -droog: SVG or PS project for you? luser- -droog <mijoryx@yahoo.com> - 2012-07-17 08:16 -0700
    Re: ping luser- -droog: SVG or PS project for you? tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-07-17 19:25 -0400
  Re: ping luser- -droog: SVG or PS project for you? luser- -droog <mijoryx@yahoo.com> - 2012-08-17 23:40 -0700
    Re: ping luser- -droog: SVG or PS project for you? luser- -droog <mijoryx@yahoo.com> - 2012-08-18 00:14 -0700
      Re: ping luser- -droog: SVG or PS project for you? tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-08-18 22:44 -0400
        Moire Madness! Re: ping luser- -droog: SVG or PS project for you? luser- -droog <mijoryx@yahoo.com> - 2012-08-23 13:00 -0700
          Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-08-24 01:45 -0400
            Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-08-24 01:49 -0400
            Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? luser- -droog <mijoryx@yahoo.com> - 2012-08-23 23:11 -0700
              Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? luser- -droog <mijoryx@yahoo.com> - 2012-08-23 23:58 -0700
                Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-08-25 02:17 -0400
                Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? Luser droog <mijoryx@yahoo.com> - 2012-08-29 18:25 -0500
                Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? Luser droog <mijoryx@yahoo.com> - 2012-08-29 21:32 -0500
                Re: Moire Madness! Re: ping luser- -droog: SVG or PS project for you? tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-08-30 05:26 -0400
                Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you? Luser droog <mijoryx@yahoo.com> - 2012-09-02 16:04 -0500
                Re: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you? Luser droog <mijoryx@yahoo.com> - 2012-09-03 12:29 -0500
                Re: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you? Luser droog <mijoryx@yahoo.com> - 2012-09-04 12:04 -0500
                Re: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you? "M. Joshua Ryan" <mijoryx@yahoo.com> - 2012-09-04 12:49 -0500
                A shaded cylinder luser- -droog <mijoryx@yahoo.com> - 2012-09-04 18:11 -0700
                Re: A shaded cylinder luser- -droog <mijoryx@yahoo.com> - 2012-09-11 13:03 -0700
                Spinning Steinmertz Solid (approx.) luser- -droog <mijoryx@yahoo.com> - 2012-09-11 21:29 -0700
                Mulligan (again) luser- -droog <mijoryx@yahoo.com> - 2012-09-13 19:07 -0700
                Re: Mulligan (again) tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-09-14 05:05 -0400
                Heineken time "luser.droog" <luser.droog@gmail.com> - 2012-09-15 16:50 -0500
                Bigger and Badderer "luser.droog" <luser.droog@gmail.com> - 2012-09-16 23:33 -0500
                Re: Bigger and Badderer "luser.droog" <luser.droog@gmail.com> - 2012-09-16 23:37 -0500
                QapplaH! "luser.droog" <luser.droog@gmail.com> - 2012-09-17 11:34 -0500
                Re: QapplaH! (appendix: updated mat.ps) "luser.droog" <luser.droog@gmail.com> - 2012-09-17 13:05 -0500
                one more cup of coffee for the road. "luser.droog" <luser.droog@gmail.com> - 2012-09-18 02:51 -0500
                Re: Bigger and Badderer tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-09-18 21:52 -0400
                Re: Bigger and Badderer "luser.droog" <luser.droog@gmail.com> - 2012-09-18 22:30 -0500
                Re: Bigger and Badderer tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-09-19 00:59 -0400
                Re: Bigger and Badderer "luser.droog" <luser.droog@gmail.com> - 2012-09-19 00:48 -0500
                Revolving Camera prototype "luser.droog" <luser.droog@gmail.com> - 2012-09-23 22:30 -0500
                Steinmetz with Revolving Camera "luser.droog" <luser.droog@gmail.com> - 2012-09-24 09:30 -0500

csiph-web