POV-Ray : Newsgroups : povray.general : 2D function to 3D tube : Re: 2D function to 3D tube Server Time
25 Apr 2024 20:50:43 EDT (-0400)
  Re: 2D function to 3D tube  
From: Bald Eagle
Date: 23 Dec 2022 13:35:00
Message: <web.63a5f4bb560d61681f9dae3025979125@news.povray.org>
"Droj" <803### [at] drojde> wrote:

> I spent some time to read what Wikipedia says about atan2 function.
> Well, it gave me a nice headache but didn't clear the muddy waters.
> The only thing I realised is that the function has to change depending on the
> quadrants the graph passes.

Well, I did do a lot of sleuthing last night, and got a nice diagram with the
curve, vertical circle, tangent line, angle, and rotated circle.  Seemed to work
very nicely on y=pow(x,2).

Going back to your original unedited scene, it's clear that at the very least
you have the arguments for atan2 switched - it's atan2 (y, x).  You also need to
use QY in both F1 and F2.
Im my homebrew code, I'm using atan2 (f'(x)*x, x), since that's going to be each
cathetus of the right triangle representing the tangent line and the x-axis.

That's going to require some refactoring to deal with the parametric vs implicit
 equations, but I went and did that....

.... but after that, I can't seem to straighten out the atan2 issue in your scene
code - and I'm suspecting that it may be an issue with the way that meshmaker
handles the generation of the triangles.  It may be straddling regions such that
the sides of the curve get switched, or something similar.

Hopefully I'll give it a further look and see if that's the issue.   I'm going
to try to make a much finer mesh and see if that minimizes or even eliminates
the problem.

> BTW I used the macro:
>
> #for (N, 0, tau, tau/180)
>  #local X = FX (N);
>  #local Y = FY (N);
>  sphere {<X/4, Y/4, 0> 0.01 pigment {rgb y}}
>  cylinder {0, x 0.05 pigment {rgb z} rotate z*degrees(PHI (N)) translate <X/4,
> Y/4, 0>}
> #end
> but Povray at once complaint about 'undeclared tau'.
> Can you give me a hint what that macro does? I am ignorant I know!
>
> I promise to be persistant and as being a chemist I can be very persistant.

Excellent - fellow chemist here, persistence just didn't pay off as much as it
needed to in that field.  :(

tau is simply 2*pi (available in v3.8), so you can either replace that, or just
put a line near the beginning of the scene:

#declare tau = 2*pi;

I'm confident that this is a solvable problem.

-BW


Post a reply to this message


Attachments:
Download 'tubecurves.png' (117 KB)

Preview of image 'tubecurves.png'
tubecurves.png


 

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