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


Groups > comp.lang.postscript > #815 > unrolled thread

ping luser- -droog: SVG or PS project for you?

Started bytlvp <mPiOsUcB.EtLlLvEp@att.net>
First post2012-07-17 04:48 -0400
Last post2012-09-24 09:30 -0500
Articles 20 on this page of 36 — 5 participants

Back to article view | Back to comp.lang.postscript


Contents

  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

Page 1 of 2  [1] 2  Next page →


#815 — ping luser- -droog: SVG or PS project for you?

Fromtlvp <mPiOsUcB.EtLlLvEp@att.net>
Date2012-07-17 04:48 -0400
Subjectping luser- -droog: SVG or PS project for you?
Message-ID<1ca6lvkhx25dt.14pkcuyecuct2$.dlg@40tude.net>
I'm not sure whether you're up to taking on others' tasks, but here's a
geometrical one my own PS and/or SVG capabilities just aren't up to at all.

I'd like to find code for getting 2D-projected views of the 3D object
whose x- and y- and z-coordinates (after suitable scaling, say) satisfy:

: Max [ x^2+y^2, x^2+z^2, y^2+z^2 ] = 4  (-2 <= x&y&z <= +2) .

You can visualize this as the result of starting with a 4-inch length of
two-inch radius wooden doweling (that helps assure, say, x^2+y^2 <= 4),
spinning it against a belt sander with spinning axis perpendicular to --
and bisecting -- the central axis from the one disc-shaped end to the other
until you've removed enough material to assure x^2+z^2 <= 4 (if it were a
stubby D cell battery, it would be spinning end over end, grinding the +
and - poles down until they're well rounded, sort of), and then using a
third axis perpendicular to the two axes already mentioned as a spinning
axis for grinding down the last bits (still at the + and - poles), to
assure y^2+z^2 <= 4.

[If you have Mathematica, tell it you want it to give you

: RegionPlot3D[Max[x^2+y^2,x^2+z^2,y^2+z^2]<=4,{x,-2,2},{y,-2,2},{z,-2,2}]] .

(Or try with the last 6 instances of the values "2", in the braces,
replaced by "2.01".)
With Maple, I suspect some very similar formulation will work as well. But
I have neither of them, and Wolfram|Alpha balks at giving the help I want.]

Anyway, viewed "head-on" from the perspective of any of those three axes,
the resulting object has circular silhouette. Viewed from virtually any
other perspective, not properly circular at all.

Any way to come up with a SVG animation showing views of this beast as
one's viewing angle varies from elevations of 0 up through 45 degrees,
and/or one's lateral angle varies between -45 and +45 degrees (leftward
and/or rightward), would be welcome. Or even just a short slide-show of PS
views :-) . (I think of your snowfkake iterations as a "slide-show" model.)

TIA, if possible; and no hard feelings if not. Cheers, -- tlvp
-- 
Avant de repondre, jeter la poubelle, SVP.

[toc] | [next] | [standalone]


#816

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-07-17 08:16 -0700
Message-ID<aff1ff46-4811-4bfe-ab8f-0ecba80a374c@googlegroups.com>
In reply to#815
On Tuesday, July 17, 2012 3:48:33 AM UTC-5, tlvp wrote:
> I&#39;m not sure whether you&#39;re up to taking on others&#39; tasks, but here&#39;s a
> geometrical one my own PS and/or SVG capabilities just aren&#39;t up to at all.
> 
> I&#39;d like to find code for getting 2D-projected views of the 3D object
> whose x- and y- and z-coordinates (after suitable scaling, say) satisfy:
> 
> : Max [ x^2+y^2, x^2+z^2, y^2+z^2 ] = 4  (-2 &lt;= x&amp;y&amp;z &lt;= +2) .
> 
> You can visualize this as the result of starting with a 4-inch length of
> two-inch radius wooden doweling (that helps assure, say, x^2+y^2 &lt;= 4),
> spinning it against a belt sander with spinning axis perpendicular to --
> and bisecting -- the central axis from the one disc-shaped end to the other
> until you&#39;ve removed enough material to assure x^2+z^2 &lt;= 4 (if it were a
> stubby D cell battery, it would be spinning end over end, grinding the +
> and - poles down until they&#39;re well rounded, sort of), and then using a
> third axis perpendicular to the two axes already mentioned as a spinning
> axis for grinding down the last bits (still at the + and - poles), to
> assure y^2+z^2 &lt;= 4.
> 
> [If you have Mathematica, tell it you want it to give you
> 
> : RegionPlot3D[Max[x^2+y^2,x^2+z^2,y^2+z^2]&lt;=4,{x,-2,2},{y,-2,2},{z,-2,2}]] .
> 
> (Or try with the last 6 instances of the values &quot;2&quot;, in the braces,
> replaced by &quot;2.01&quot;.)
> With Maple, I suspect some very similar formulation will work as well. But
> I have neither of them, and Wolfram|Alpha balks at giving the help I want.]
> 
> Anyway, viewed &quot;head-on&quot; from the perspective of any of those three axes,
> the resulting object has circular silhouette. Viewed from virtually any
> other perspective, not properly circular at all.
> 
> Any way to come up with a SVG animation showing views of this beast as
> one&#39;s viewing angle varies from elevations of 0 up through 45 degrees,
> and/or one&#39;s lateral angle varies between -45 and +45 degrees (leftward
> and/or rightward), would be welcome. Or even just a short slide-show of PS
> views :-) . (I think of your snowfkake iterations as a &quot;slide-show&quot; model.)
> 
> TIA, if possible; and no hard feelings if not. Cheers, -- tlvp
> -- 
> Avant de repondre, jeter la poubelle, SVP.

I'll give it a go. Might have to reread the second half
of Mathematical Illustrations. It would be a bridge to
one of my ideas: an animated stereogram of a rotating
tesseract.

[toc] | [prev] | [next] | [standalone]


#817

Fromtlvp <mPiOsUcB.EtLlLvEp@att.net>
Date2012-07-17 19:25 -0400
Message-ID<tlkyodadk6fh.j1zc81uuctx2$.dlg@40tude.net>
In reply to#816
On Tue, 17 Jul 2012 08:16:41 -0700 (PDT), luser- -droog wrote,
and I am astonished at all the substitutions of HTML entity names for the
actual LessThan or Apostrophe or Ampersand or QuoteMark characters I used:

> Path: n102.xanadu-bbs.net!optima5.xanadu-bbs.net!optima11.xanadu-bbs.net!optima2.xanadu-bbs.net!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
> From: luser- -droog <mijoryx@yahoo.com>
> Newsgroups: comp.lang.postscript
> Subject: Re: ping luser- -droog: SVG or PS project for you?
> Date: Tue, 17 Jul 2012 08:16:41 -0700 (PDT)
> Organization: http://groups.google.com
> Lines: 47
> Message-ID: <aff1ff46-4811-4bfe-ab8f-0ecba80a374c@googlegroups.com>
> References: <1ca6lvkhx25dt.14pkcuyecuct2$.dlg@40tude.net>
> NNTP-Posting-Host: 99.191.124.223
> Mime-Version: 1.0
> Content-Type: text/plain; charset=ISO-8859-1
> X-Trace: posting.google.com 1342538202 8793 127.0.0.1 (17 Jul 2012 15:16:42 GMT)
> X-Complaints-To: groups-abuse@google.com
> NNTP-Posting-Date: Tue, 17 Jul 2012 15:16:42 +0000 (UTC)
> Cc: mPiOsUcB.EtLlLvEp@att.net
> In-Reply-To: <1ca6lvkhx25dt.14pkcuyecuct2$.dlg@40tude.net>
> Complaints-To: groups-abuse@google.com
> Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=99.191.124.223;
>  posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
> User-Agent: G2/1.0
> X-Received-Bytes: 3613
> Xref: n102.xanadu-bbs.net comp.lang.postscript:2330
> 
> On Tuesday, July 17, 2012 3:48:33 AM UTC-5, tlvp wrote:
>> I&#39;m not sure whether you&#39;re up to taking on others&#39; tasks, but here&#39;s a
>> geometrical one my own PS and/or SVG capabilities just aren&#39;t up to at all.
>> 
>> I&#39;d like to find code for getting 2D-projected views of the 3D object
>> whose x- and y- and z-coordinates (after suitable scaling, say) satisfy:
>> 
>>: Max [ x^2+y^2, x^2+z^2, y^2+z^2 ] = 4  (-2 &lt;= x&amp;y&amp;z &lt;= +2) .
>> 
>> You can visualize this as the result of starting with a 4-inch length of
>> two-inch radius wooden doweling (that helps assure, say, x^2+y^2 &lt;= 4),
>> spinning it against a belt sander with spinning axis perpendicular to --
>> and bisecting -- the central axis from the one disc-shaped end to the other
>> until you&#39;ve removed enough material to assure x^2+z^2 &lt;= 4 (if it were a
>> stubby D cell battery, it would be spinning end over end, grinding the +
>> and - poles down until they&#39;re well rounded, sort of), and then using a
>> third axis perpendicular to the two axes already mentioned as a spinning
>> axis for grinding down the last bits (still at the + and - poles), to
>> assure y^2+z^2 &lt;= 4.
>> 
>> [If you have Mathematica, tell it you want it to give you
>> 
>>: RegionPlot3D[Max[x^2+y^2,x^2+z^2,y^2+z^2]&lt;=4,{x,-2,2},{y,-2,2},{z,-2,2}]] .
>> 
>> (Or try with the last 6 instances of the values &quot;2&quot;, in the braces,
>> replaced by &quot;2.01&quot;.)
>> With Maple, I suspect some very similar formulation will work as well. But
>> I have neither of them, and Wolfram|Alpha balks at giving the help I want.]
>> 
>> Anyway, viewed &quot;head-on&quot; from the perspective of any of those three axes,
>> the resulting object has circular silhouette. Viewed from virtually any
>> other perspective, not properly circular at all.
>> 
>> Any way to come up with a SVG animation showing views of this beast as
>> one&#39;s viewing angle varies from elevations of 0 up through 45 degrees,
>> and/or one&#39;s lateral angle varies between -45 and +45 degrees (leftward
>> and/or rightward), would be welcome. Or even just a short slide-show of PS
>> views :-) . (I think of your snowfkake iterations as a &quot;slide-show&quot; model.)
>> 
>> TIA, if possible; and no hard feelings if not. Cheers, -- tlvp
>> -- 
>> Avant de repondre, jeter la poubelle, SVP.
> 
> I'll give it a go. Might have to reread the second half
> of Mathematical Illustrations. It would be a bridge to
> one of my ideas: an animated stereogram of a rotating
> tesseract.

Think it's Google Groups doing that? Or your browser? Or other? (OtOH, your
own Apostrophe, in your "I'll give it a go" phrase, is just fine :-) .

Anyway, I'm heartened to see that you'll "give it a go" -- I won't hold my
breath for it, but I will be interested to see what you come up with.

Cheers, and TIA, -- tlvp
-- 
Avant de repondre, jeter la poubelle, SVP.

[toc] | [prev] | [next] | [standalone]


#890

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-08-17 23:40 -0700
Message-ID<b578b27d-5292-4e14-9bea-51c334034ea6@googlegroups.com>
In reply to#815
On Tuesday, July 17, 2012 3:48:33 AM UTC-5, tlvp wrote:
> I'm not sure whether you're up to taking on others' tasks, but here's a
> 
> geometrical one my own PS and/or SVG capabilities just aren't up to at all.
> 
> 
> 
> I'd like to find code for getting 2D-projected views of the 3D object
> 
> whose x- and y- and z-coordinates (after suitable scaling, say) satisfy:
> 
> 
> 
> : Max [ x^2+y^2, x^2+z^2, y^2+z^2 ] = 4  (-2 <= x&y&z <= +2) .
> 
> 
> 
> You can visualize this as the result of starting with a 4-inch length of
> 
> two-inch radius wooden doweling (that helps assure, say, x^2+y^2 <= 4),
> 
> spinning it against a belt sander with spinning axis perpendicular to --
> 
> and bisecting -- the central axis from the one disc-shaped end to the other
> 
> until you've removed enough material to assure x^2+z^2 <= 4 (if it were a
> 
> stubby D cell battery, it would be spinning end over end, grinding the +
> 
> and - poles down until they're well rounded, sort of), and then using a
> 
> third axis perpendicular to the two axes already mentioned as a spinning
> 
> axis for grinding down the last bits (still at the + and - poles), to
> 
> assure y^2+z^2 <= 4.
> 
> 
> 
> [If you have Mathematica, tell it you want it to give you
> 
> 
> 
> : RegionPlot3D[Max[x^2+y^2,x^2+z^2,y^2+z^2]<=4,{x,-2,2},{y,-2,2},{z,-2,2}]] .
> 
> 
> 
> (Or try with the last 6 instances of the values "2", in the braces,
> 
> replaced by "2.01".)
> 
> With Maple, I suspect some very similar formulation will work as well. But
> 
> I have neither of them, and Wolfram|Alpha balks at giving the help I want.]
> 
> 
> 
> Anyway, viewed "head-on" from the perspective of any of those three axes,
> 
> the resulting object has circular silhouette. Viewed from virtually any
> 
> other perspective, not properly circular at all.
> 
> 
> 
> Any way to come up with a SVG animation showing views of this beast as
> 
> one's viewing angle varies from elevations of 0 up through 45 degrees,
> 
> and/or one's lateral angle varies between -45 and +45 degrees (leftward
> 
> and/or rightward), would be welcome. Or even just a short slide-show of PS
> 
> views :-) . (I think of your snowfkake iterations as a "slide-show" model.)
> 
> 
> 
> TIA, if possible; and no hard feelings if not. Cheers, -- tlvp
> 

Alright, version 1 has some obvious flaws.
But it looks really strange.
I think I should solve for z instead of sampling.
And there's no projection here, just dropping the z
(interpreting it as a grey value).

I borrowed heavily from my mandelbrot set program
in the use of `image`.

%!

/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

/tlvp {
    /res exch def  %resolution
    /str res string def  %1-row buffer
    /++ { dup load 1 add store } bind def  %increment proc
    /yc 0 def  %y cursor
    res res 8 [ res 0 0 res neg 0 res ]
    { %image
        0 1 res 1 sub { %for each byte of the string, incr x
            /xc exch def  %x cursor
            /x0 xc res div 4 mul 2 sub def  %
            /y0 yc res div 4 mul 2 sub def  %

            0 1 res 1 sub { %check all z values in range
                /zc exch def
                /z0 zc res div 4 mul 2 sub def
                x0 y0 z0 f {
                    str xc
                    z0 2 add 4 div 255 mul cvi
                    put
                } if
            } for
        } for
        /yc ++  %incr y for next row
        str  %yield string buffer to `image`
    } image
} def

612 612 scale
100 tlvp

showpage

[toc] | [prev] | [next] | [standalone]


#891

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-08-18 00:14 -0700
Message-ID<3d013aa0-e8c0-4db9-8a03-ed29b2eba2cf@googlegroups.com>
In reply to#890
On Saturday, August 18, 2012 1:40:51 AM UTC-5, luser- -droog wrote:
> On Tuesday, July 17, 2012 3:48:33 AM UTC-5, tlvp wrote:
> 
> > I'm not sure whether you're up to taking on others' tasks, but here's a
> 
> > 
> 
> > geometrical one my own PS and/or SVG capabilities just aren't up to at all.
> 
> > 
> 
> > 
> 
> > 
> 
> > I'd like to find code for getting 2D-projected views of the 3D object
> 
> > 
> 
> > whose x- and y- and z-coordinates (after suitable scaling, say) satisfy:
> 
> > 
> 
> > 
> 
> > 
> 
> > : Max [ x^2+y^2, x^2+z^2, y^2+z^2 ] = 4  (-2 <= x&y&z <= +2) .
> 
> > 
> 
> > 
[snip]
> 
> 
> 
> Alright, version 1 has some obvious flaws.
> 
> But it looks really strange.
> 
> I think I should solve for z instead of sampling.
> 
> And there's no projection here, just dropping the z
> 
> (interpreting it as a grey value).
> 
> 
> 
> I borrowed heavily from my mandelbrot set program
> 
> in the use of `image`.
> 

Forgot to clear the bytes, so it was smearing.
Now it uses 128 for a mid-grey background.
And a little fuzzy on the notion of equality
starts to bring it to life, I think.

%!

/oldeq /eq load def
/eq {
    ceiling exch ceiling 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

/tlvp {
    /dep exch def  %depth
    /res exch def  %resolution
    /str res string def  %1-row buffer
    /++ { dup load 1 add store } bind def  %increment proc
    /yc 0 def  %y cursor
    res res 8 [ res 0 0 res neg 0 res ]
    { %image
        0 1 res 1 sub { %for each byte of the string, incr x
            /xc exch def  %x cursor
            /x0 xc res div 4 mul 2 sub def  %
            /y0 yc res div 4 mul 2 sub def  %
            str xc 128 put

            0 1 dep 1 sub { %check all z values in range
                /zc exch def
                /z0 zc dep div 4 mul 2 sub def
                x0 y0 z0 f {
                    str xc
                    z0 2 add 4 div 255 mul cvi
                    put
                } if
            } for
        } for
        /yc ++  %incr y for next row
        str  %yield string buffer to `image`
    } image
} def

0 150 translate
612 612 scale
100 100 tlvp %x&y z don't push it with these, it's O(n^3)!

showpage

[toc] | [prev] | [next] | [standalone]


#892

Fromtlvp <mPiOsUcB.EtLlLvEp@att.net>
Date2012-08-18 22:44 -0400
Message-ID<fg280ctdmlnb.61z3ivwjxw33$.dlg@40tude.net>
In reply to#891
On Sat, 18 Aug 2012 00:14:56 -0700 (PDT), luser- -droog wrote:

> On Saturday, August 18, 2012 1:40:51 AM UTC-5, luser- -droog wrote:
>> On Tuesday, July 17, 2012 3:48:33 AM UTC-5, tlvp wrote:
>> 
>>> I'm not sure whether you're up to taking on others' tasks, but here's a
>> 
>>> 
>> 
>>> geometrical one my own PS and/or SVG capabilities just aren't up to at all.
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> I'd like to find code for getting 2D-projected views of the 3D object
>> 
>>> 
>> 
>>> whose x- and y- and z-coordinates (after suitable scaling, say) satisfy:
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> : Max [ x^2+y^2, x^2+z^2, y^2+z^2 ] = 4  (-2 <= x&y&z <= +2) .
>> 
>>> 
>> 
>>> 
> [snip]
>> 
>> 
>> 
>> Alright, version 1 has some obvious flaws.
>> 
>> But it looks really strange.
>> 
>> I think I should solve for z instead of sampling.
>> 
>> And there's no projection here, just dropping the z
>> 
>> (interpreting it as a grey value).
>> 
>> 
>> 
>> I borrowed heavily from my mandelbrot set program
>> 
>> in the use of `image`.
>> 
> 
> Forgot to clear the bytes, so it was smearing.
> Now it uses 128 for a mid-grey background.
> And a little fuzzy on the notion of equality
> starts to bring it to life, I think.
> 
> %!
> 
> /oldeq /eq load def
> /eq {
>     ceiling exch ceiling 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
> 
> /tlvp {
>     /dep exch def  %depth
>     /res exch def  %resolution
>     /str res string def  %1-row buffer
>     /++ { dup load 1 add store } bind def  %increment proc
>     /yc 0 def  %y cursor
>     res res 8 [ res 0 0 res neg 0 res ]
>     { %image
>         0 1 res 1 sub { %for each byte of the string, incr x
>             /xc exch def  %x cursor
>             /x0 xc res div 4 mul 2 sub def  %
>             /y0 yc res div 4 mul 2 sub def  %
>             str xc 128 put
> 
>             0 1 dep 1 sub { %check all z values in range
>                 /zc exch def
>                 /z0 zc dep div 4 mul 2 sub def
>                 x0 y0 z0 f {
>                     str xc
>                     z0 2 add 4 div 255 mul cvi
>                     put
>                 } if
>             } for
>         } for
>         /yc ++  %incr y for next row
>         str  %yield string buffer to `image`
>     } image
> } def
> 
> 0 150 translate
> 612 612 scale
> 100 100 tlvp %x&y z don't push it with these, it's O(n^3)!
> 
> showpage

You've got it :-) ! ... But the "project z out of the picture" strategy
loses the sort of perspective that gives a better feel for the object.

It's a so-called "Steinmetz Solid" (q.v. -- midway down the first page of
Google hits, as they come up for me, are some neat small renditions of it). 

Cheers, -- tlvp
-- 
Avant de repondre, jeter la poubelle, SVP.

[toc] | [prev] | [next] | [standalone]


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

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-08-23 13:00 -0700
SubjectMoire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<3cb138c8-2147-48a6-b90a-91c8cc7e6d29@googlegroups.com>
In reply to#892
On Saturday, August 18, 2012 9:44:21 PM UTC-5, tlvp wrote:
> On Sat, 18 Aug 2012 00:14:56 -0700 (PDT), luser- -droog wrote:
> 
> 
> > Forgot to clear the bytes, so it was smearing.
> 
> > Now it uses 128 for a mid-grey background.
> 
> > And a little fuzzy on the notion of equality
> 
> > starts to bring it to life, I think.
> 
> > 
> 
[snip]
> 
> 
> You've got it :-) ! ... But the "project z out of the picture" strategy
> 
> loses the sort of perspective that gives a better feel for the object.
> 
> 
> 
> It's a so-called "Steinmetz Solid" (q.v. -- midway down the first page of
> 
> Google hits, as they come up for me, are some neat small renditions of it). 
> 


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.

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.

/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

%generate data by brute force, cache in file, plot
/pointfieldtocache {
    /res exch def
    /dt 1 res div def
    /fuzz res .5 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
                    3 copy project
                    %2 copy exch = =
                    %2 copy transform exch = =  ()=
                    2 copy 2 copy moveto dt .5 mul 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
                    project
                    2 copy 2 copy moveto dt .5 mul 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
    60 pointfield
    %setmatrix fill
    /flushpage where {pop flushpage} if
    showpage
} for

[toc] | [prev] | [next] | [standalone]


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

Fromtlvp <mPiOsUcB.EtLlLvEp@att.net>
Date2012-08-24 01:45 -0400
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<c50v0wb3pdm3$.hes4quvy1zz1.dlg@40tude.net>
In reply to#895
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.

Cheers, -- tlvp
-- 
Avant de repondre, jeter la poubelle, SVP.

[toc] | [prev] | [next] | [standalone]


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

Fromtlvp <mPiOsUcB.EtLlLvEp@att.net>
Date2012-08-24 01:49 -0400
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<1f3qycex5gti1.kakekwtfbyk0.dlg@40tude.net>
In reply to#899
On Fri, 24 Aug 2012 01:45:13 -0400, tlvp failed to clear out a stray
decimal point or two from where it didn't belong -- cleared out now:

> 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.

Ah, typos -- sorry about that. Cheers, -- tlvp
-- 
Avant de repondre, jeter la poubelle, SVP.

[toc] | [prev] | [next] | [standalone]


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

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-08-23 23:11 -0700
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<5638890b-933f-4f37-9635-7fbd3daec2c5@googlegroups.com>
In reply to#899
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.

[toc] | [prev] | [next] | [standalone]


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

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-08-23 23:58 -0700
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<67041f2e-e3e3-44e6-99ee-3d4accbaed25@googlegroups.com>
In reply to#901
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

[toc] | [prev] | [next] | [standalone]


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

Fromtlvp <mPiOsUcB.EtLlLvEp@att.net>
Date2012-08-25 02:17 -0400
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<1h6zz5p1ua7nx$.1bghff5yydx4a$.dlg@40tude.net>
In reply to#902
On Thu, 23 Aug 2012 23:58:25 -0700 (PDT), luser- -droog wrote:

> ...
> 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.
> 
>  ... [details snipped] ...
> 
>     /flushpage where {pop flushpage} if
>     showpage
> } for

The color adds very nicely to the effect, thank you, moy droog :-) .

Two things keep surprising me, though, in the graphics swept out: first,
the large number of times the eye beholds squares unfolding; and, second,
the total absence of any swept out figures whose silhouette is a disc.

After all, peering straight at the figure directly along any of the three
principal axes (x-axis, y-axis, z-axis) should reveal a circular outline.

The squares are the cartographic "contour level-lines" with respect to
heights measured along those axes, but small squares near the top and
bottom should grow as squares only up to a certain point, and then start to
balloon out to become more and more circle-like, finally becoming a true
circle at mid-height exactly. Why doesn't that strike the eye more
blatantly, at least occasionally?

I know, it sounds like "Mrrble, mrrble, grubs again!" but it's not, really,
I'm just curious :-) ... and hoping maybe to catch a glimpse of a tiny
variation in how to compute (or to color) the lines being drawn, so as
better to capture the spirit of that Steinmetz Solid. And, in the meantime,
I think what you have is great! Again, my thanks! 

Cheers, -- tlvp

PS: something about Google Groups that keeps interspersing new blank lines
between each pair of posted lines being quoted? Makes everything you quote
get stretched to twice, or twice-twice, or even twice-twice-twice its
original line-count :-) . No chance of convincing you to use a *proper*
newsreader? like Thunderbird? Dialog? Pan? Agent? MesNews? (or other?)
-- 
Avant de repondre, jeter la poubelle, SVP.

[toc] | [prev] | [next] | [standalone]


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

FromLuser droog <mijoryx@yahoo.com>
Date2012-08-29 18:25 -0500
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<k1m8ci$29e6$1@adenine.netfront.net>
In reply to#904
tlvp wrote:

> On Thu, 23 Aug 2012 23:58:25 -0700 (PDT), luser- -droog wrote:
> 
>> ...
>> 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.
>> 
>>  ... [details snipped] ...
>> 
>>     /flushpage where {pop flushpage} if
>>     showpage
>> } for
> 
> The color adds very nicely to the effect, thank you, moy droog :-) .
> 
> Two things keep surprising me, though, in the graphics swept out: first,
> the large number of times the eye beholds squares unfolding; and, second,
> the total absence of any swept out figures whose silhouette is a disc.
> 
> After all, peering straight at the figure directly along any of the three
> principal axes (x-axis, y-axis, z-axis) should reveal a circular outline.
> 
> The squares are the cartographic "contour level-lines" with respect to
> heights measured along those axes, but small squares near the top and
> bottom should grow as squares only up to a certain point, and then start
> to balloon out to become more and more circle-like, finally becoming a
> true circle at mid-height exactly. Why doesn't that strike the eye more
> blatantly, at least occasionally?
> 
> I know, it sounds like "Mrrble, mrrble, grubs again!" but it's not,
> really, I'm just curious :-) ... and hoping maybe to catch a glimpse of a
> tiny variation in how to compute (or to color) the lines being drawn, so
> as better to capture the spirit of that Steinmetz Solid. And, in the
> meantime, I think what you have is great! Again, my thanks!
> 
> Cheers, -- tlvp
> 
> PS: something about Google Groups that keeps interspersing new blank lines
> between each pair of posted lines being quoted? Makes everything you quote
> get stretched to twice, or twice-twice, or even twice-twice-twice its
> original line-count :-) . No chance of convincing you to use a *proper*
> newsreader? like Thunderbird? Dialog? Pan? Agent? MesNews? (or other?)

Trying KNode with a third free server.


--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


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

FromLuser droog <mijoryx@yahoo.com>
Date2012-08-29 21:32 -0500
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<k1mjct$2pld$1@adenine.netfront.net>
In reply to#904
tlvp wrote:

> On Thu, 23 Aug 2012 23:58:25 -0700 (PDT), luser- -droog wrote:
> 
>> ...
>> 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.
>> 
>>  ... [details snipped] ...
>> 
>>     /flushpage where {pop flushpage} if
>>     showpage
>> } for
> 
> The color adds very nicely to the effect, thank you, moy droog :-) .
> 
> Two things keep surprising me, though, in the graphics swept out: first,
> the large number of times the eye beholds squares unfolding; and, second,
> the total absence of any swept out figures whose silhouette is a disc.
> 
> After all, peering straight at the figure directly along any of the three
> principal axes (x-axis, y-axis, z-axis) should reveal a circular outline.
> 
> The squares are the cartographic "contour level-lines" with respect to
> heights measured along those axes, but small squares near the top and
> bottom should grow as squares only up to a certain point, and then start
> to balloon out to become more and more circle-like, finally becoming a
> true circle at mid-height exactly. Why doesn't that strike the eye more
> blatantly, at least occasionally?
> 
> I know, it sounds like "Mrrble, mrrble, grubs again!" but it's not,
> really, I'm just curious :-) ... and hoping maybe to catch a glimpse of a
> tiny variation in how to compute (or to color) the lines being drawn, so
> as better to capture the spirit of that Steinmetz Solid. And, in the
> meantime, I think what you have is great! Again, my thanks!
> 

Well, I think to make any real progress, we need to transform it into
an easier-to-calculate form. Casselman frequently uses parametrization,
so I thought that was the thing to do. So,

Max(x^2+y^2, y^2+z^2, x^2+z^2)=4

If we take x=r*cos t, y=r*sin t, then for one "third" of the shape,

r^2 * cos^2 t + r^2 * sin^2 t = 4
r^2 (sin^2 t + cos^2 t) = 4
r = +/- 2

and 0 < t < 2pi

That reduces it to 2 variables t and z, right?
But I'm not sure what to do next. Keep z as it is?
Or convert it to an angle, too?

I think I'll go back to the simple side and try to draw
the cylinders themselves as wireframes (circles one way, 
rectangles the other two). Then I should be able to
draw each one constrained by the other two, I think.


--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


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

Fromtlvp <mPiOsUcB.EtLlLvEp@att.net>
Date2012-08-30 05:26 -0400
SubjectRe: Moire Madness! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<1crb2uv6n8aor$.ypijta16vm02.dlg@40tude.net>
In reply to#906
On Wed, 29 Aug 2012 21:32:52 -0500, Luser droog wrote:

> tlvp wrote:
> 
>> On Thu, 23 Aug 2012 23:58:25 -0700 (PDT), luser- -droog wrote:
>> 
>>> ...
>>> 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.
>>> 
>>>  ... [details snipped] ...
>>> 
>>>     /flushpage where {pop flushpage} if
>>>     showpage
>>> } for
>> 
>> The color adds very nicely to the effect, thank you, moy droog :-) .
>> 
>> Two things keep surprising me, though, in the graphics swept out: first,
>> the large number of times the eye beholds squares unfolding; and, second,
>> the total absence of any swept out figures whose silhouette is a disc.
>> 
>> After all, peering straight at the figure directly along any of the three
>> principal axes (x-axis, y-axis, z-axis) should reveal a circular outline.
>> 
>> The squares are the cartographic "contour level-lines" with respect to
>> heights measured along those axes, but small squares near the top and
>> bottom should grow as squares only up to a certain point, and then start
>> to balloon out to become more and more circle-like, finally becoming a
>> true circle at mid-height exactly. Why doesn't that strike the eye more
>> blatantly, at least occasionally?
>> 
>> I know, it sounds like "Mrrble, mrrble, grubs again!" but it's not,
>> really, I'm just curious :-) ... and hoping maybe to catch a glimpse of a
>> tiny variation in how to compute (or to color) the lines being drawn, so
>> as better to capture the spirit of that Steinmetz Solid. And, in the
>> meantime, I think what you have is great! Again, my thanks!
>> 
> 
> Well, I think to make any real progress, we need to transform it into
> an easier-to-calculate form. Casselman frequently uses parametrization,
> so I thought that was the thing to do. So,
> 
> Max(x^2+y^2, y^2+z^2, x^2+z^2)=4
> 
> If we take x=r*cos t, y=r*sin t, then for one "third" of the shape,
> 
> r^2 * cos^2 t + r^2 * sin^2 t = 4
> r^2 (sin^2 t + cos^2 t) = 4
> r = +/- 2
> 
> and 0 < t < 2pi
> 
> That reduces it to 2 variables t and z, right?
> But I'm not sure what to do next. Keep z as it is?
> Or convert it to an angle, too?
> 
> I think I'll go back to the simple side and try to draw
> the cylinders themselves as wireframes (circles one way, 
> rectangles the other two). Then I should be able to
> draw each one constrained by the other two, I think.
> 
> 
> --- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

Here's another way to think of the geometric object itself.

Start by picturing a cube -- sides of length 4, say -- with spindle-shafts
drilled perpendicularly through it at each face.

Now chuck it (with the help of a spindle through one of those shafts), and
lathe-turn it down until everything at distance 2 or more from the center
of rotation is cut away. See it? A cylinder of height 4 and diameter 4.

Now pick a new shaft, chuck it with help of a spindle through that shaft,
and turn it down until everything at distance 2 or more from the center of
rotation is cut away. See it? A "roundly beveled former cylinder ... ."

Now, using a spindle through the last shaft, chuck it again, and proceed as
earlier, i.e., turn it down until everything at distance 2 or more from the
center of rotation is cut away. See it? The Steinmetz Solid.

Think there's any hope of showing how it's gradually revealed through that
last lathe-turning procedure?

Me, I'm just not up to keeping tabs on all the recursion/iteration needed.

Cheers, -- tlvp
-- 
Avant de repondre, jeter la poubelle, SVP.
[PS: how sweet to have no pointless blank lines quoted in follow-ups :-) .]

[toc] | [prev] | [next] | [standalone]


#911 — Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?

FromLuser droog <mijoryx@yahoo.com>
Date2012-09-02 16:04 -0500
SubjectHula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<k20hls$433$1@adenine.netfront.net>
In reply to#908
tlvp wrote:

> On Wed, 29 Aug 2012 21:32:52 -0500, Luser droog wrote:
> 
>> tlvp wrote:
>> 
>>> On Thu, 23 Aug 2012 23:58:25 -0700 (PDT), luser- -droog wrote:
>>> 
>>>> ...
>>>> 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.
>>>> 
>>>>  ... [details snipped] ...
>>>> 
>>>>     /flushpage where {pop flushpage} if
>>>>     showpage
>>>> } for
>>> 
>>> The color adds very nicely to the effect, thank you, moy droog :-) .
>>> 
>>> Two things keep surprising me, though, in the graphics swept out: first,
>>> the large number of times the eye beholds squares unfolding; and,
>>> second, the total absence of any swept out figures whose silhouette is a
>>> disc.
>>> 
>>> After all, peering straight at the figure directly along any of the
>>> three principal axes (x-axis, y-axis, z-axis) should reveal a circular
>>> outline.
>>> 
>>> The squares are the cartographic "contour level-lines" with respect to
>>> heights measured along those axes, but small squares near the top and
>>> bottom should grow as squares only up to a certain point, and then start
>>> to balloon out to become more and more circle-like, finally becoming a
>>> true circle at mid-height exactly. Why doesn't that strike the eye more
>>> blatantly, at least occasionally?
>>> 
>>> I know, it sounds like "Mrrble, mrrble, grubs again!" but it's not,
>>> really, I'm just curious :-) ... and hoping maybe to catch a glimpse of
>>> a tiny variation in how to compute (or to color) the lines being drawn,
>>> so as better to capture the spirit of that Steinmetz Solid. And, in the
>>> meantime, I think what you have is great! Again, my thanks!
>>> 
>> 
>> Well, I think to make any real progress, we need to transform it into
>> an easier-to-calculate form. Casselman frequently uses parametrization,
>> so I thought that was the thing to do. So,
>> 
>> Max(x^2+y^2, y^2+z^2, x^2+z^2)=4
>> 
>> If we take x=r*cos t, y=r*sin t, then for one "third" of the shape,
>> 
>> r^2 * cos^2 t + r^2 * sin^2 t = 4
>> r^2 (sin^2 t + cos^2 t) = 4
>> r = +/- 2
>> 
>> and 0 < t < 2pi
>> 
>> That reduces it to 2 variables t and z, right?
>> But I'm not sure what to do next. Keep z as it is?
>> Or convert it to an angle, too?
>> 
>> I think I'll go back to the simple side and try to draw
>> the cylinders themselves as wireframes (circles one way,
>> rectangles the other two). Then I should be able to
>> draw each one constrained by the other two, I think.
>> 
>> 
>> --- Posted via news://freenews.netfront.net/ - Complaints to
>> news@netfront.net ---
> 
> Here's another way to think of the geometric object itself.
> 
> Start by picturing a cube -- sides of length 4, say -- with spindle-shafts
> drilled perpendicularly through it at each face.
> 
> Now chuck it (with the help of a spindle through one of those shafts), and
> lathe-turn it down until everything at distance 2 or more from the center
> of rotation is cut away. See it? A cylinder of height 4 and diameter 4.
> 
> Now pick a new shaft, chuck it with help of a spindle through that shaft,
> and turn it down until everything at distance 2 or more from the center of
> rotation is cut away. See it? A "roundly beveled former cylinder ... ."
> 
> Now, using a spindle through the last shaft, chuck it again, and proceed
> as earlier, i.e., turn it down until everything at distance 2 or more from
> the center of rotation is cut away. See it? The Steinmetz Solid.
> 
> Think there's any hope of showing how it's gradually revealed through that
> last lathe-turning procedure?
> 
> Me, I'm just not up to keeping tabs on all the recursion/iteration needed.
> 

I can definitely imagine it better after reading this.
But drawing it? Not so sure. To simulate a lathe, we need
a material that can be cut and removed. That would lead
me back toward the point-field. Then we could maybe animate 
a tool revolving and deactivate the corresponding points in
the field. But I think it would be painfully slow.

This one simplifies (perhaps too much) the shape to projected
polygon rings. Imagine a big hotel atrium with a suspended
sculpture of hula-hoops and you're ascending upon it in the
glass elevator.

This looks worse than the previous, but I still consider it
a step forward because the calculation is more elegant. 
Most of the execution time of the other program is calculating
points that fail to show up. Because it has to make sure not
to draw them.

Now with this wireframe, I think I can evolve it to "fill-in"
the gaps and make rectangles out of points in corresponding
rings. Then we can get a normal vector for the "face" and
only draw the "front" of the shape. 

The other -lemma is finally learning how those matrix projections
work. And to squash the rotation sequence into a single matrix.
That seems to call for a fully-general matrix multiplication
routine. And a utility to do transposes. Of course I know these
things exist, but to "own" it, I have to write my own. Even if it's
straight from some wikipedia pseudocode. It's like a Hunter Thompson
thing. Where he re-typed the works of Hemmingway to know what 
it felt like to write those books. Once I've written my own version
of something, I'm on the inside of it rather than the outside.
Like gematria.

Anyhoo. On to the picture.

554(1)03:41 PM:ps 0> cat 3d3.ps
%!
/.setlanguagelevel where { pop 2 .setlanguagelevel } if

% x y z ang -> x y' z'
/rotx { 3 dict begin
    /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
end } def

% x y z ang -> x' y z'
/roty { 4 dict begin
    /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
end } def

% x y z ang -> x' y' z
/rotz { 4 dict begin
    /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
end } def

% Eye coords
/ex .2 def
/ey .2 def
/ez 5 def

% x y z -> X Y
/project {
%ang roty
%ang .25 mul rotx
%alpha rotz
beta roty
gamma rotx
3 dict begin
    /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
end } def


/moveto { z project //moveto } def
/lineto { z project //lineto } def

%h R N
/cylinder { 2 dict begin
    /N exch def
    /R exch def
    /h exch def
    /dz 1 N div def
    /dt 360 dz mul def

    0 dz 1 {
        h mul h 2 div sub /z exch def
        R 0 moveto
        0 dt 360 {
            dup cos R mul
            exch sin R mul
            lineto
        } for
        closepath
    } for

end } def

%/alpha 0 def
/beta 0 def
/gamma 0 def
0 10 180 { /ang exch def
    /ey ang 180 div 5 mul 2.5 sub def

    /dep 30 def
    300 400 translate
    60 dup dup scale 1 exch div setlinewidth

    %/alpha ang def
    /beta 0 def
    /gamma 0 def
    4 2 dep cylinder

    %/alpha ang def
    /beta 90 def
    /gamma 0 def
    4 2 dep cylinder

    %/alpha ang def
    /beta 0 def
    /gamma 90 def
    4 2 dep cylinder

    %gsave %false upath
    %erasepage
    %grestore %uappend
    stroke
    /flushpage where { pop flushpage } if
    %copypage
    showpage

} for




--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#914 — Re: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?

FromLuser droog <mijoryx@yahoo.com>
Date2012-09-03 12:29 -0500
SubjectRe: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<k22peg$2fpt$1@adenine.netfront.net>
In reply to#911
Luser droog wrote:

> tlvp wrote:
> 
>> On Wed, 29 Aug 2012 21:32:52 -0500, Luser droog wrote:
>> 
>>> tlvp wrote:
>>> 
>>>> On Thu, 23 Aug 2012 23:58:25 -0700 (PDT), luser- -droog wrote:
>>>> 
>>>>> ...
>>>>> 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.
>>>>> 
>>>>>  ... [details snipped] ...
>>>>> 
>>>>>     /flushpage where {pop flushpage} if
>>>>>     showpage
>>>>> } for
>>>> 
>>>> The color adds very nicely to the effect, thank you, moy droog :-) .
>>>> 
>>>> Two things keep surprising me, though, in the graphics swept out:
>>>> first, the large number of times the eye beholds squares unfolding;
>>>> and, second, the total absence of any swept out figures whose
>>>> silhouette is a disc.
>>>> 
>>>> After all, peering straight at the figure directly along any of the
>>>> three principal axes (x-axis, y-axis, z-axis) should reveal a circular
>>>> outline.
>>>> 
>>>> The squares are the cartographic "contour level-lines" with respect to
>>>> heights measured along those axes, but small squares near the top and
>>>> bottom should grow as squares only up to a certain point, and then
>>>> start to balloon out to become more and more circle-like, finally
>>>> becoming a true circle at mid-height exactly. Why doesn't that strike
>>>> the eye more blatantly, at least occasionally?
>>>> 
>>>> I know, it sounds like "Mrrble, mrrble, grubs again!" but it's not,
>>>> really, I'm just curious :-) ... and hoping maybe to catch a glimpse of
>>>> a tiny variation in how to compute (or to color) the lines being drawn,
>>>> so as better to capture the spirit of that Steinmetz Solid. And, in the
>>>> meantime, I think what you have is great! Again, my thanks!
>>>> 
>>> 
>>> Well, I think to make any real progress, we need to transform it into
>>> an easier-to-calculate form. Casselman frequently uses parametrization,
>>> so I thought that was the thing to do. So,
>>> 
>>> Max(x^2+y^2, y^2+z^2, x^2+z^2)=4
>>> 
>>> If we take x=r*cos t, y=r*sin t, then for one "third" of the shape,
>>> 
>>> r^2 * cos^2 t + r^2 * sin^2 t = 4
>>> r^2 (sin^2 t + cos^2 t) = 4
>>> r = +/- 2
>>> 
>>> and 0 < t < 2pi
>>> 
>>> That reduces it to 2 variables t and z, right?
>>> But I'm not sure what to do next. Keep z as it is?
>>> Or convert it to an angle, too?
>>> 
>>> I think I'll go back to the simple side and try to draw
>>> the cylinders themselves as wireframes (circles one way,
>>> rectangles the other two). Then I should be able to
>>> draw each one constrained by the other two, I think.
>>> 
>>> 
>>> --- Posted via news://freenews.netfront.net/ - Complaints to
>>> news@netfront.net ---
>> 
>> Here's another way to think of the geometric object itself.
>> 
>> Start by picturing a cube -- sides of length 4, say -- with
>> spindle-shafts drilled perpendicularly through it at each face.
>> 
>> Now chuck it (with the help of a spindle through one of those shafts),
>> and lathe-turn it down until everything at distance 2 or more from the
>> center of rotation is cut away. See it? A cylinder of height 4 and
>> diameter 4.
>> 
>> Now pick a new shaft, chuck it with help of a spindle through that shaft,
>> and turn it down until everything at distance 2 or more from the center
>> of rotation is cut away. See it? A "roundly beveled former cylinder ...
>> ."
>> 
>> Now, using a spindle through the last shaft, chuck it again, and proceed
>> as earlier, i.e., turn it down until everything at distance 2 or more
>> from the center of rotation is cut away. See it? The Steinmetz Solid.
>> 
>> Think there's any hope of showing how it's gradually revealed through
>> that last lathe-turning procedure?
>> 
>> Me, I'm just not up to keeping tabs on all the recursion/iteration
>> needed.
>> 
> 
> I can definitely imagine it better after reading this.
> But drawing it? Not so sure. To simulate a lathe, we need
> a material that can be cut and removed. That would lead
> me back toward the point-field. Then we could maybe animate
> a tool revolving and deactivate the corresponding points in
> the field. But I think it would be painfully slow.
> 
> This one simplifies (perhaps too much) the shape to projected
> polygon rings. Imagine a big hotel atrium with a suspended
> sculpture of hula-hoops and you're ascending upon it in the
> glass elevator.
> 
> This looks worse than the previous, but I still consider it
> a step forward because the calculation is more elegant.
> Most of the execution time of the other program is calculating
> points that fail to show up. Because it has to make sure not
> to draw them.
> 
> Now with this wireframe, I think I can evolve it to "fill-in"
> the gaps and make rectangles out of points in corresponding
> rings. Then we can get a normal vector for the "face" and
> only draw the "front" of the shape.
> 
> The other -lemma is finally learning how those matrix projections
> work. And to squash the rotation sequence into a single matrix.
> That seems to call for a fully-general matrix multiplication
> routine. And a utility to do transposes. Of course I know these
> things exist, but to "own" it, I have to write my own. Even if it's
> straight from some wikipedia pseudocode. It's like a Hunter Thompson
> thing. Where he re-typed the works of Hemmingway to know what
> it felt like to write those books. Once I've written my own version
> of something, I'm on the inside of it rather than the outside.
> Like gematria.
> 
> Anyhoo. On to the picture.
> 
> 554(1)03:41 PM:ps 0> cat 3d3.ps

I've added the parallels by drawing each segment as a little box.
Sadly, this makes it about 4x slower.

I have an intuition that eofill can discern between the the front
and back rectangles since their orientations are quite literally
reversed. But that doesn't help me avoid stroking them.

566(0)12:22 PM:ps 0> cat 3d3.ps
%!
/.setlanguagelevel where { pop 2 .setlanguagelevel } if

% x y z ang -> x y' z'
/rotx { 3 dict begin
    /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
end } def

% x y z ang -> x' y z'
/roty { 4 dict begin
    /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
end } def

% x y z ang -> x' y' z
/rotz { 4 dict begin
    /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
end } def

% Eye coords
/ex .2 def
/ey .2 def
/ez 5 def

% x y z -> X Y
/project {
%ang roty
%ang .25 mul rotx
%alpha rotz
beta roty
gamma rotx
3 dict begin
    /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
end } def


/moveto { z project //moveto } def
/lineto { z project //lineto } def

%h R N
/cylinder { 5 dict begin
    /N exch def
    /R exch def
    /h exch def
    /dz 1 N div def
    /dt 360 dz mul def
    /hdz h dz mul def

    0 dz 1 dz sub {
        h mul h 2 div sub /z exch def
        %R 0 moveto
        0 dt 360 {
            dup
            dup cos R mul
            exch sin R mul
            2 copy moveto  % R t z
            /z z hdz add def
            lineto         % R t z+dz
            dt sub
            dup cos R mul
            exch sin R mul
            2 copy lineto  % R t-dt z+dz
            /z z hdz sub def
            lineto         % R t-dt z
            closepath
        } for
        %closepath
    } for

end } def

%/alpha 0 def
/beta 0 def
/gamma 0 def
0 10 180 { /ang exch def
    /ey ang 180 div 5 mul 2.5 sub def

    /dep 20 def
    300 400 translate
    60 dup dup scale 1 exch div setlinewidth

    %/alpha ang def
    /beta 0 def
    /gamma 0 def
    4 2 dep cylinder

    %/alpha ang def
    /beta 90 def
    /gamma 0 def
    4 2 dep cylinder

    %/alpha ang def
    /beta 0 def
    /gamma 90 def
    4 2 dep cylinder

    %gsave %false upath
    %erasepage
    %grestore %uappend
    stroke
    /flushpage where { pop flushpage } if
    %copypage
    showpage

} for



--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#925 — Re: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?

FromLuser droog <mijoryx@yahoo.com>
Date2012-09-04 12:04 -0500
SubjectRe: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<k25cb3$2hbi$1@adenine.netfront.net>
In reply to#914
Well, something's gone very wrong here. But it's the failures
that are most interesting, right?

The last thing I did was add the 'model' calls into the vectors
and out of the 'project' procedure. But that seems right.
I need to apply the model rotation before I take the normal vector
for visibility. Maybe I need to normalize the normal.
or the norml :)

I've inlined the matrix stuff, to save y'all some cut-and-paste
or directory hunting or usenet archiving or giving up before you
can laugh at this poor excuse for a cylinder. Somebody left it
on the railroad tracks.

%!
%The ol' cylinder, take 4

%(mat.ps) run
%!
%mat.ps
%Matrix and Vector math routines

/.error where { pop /signalerror { .error } def } if

/dot { % u v
    2 copy length exch length ne {
        /dot cvx /undefinedresult signalerror
    } if
    % u v
    0 % u v sum
    0 1 3 index length 1 sub { % u v sum i
        3 index 1 index get exch % u v sum u_i i
        3 index exch get % u v sum u_i v_i
        mul add % u v sum
    } for % u v sum

    3 1 roll pop pop % sum
} bind def

% [ x1 x2 x3 ] [ y1 y2 y3 ]  cross  [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2-x2*y1 ]
/cross { % u v
    dup length 3 ne
    2 index length 3 ne or {
        /cross cvx /undefinedresult signalerror
    } if
    % u v
    exch aload pop 4 3 roll aload pop % x1 x2 x3 y1 y2 y3
    [
        5 index 2 index mul % ... [ x2*y3
        3 index 6 index mul sub % ... [ x2*y3-y2*x3
        5 index 5 index mul % ... [ x2*y3-y2*x3 x3*y1
        8 index 4 index mul sub % ... [ x2*y3-y2*x3 x3*y1-x1*y3
        8 index 5 index mul % ... [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2
        8 index 7 index mul sub % ... [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2-x2*y1
    ]
    7 1 roll 6 { pop } repeat
} bind def

/transpose { STATICDICT begin
    /A exch def
    /M A length def
    /N A 0 get length def
    [
    0 1 N 1 sub { /n exch def
        [
        0 1 M 1 sub { /m exch def
            A m get n get
        } for
        ]
    } for
    ]
end } dup 0 6 dict put def

/matmul { STATICDICT begin
    /B exch def
    B 0 get type /arraytype ne { /B [B] def } if
    /A exch def
    A 0 get type /arraytype ne { /A [A] def } if
    /Q B length def
    /R B 0 get length def
    /P A length def
    Q A 0 get length ne {
        /A A transpose def
        /P A length def
        Q A 0 get length ne {
            A B end /matmul cvx /undefinedresult signalerror
        } if
    } if

    [
    0 1 R 1 sub { /r exch def
        [
        0 1 P 1 sub { /p exch def
            0
            0 1 Q 1 sub { /q exch def
                A p get q get
                B q get r get mul
                add
            } for
        } for
        ]
    } for
    ]

end } dup 0 10 dict put def

%u v {operator}  vop  u(op)v
%apply a binary operator to corresponding elements
%in two vectors producing a third vector as result
/vop { 1 dict begin
    /op exch def
    2 copy length exch length ne {
        /vop cvx end /undefinedresult signalerror
    } if

    [ 3 1 roll % [ u v
    0 1 2 index length 1 sub { % [ ... u v i
        3 copy exch pop get % u v i u_i
        3 copy pop get      % u v i u_i v_i
        op exch pop         % u v u_i(op)v_i
        3 1 roll            % u_i(op)v_i u v
    } for % [ ... u v
    pop pop ]

end } def


% x y z ang -> x y' z'
/rotx { 3 dict begin
    /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
end } def

% x y z ang -> x' y z'
/roty { 4 dict begin
    /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
end } def

% x y z ang -> x' y' z
/rotz { 4 dict begin
    /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
end } def

% x y z -> x' y' z'
/model {
%ang roty
%ang .25 mul rotx
%alpha rotz
beta roty
%gamma rotx
} def

% Eye coords
/ex 0 def 
/ey 0 def
/ez 5 def

% x y z -> X Y
/project {
3 dict begin
    /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
end } def



%h R N
/cylinder { 20 dict begin
    /N exch def
    /R exch def
    /h exch def
    /dz 1 N div def
    /dt 360 dz mul def
    /hdz h dz mul def

    0 dz 1 dz sub {
        h mul h 2 div sub /z exch def

        0 dt 360 { /t exch def
            /v1 [ t cos R mul
                t sin R mul
                z model ] def
            /v4 [ v1 aload pop pop
                z hdz add model ] def
            /t t dt add def
            /v2 [ t cos R mul
                t sin R mul
                z model ] def
            /v3 [ v2 aload pop pop
                z hdz add model ] def
            /normal v4 v1 {sub} vop
                    v2 v1 {sub} vop
                    cross def
            [normal aload pop 1] [ex ey ez 1] dot 0 ge {
                /action { moveto /action { lineto } def } def
                [ v1 v2 v3 v4 ]
                { aload pop project action }
                forall
                closepath stroke
            } if
            
        } for
    } for
end } def

300 400 translate
1 50 dup dup scale div setlinewidth
/beta 90 def
4 2 10 cylinder


--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#926 — Re: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?

From"M. Joshua Ryan" <mijoryx@yahoo.com>
Date2012-09-04 12:49 -0500
SubjectRe: Hula-Hoop Hullaballoo! Re: ping luser- -droog: SVG or PS project for you?
Message-ID<k25evu$2jc8$1@adenine.netfront.net>
In reply to#925
Luser droog wrote:

> Well, something's gone very wrong here. But it's the failures
> that are most interesting, right?
> 
> The last thing I did was add the 'model' calls into the vectors
> and out of the 'project' procedure. But that seems right.
> I need to apply the model rotation before I take the normal vector
> for visibility. Maybe I need to normalize the normal.
> or the norml :)
> 
> I've inlined the matrix stuff, to save y'all some cut-and-paste
> or directory hunting or usenet archiving or giving up before you
> can laugh at this poor excuse for a cylinder. Somebody left it
> on the railroad tracks.
> 
> %!
> %The ol' cylinder, take 4
> 
> %(mat.ps) run
> %!
> %mat.ps
> %Matrix and Vector math routines
> 
> /.error where { pop /signalerror { .error } def } if
> 
> /dot { % u v
>     2 copy length exch length ne {
>         /dot cvx /undefinedresult signalerror
>     } if
>     % u v
>     0 % u v sum
>     0 1 3 index length 1 sub { % u v sum i
>         3 index 1 index get exch % u v sum u_i i
>         3 index exch get % u v sum u_i v_i
>         mul add % u v sum
>     } for % u v sum
> 
>     3 1 roll pop pop % sum
> } bind def
> 
> % [ x1 x2 x3 ] [ y1 y2 y3 ]  cross  [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2-x2*y1
> ] /cross { % u v
>     dup length 3 ne
>     2 index length 3 ne or {
>         /cross cvx /undefinedresult signalerror
>     } if
>     % u v
>     exch aload pop 4 3 roll aload pop % x1 x2 x3 y1 y2 y3
>     [
>         5 index 2 index mul % ... [ x2*y3
>         3 index 6 index mul sub % ... [ x2*y3-y2*x3
>         5 index 5 index mul % ... [ x2*y3-y2*x3 x3*y1
>         8 index 4 index mul sub % ... [ x2*y3-y2*x3 x3*y1-x1*y3
>         8 index 5 index mul % ... [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2
>         8 index 7 index mul sub % ... [ x2*y3-y2*x3 x3*y1-x1*y3
>         x1*y2-x2*y1
>     ]
>     7 1 roll 6 { pop } repeat
> } bind def
> 
> /transpose { STATICDICT begin
>     /A exch def
>     /M A length def
>     /N A 0 get length def
>     [
>     0 1 N 1 sub { /n exch def
>         [
>         0 1 M 1 sub { /m exch def
>             A m get n get
>         } for
>         ]
>     } for
>     ]
> end } dup 0 6 dict put def
> 
> /matmul { STATICDICT begin
>     /B exch def
>     B 0 get type /arraytype ne { /B [B] def } if
>     /A exch def
>     A 0 get type /arraytype ne { /A [A] def } if
>     /Q B length def
>     /R B 0 get length def
>     /P A length def
>     Q A 0 get length ne {
>         /A A transpose def
>         /P A length def
>         Q A 0 get length ne {
>             A B end /matmul cvx /undefinedresult signalerror
>         } if
>     } if
> 
>     [
>     0 1 R 1 sub { /r exch def
>         [
>         0 1 P 1 sub { /p exch def
>             0
>             0 1 Q 1 sub { /q exch def
>                 A p get q get
>                 B q get r get mul
>                 add
>             } for
>         } for
>         ]
>     } for
>     ]
> 
> end } dup 0 10 dict put def
> 
> %u v {operator}  vop  u(op)v
> %apply a binary operator to corresponding elements
> %in two vectors producing a third vector as result
> /vop { 1 dict begin
>     /op exch def
>     2 copy length exch length ne {
>         /vop cvx end /undefinedresult signalerror
>     } if
> 
>     [ 3 1 roll % [ u v
>     0 1 2 index length 1 sub { % [ ... u v i
>         3 copy exch pop get % u v i u_i
>         3 copy pop get      % u v i u_i v_i
>         op exch pop         % u v u_i(op)v_i
>         3 1 roll            % u_i(op)v_i u v
>     } for % [ ... u v
>     pop pop ]
> 
> end } def
> 
> 
> % x y z ang -> x y' z'
> /rotx { 3 dict begin
>     /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
> end } def
> 
> % x y z ang -> x' y z'
> /roty { 4 dict begin
>     /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
> end } def
> 
> % x y z ang -> x' y' z
> /rotz { 4 dict begin
>     /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
> end } def
> 
> % x y z -> x' y' z'
> /model {
> %ang roty
> %ang .25 mul rotx
> %alpha rotz
> beta roty
> %gamma rotx
> } def
> 
> % Eye coords
> /ex 0 def
> /ey 0 def
> /ez 5 def
> 
> % x y z -> X Y
> /project {
> 3 dict begin
>     /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
> end } def
> 
> 
> 
> %h R N
> /cylinder { 20 dict begin
>     /N exch def
>     /R exch def
>     /h exch def
>     /dz 1 N div def
>     /dt 360 dz mul def
>     /hdz h dz mul def
> 
>     0 dz 1 dz sub {
>         h mul h 2 div sub /z exch def
> 
>         0 dt 360 { /t exch def
>             /v1 [ t cos R mul
>                 t sin R mul
>                 z model ] def
>             /v4 [ v1 aload pop pop
>                 z hdz add model ] def

Here's the stupid. ^ the x and y of v4 and v3 get modelled twice.

>             /t t dt add def
>             /v2 [ t cos R mul
>                 t sin R mul
>                 z model ] def
>             /v3 [ v2 aload pop pop
>                 z hdz add model ] def

So take the 'model's out of the above and add this here:

            [ v1 v2 v3 v4 ] {
                aload 4 1 roll model 4 3 roll astore pop
            } forall

>             /normal v4 v1 {sub} vop
>                     v2 v1 {sub} vop
>                     cross def

I also tried normalizing the normal, but, of course it doesn't
change anything. The dot product still has the same sign.

            /nlen 0 normal { dup mul add } forall def
            /normal normal [nlen nlen nlen] {div} vop def

>             [normal aload pop 1] [ex ey ez 1] dot 0 ge {

Changing 'ge' to 'le' shows the front of the shape instead of the back.
Since the eye is at +z, the eye-vector is -z.

>                 /action { moveto /action { lineto } def } def
>                 [ v1 v2 v3 v4 ]
>                 { aload pop project action }
>                 forall
>                 closepath stroke
>             } if
>             
>         } for
>     } for
> end } def
> 
> 300 400 translate
> 1 50 dup dup scale div setlinewidth
> /beta 90 def
> 4 2 10 cylinder
> 
> 
> --- Posted via news://freenews.netfront.net/ - Complaints to
> news@netfront.net ---


--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#929 — A shaded cylinder

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-09-04 18:11 -0700
SubjectA shaded cylinder
Message-ID<4b7086f3-24d9-40e7-b1c8-da165ee98c12@googlegroups.com>
In reply to#926
I snagged a quick-and-dirty light model from Rogers' Procedural Elements.
Take off the wire-frame training wheels, and burn the background to 
bring up the white edge and now it looks like a thing!

Still not the "right" thing yet, but we're getting there.

505(1)08:08 PM:ps 0> cat 3d4.ps
%!
%A shaded cylinder! Woohoo!

%(mat.ps) run
%!
%mat.ps
%Matrix and Vector math routines

/.error where { pop /signalerror { .error } def } if

/dot { % u v
    2 copy length exch length ne {
        /dot cvx /undefinedresult signalerror
    } if
    % u v
    0 % u v sum
    0 1 3 index length 1 sub { % u v sum i
        3 index 1 index get exch % u v sum u_i i
        3 index exch get % u v sum u_i v_i
        mul add % u v sum
    } for % u v sum

    3 1 roll pop pop % sum
} bind def

% [ x1 x2 x3 ] [ y1 y2 y3 ]  cross  [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2-x2*y1 ]
/cross { % u v
    dup length 3 ne
    2 index length 3 ne or {
        /cross cvx /undefinedresult signalerror
    } if
    % u v
    exch aload pop 4 3 roll aload pop % x1 x2 x3 y1 y2 y3
    [
        5 index 2 index mul % ... [ x2*y3
        3 index 6 index mul sub % ... [ x2*y3-y2*x3
        5 index 5 index mul % ... [ x2*y3-y2*x3 x3*y1
        8 index 4 index mul sub % ... [ x2*y3-y2*x3 x3*y1-x1*y3
        8 index 5 index mul % ... [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2
        8 index 7 index mul sub % ... [ x2*y3-y2*x3 x3*y1-x1*y3 x1*y2-x2*y1
    ]
    7 1 roll 6 { pop } repeat
} bind def

/transpose { STATICDICT begin
    /A exch def
    /M A length def
    /N A 0 get length def
    [
    0 1 N 1 sub { /n exch def
        [
        0 1 M 1 sub { /m exch def
            A m get n get
        } for
        ]
    } for
    ]
end } dup 0 6 dict put def

/matmul { STATICDICT begin
    /B exch def
    B 0 get type /arraytype ne { /B [B] def } if
    /A exch def
    A 0 get type /arraytype ne { /A [A] def } if
    /Q B length def
    /R B 0 get length def
    /P A length def
    Q A 0 get length ne {
        /A A transpose def
        /P A length def
        Q A 0 get length ne {
            A B end /matmul cvx /undefinedresult signalerror
        } if
    } if

    [
    0 1 R 1 sub { /r exch def
        [
        0 1 P 1 sub { /p exch def
            0
            0 1 Q 1 sub { /q exch def
                A p get q get
                B q get r get mul
                add
            } for
        } for
        ]
    } for
    ]

end } dup 0 10 dict put def

%u v {operator}  vop  u(op)v
%apply a binary operator to corresponding elements
%in two vectors producing a third vector as result
/vop { 1 dict begin
    /op exch def
    2 copy length exch length ne {
        /vop cvx end /undefinedresult signalerror
    } if

    [ 3 1 roll % [ u v
    0 1 2 index length 1 sub { % [ ... u v i
        3 copy exch pop get % u v i u_i
        3 copy pop get      % u v i u_i v_i
        op exch pop         % u v u_i(op)v_i
        3 1 roll            % u_i(op)v_i u v
    } for % [ ... u v
    pop pop ]

end } def


%length of a vector
/mag { 0 exch { dup mul add } forall } def

% x y z ang -> x y' z'
/rotx { 3 dict begin
    /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
end } def

% x y z ang -> x' y z'
/roty { 4 dict begin
    /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
end } def

% x y z ang -> x' y' z
/rotz { 4 dict begin
    /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
end } def

% x y z -> x' y' z'
/model {
%ang roty
%ang .25 mul rotx
%alpha rotz
beta roty
gamma rotx
} def

% Eye coords
/ex .1 def
/ey .1 def
/ez 5 def
/eyedir [ex ey ez]
    dup mag [ exch dup dup ]{div} vop
def

% x y z -> X Y
/project {
3 dict begin
    /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
end } def

/light
    [ 3 -7 -2 1 ]
    dup mag [ exch dup dup dup ]{div} vop
def
/Ia .4 def % Incident Ambient Intensity
/Ka .4 def % Ambient Diffuse reflection constant
/Il .5 def % Incident intensity of Lightsource
/Kd .3 def % Diffuse reflection constant

%h R N
/cylinder { 20 dict begin
    /N exch def
    /R exch def
    /h exch def
    /dz 1 N div def
    /dt 360 dz mul def
    /hdz h dz mul def

    0 dz 1 dz sub {
        h mul h 2 div sub /z exch def

        0 dt 360 { /t exch def
            /v1 [ t cos R mul
                t sin R mul
                z ] def
            /v4 [ v1 aload pop pop
                z hdz add ] def
            /t t dt add def
            /v2 [ t cos R mul
                t sin R mul
                z ] def
            /v3 [ v2 aload pop pop
                z hdz add ] def
            [ v1 v2 v3 v4 ] {
                aload 4 1 roll model 4 3 roll astore pop
            } forall
            /normal v4 v1 {sub} vop
                    v2 v1 {sub} vop
                    cross def
            /nlen normal mag def
            /normal normal [nlen nlen nlen] {div} vop def
            [normal aload pop 1] [eyedir aload pop 1] dot 0 lt {
                /action { moveto /action { lineto } def } def
                [ v1 v2 v3 v4 ]
                { aload pop project action }
                forall
                closepath
                gsave
                    [normal aload pop 1]
                    light
                    %[ex ey ez neg 1] %"radiant"
                    dot
                    Il Kd mul mul
                    Ia Ka mul add
                    setgray
                    fill
                grestore
                stroke
            } if

        } for
    } for
end } def

300 400 translate
280 dup dup moveto
dup neg dup neg lineto
dup neg dup lineto
dup neg lineto closepath .6 setgray fill
1 70 dup dup scale div setlinewidth

/beta 0 def
/gamma 0 def
4 2 50 cylinder

/beta 90 def
/gamma 0 def
4 2 50 cylinder

/beta 0 def
/gamma 90 def
4 2 50 cylinder
                      

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.postscript


csiph-web