POV-Ray : Newsgroups : povray.general : Curved line : Re: Curved line Server Time
30 Jul 2024 12:27:15 EDT (-0400)
  Re: Curved line  
From: Chris B
Date: 19 Feb 2009 09:20:12
Message: <499d6a9c$1@news.povray.org>
"twister" <twi### [at] o2pl> wrote in message 
news:web.499d45114c7fcf678896485d0@news.povray.org...
> Thanks Chris!
>
> I find the prism model more accurate for my purposes. I also think of 
> marking
> the points at specific length of spline. For example if spline has overall
> length of 32.1 units I would like to find a point where the length is 10. 
> Is
> there any functions which provide such information?
>
> Best regards,
> Twister
>

Someone might have an existing macro, otherwise you can just loop through 
using the vlength function to calculate a cumulative spline length and add 
some logic to detect specific distances along the spline. The following 
example plugs into the example I gave before, so I've used a distance of 2 
rather than 10 (my spline wasn't 10 units long).

Regards,
Chris B.

// Initialise some variables.
#declare PreviousPosition = MySpline(0);
#declare I = 0.01;
#declare CumulativeLength = 0;
// Loop through the spline keeping account of the length
#while (I < 1)
  #declare ThisPosition = MySpline(I);
  #declare CumulativeLength = 
CumulativeLength+vlength(ThisPosition-PreviousPosition);
  // If we didn't reach 2 units before, but we reached it now, record the 
location.
  #ifndef(Position_2)
    #if (CumulativeLength>2) #declare Position_2 = ThisPosition; #end
  #end
  // Get ready for the next iteration of the loop
  #declare PreviousPosition = ThisPosition;
  #declare I = I + 0.01;
#end

// Add a sphere and write the location into the message stream.
#ifdef (Position_2)
  sphere {Position_2,0.1 pigment {rgb <1,0,0>}}
  #debug concat("Position_10: ",vstr(3,Position_2,",",3,3),"\n")
#end


Post a reply to this message

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