POV-Ray : Newsgroups : povray.general : Edge detection : Re: Edge detection Server Time
29 Jul 2024 02:28:39 EDT (-0400)
  Re: Edge detection  
From: Anthony D  Baye
Date: 13 Aug 2013 03:05:05
Message: <web.5209d9c029bc8274328783aa0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> > You can create splines using Inkscape.  I also have a set of LOGO turtle macros
> > that can be used to create splines...
>
> I like it.  How do I take the points from the path generated by Trace Bitmap and
> import those coordinates into POV-Ray?

I'm not sure.  I've never used it myself, but if you can export as either an svg
file or rawtext, you can copy the points directly using a text editor.

>
> LOGO.  I wouldn't have thought of that.  I like the simple stuff.
> Does it work well?

I created them so I could do some experiments with 2D fractals; Things like Koch
flakes and Gosper islands.  I've included a DUMP() macro which takes a single
argument that will dump the contents of the lSpline array to a file as a natural
spline.

before using any of the other macros you need to call Init() - this sets up the
environment variables for the "turtle".  Calling Init() again will reset the
environment, so you can construct multiple splines in one file.

the fd() and

The logo_prism object is, as the name suggests, a prism made from the lSpline
array.

points are only appended to lSpline if _Draw_ = true, you can use pu() and pd()
to set that.  (This is handy for making complex splines)

I haven't played with these in a while, so they're a bit rough around the edges.
 Feel free to tinker with the code.

I hope you find them useful.

Regards,
A.D.B.

#include "kolors.inc"
#include "math.inc"
#include "arrays.inc"

#macro init()
#ifdef(logo_prism)
    #undef(logo_prism)
#end
#declare _cP_ = <0.0, 0.0, 0.0>;
#declare _cD_ = 0;
#declare _DRAW_ = true;
#declare _MAX_SIZE_ = 100000000;
#declare _SPLINE_SIZE_ = 0;
#declare lSpline = array[1] {<0,0>};
#end

// Pen Up
#macro pu()
     #declare _DRAW_ = false;
#end

// Pen Down
#macro pd()
     #declare _DRAW_ = true;
#end

// left turn (degrees)
#macro lt(d)
     #declare _cD_ = _cD_ + d;
     #if(_cD_ > 360)
          #declare _cD_ = _cD_ - 360;
     #end
#end

// right turn (degrees)
#macro rt(d)
     #declare _cD_ = _cD_ - d;
     #if(_cD_ < -360)
          #declare _cD_ = _cD_ + 360;
     #end
#end

// foreward (length)
#macro fd(l)
     #local _pL_ = _cP_;
     #declare _cP_ = _cP_ + l*<cosd(_cD_), sind(_cD_), 0>;

     #if(_DRAW_)
//        cylinder { _pL_, _cP_, 0.015625 pigment {Orange}
//             finish { ambient 0.6 diffuse 0.3 } }
          #if(_SPLINE_SIZE_ = 0)
               #declare lSpline[0] = <_pL_.x,_pL_.y>;
//               #debug concat("adding " vstr(2,_cP_,", ",0 ,4) " to lSpline\n")
          #else
               Resize_Array(lSpline, _SPLINE_SIZE_ + 1)
               #declare lSpline[_SPLINE_SIZE_] = <_cP_.x,_cP_.y>;
          #end
          #declare _SPLINE_SIZE_ = _SPLINE_SIZE_ + 1;
//        #debug concat("current point = " vstr(2,lSpline[_SPLINE_SIZE_-1],",
",0 ,4) "\n")
     #end
//     #debug concat("moving to: " vstr(2,_cP_,", ",0 ,4) "\n")
#end

#macro DUMP(fName)

#local OPEN = concat("spline {\nnatural_spline\n", str(_SPLINE_SIZE_,0,0), "\n")
#local CLOSE = "\n}\n";

#fopen DUMP_FILE fName write
#write(DUMP_FILE, OPEN)
#local j = 0;
#while(j < _SPLINE_SIZE_)
     #local OUTPUT = concat(str(j/_SPLINE_SIZE_,0,4)", <"str(lSpline[j].u,0,4)
", " str(lSpline[j].v,0,4) ">\n")
     #write(DUMP_FILE, OUTPUT)
//     #debug OUTPUT
#local j = j + 1;
#end
#write(DUMP_FILE, CLOSE)
#fclose DUMP_FILE

#end

#macro PRISM(i, f)

#declare logo_prism =
prism {
     linear_sweep
     linear_spline
     i, f, _SPLINE_SIZE_
#local c = 0;
#while(c < _SPLINE_SIZE_)
     <lSpline[c].u, lSpline[c].v>
#local c = c + 1;
#end
     }

#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.