POV-Ray : Newsgroups : povray.advanced-users : Parallel (offset) curve - odd behaviour Server Time
29 Mar 2024 03:18:18 EDT (-0400)
  Parallel (offset) curve - odd behaviour (Message 1 to 4 of 4)  
From: Bald Eagle
Subject: Parallel (offset) curve - odd behaviour
Date: 26 May 2017 07:55:00
Message: <web.592816879146df1fc437ac910@news.povray.org>
I needed to work on the sine wave, and after two abysmal attempts at thickening
the curve, I was able to get something that was well-behaved, looked good, and
was fast.
I'm sure I could have gone all Xah Lee on this and differentiated the curve, but
I stuck with "practical" and just used trace() to get the normal vector.

The only issue is that the entire curve for x < 0 is different, and there's a
pronounced "ledge" at x=0.  I'm not sure why.

Perhaps someone with more experience with trace and vectors will spot the
difficulty faster than I can.

(This is currently for a laser-cutter, not a router, so I need to stack thin
lines (0.24 mm) rather than just plug in a wider bit - thus the method used
here.)

Commented-out code at bottom is 2 aborted attempts.



#version 3.7;
global_settings {
 assumed_gamma 1.0
}

#include "colors.inc"

#declare Feet = 12;
#declare PHI = (1+sqrt(5))/2;
#declare phi = (sqrt(5)-1)/2;

#declare Camera_Orthographic = true;
#declare Camera_Position = <0, 0, -300> ;  // front view
#declare Camera_Look_At  = <0, 0,  0> ;
#declare Fraction = 1;     // functions as a zoom for the orthographic view: 4
zooms in 4x, 8 zooms in 8x, etc.

// ###########################################
camera {
 #if (Camera_Orthographic = true)
  orthographic
  right     x*image_width/(Fraction)
  up   y*image_height/(Fraction)
 #else
  right     x*image_width/image_height
  up y
 #end
 location  Camera_Position
 look_at   Camera_Look_At}
// ###########################################

background {White}

light_source {<0, 10, -500> color White*0.5}

#declare Origin = sphere {0, 1 pigment {Black}}
//object {Origin}

#declare HW = image_width/2;
#declare HH = image_height/2;

#declare F = 4;

#declare Freq = F*tau/image_width;
#declare YScale = 100;
#declare R=0.5;

// Central curve
#declare Curve =
union {
#for (T, -HW, HW)
 #local XX = T;
 #local YY = YScale*sin (XX*Freq);
 sphere {<XX, YY, -1> R pigment {Black}}
 #if (T > 0)
  cylinder {LastPoint, <XX, YY, -1> R pigment {Black}}
 #end
 #local LastPoint = <XX, YY, -1>;
#end
}

object {Curve}

#declare L = 20;
 #declare Current = array [L];
 #declare Last = array [L];
 #declare C = 0;
 #for (T, -HW, HW, 2)
  #local XX = T;
  #local YY = (YScale*sin (XX*Freq))+(L*2*R);
  #declare Norm = <0, 0, 0>;
  #declare Start = <XX, YY, -1>;
  #declare Inter = trace (Curve, Start, <0, -abs(YY), 0>, Norm);
  #if (vlength (Norm) != 0)
   #for (Layer, 0, L-1)
    #declare Current[Layer] = Inter + (Norm*R*Layer);
    sphere {Current[Layer] R pigment {Red}}
    #if (C > 0)
     cylinder {Last[Layer], Current[Layer] R pigment {Red}}
    #end // end if
   #end // end for Layer
  #end // end if vlength
  #declare C = C+1;
  #for (Layer, 0, L-1)
   #local Last[Layer] = Current[Layer];
  #end
 #end

/*
#declare L = 10;
#for (N, 1, L)
 #declare Parallel = union {
 #declare C = 0;
 #for (T, -HW, HW, 2)
  #local XX = T;
  #local YY = (YScale*sin (XX*Freq))+(L*2*R);
  #declare Norm = <0, 0, 0>;
  #declare Start = <XX, YY, -1>;
  #declare Inter = trace (Curve, Start, <0, -abs(YY), 0>, Norm);
  #if (vlength (Norm) != 0)
   #declare Current = Inter + Norm;
    sphere {Current R pigment {Red}}
   #if (C > 0)
    cylinder {LastPoint, Current R pigment {Red}}
   #end
  #end
  #declare C = C+1;
  #local LastPoint = Current;
 #end
 }
#declare Curve = union {object {Curve} object {Parallel}}
#end

object {Curve}
*/


/*
#for (N, 1, 5)
 #declare Flag = -1;
 #for (T, -HW, HW)
  #local XX = T;
  #local Skip = 0;
  #if (Flag = -1)
   #local Freq = F*tau/(image_width+(N*4*R));
   #local YY = (YScale+N*R)*sin (XX*Freq);
   #local Pigment = pigment {Red};
   #if (YY > 0)
    #declare Flag = -Flag;
    //#declare T = T -1;
    #declare Skip = 1;
   #end
  #else
   #local Freq = F*tau/(image_width-(N*4*R));
   #local YY = (YScale-N*R)*sin (XX*Freq);
   #local Pigment = pigment {Blue};
   #if (YY < 0)
    #declare Flag = -Flag;
    //#declare T = T -1;
    #declare Skip = 1;
   #end
  #end

  #if (Skip != 1)
   sphere {<XX, YY, -1> R pigment {Pigment}}
   #if (T > 0)
    cylinder {LastPoint, <XX, YY, -1> R pigment {Pigment}}
   #end
   #local LastPoint = <XX, YY, -1>;
  #end
 #end
#end
*/


Post a reply to this message

From: scott
Subject: Re: Parallel (offset) curve - odd behaviour
Date: 26 May 2017 08:15:15
Message: <59281c53$1@news.povray.org>
> #version 3.7;
> global_settings {
>  assumed_gamma 1.0
> }
>
> #include "colors.inc"
>
> #declare Feet = 12;
> #declare PHI = (1+sqrt(5))/2;
> #declare phi = (sqrt(5)-1)/2;
>
> #declare Camera_Orthographic = true;
> #declare Camera_Position = <0, 0, -300> ;  // front view
> #declare Camera_Look_At  = <0, 0,  0> ;
> #declare Fraction = 1;     // functions as a zoom for the orthographic view: 4
> zooms in 4x, 8 zooms in 8x, etc.
>
> // ###########################################
> camera {
>  #if (Camera_Orthographic = true)
>   orthographic
>   right     x*image_width/(Fraction)
>   up   y*image_height/(Fraction)
>  #else
>   right     x*image_width/image_height
>   up y
>  #end
>  location  Camera_Position
>  look_at   Camera_Look_At}
> // ###########################################
>
> background {White}
>
> light_source {<0, 10, -500> color White*0.5}
>
> #declare Origin = sphere {0, 1 pigment {Black}}
> //object {Origin}
>
> #declare HW = image_width/2;
> #declare HH = image_height/2;
>
> #declare F = 4;
>
> #declare Freq = F*tau/image_width;
> #declare YScale = 100;
> #declare R=0.5;
>
> // Central curve
> #declare Curve =
> union {
> #for (T, -HW, HW)
>  #local XX = T;
>  #local YY = YScale*sin (XX*Freq);
>  sphere {<XX, YY, -1> R pigment {Black}}
>  #if (T > 0)

That line should be

#if (T>-HW)

Otherwise "Curve" is not what I think you meant it to be...


Post a reply to this message

From: Bald Eagle
Subject: Re: Parallel (offset) curve - odd behaviour
Date: 26 May 2017 10:05:00
Message: <web.592835dbd186edbec437ac910@news.povray.org>
scott <sco### [at] scottcom> wrote:


> That line should be
>
> #if (T>-HW)
>
> Otherwise "Curve" is not what I think you meant it to be...

Super!
I just needed to add my C counter in there like I did for the offset curve and
check C instead of T.   That did the trick.  :)

Tired brain and tired eyes.
Glad it was just a coding omission rather than something in the math.

Thanks for catching that.


Post a reply to this message

From: posfan12
Subject: Re: Parallel (offset) curve - odd behaviour
Date: 19 Jul 2018 21:40:01
Message: <web.5b513d1cd186edbe34baa4ef0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> scott <sco### [at] scottcom> wrote:
>
>
> > That line should be
> >
> > #if (T>-HW)
> >
> > Otherwise "Curve" is not what I think you meant it to be...
>
> Super!
> I just needed to add my C counter in there like I did for the offset curve and
> check C instead of T.   That did the trick.  :)
>
> Tired brain and tired eyes.
> Glad it was just a coding omission rather than something in the math.
>
> Thanks for catching that.


Could you post the fixed code please?


Mike


Post a reply to this message

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