POV-Ray : Newsgroups : povray.newusers : Problem with macros and translate function :/ : Re: Problem with macros and translate function :/ Server Time
18 May 2024 05:09:32 EDT (-0400)
  Re: Problem with macros and translate function :/  
From: Bald Eagle
Date: 23 Aug 2023 14:10:00
Message: <web.64e64a5ad6a8965b1f9dae3025979125@news.povray.org>
"aysays" <nomail@nomail> wrote:
> Hello I'm new to Pov-Ray and am trying to write a broccoli fractal code however
> I'm having problems with the translate function. If I understood it correctly,
> translate only accepts numerical values. I tried writing a macro but that didn't
> work either. How am I supposed to write a recursive function that utilizes
> translate?

The first thing I noticed when trying to format/indent your code (and
simultaneously make jr twitch by using TAB characters to denote whitespace) was
that you cone definition and while loop are .... disjoint.

Also, sin and cos expect angle expressed in radians.


I don't see much of a difference when changing the camera location, so something
strange is going on.  I also don't get much of a difference when I multiply your
x and y values in the translate function by as much as 10.   So you may not be
translating as much as you think you ought to be.
Scaling that cone after translating causes an(other), probably unintentional
translation, due to the offset from the origin.
Scaling by 0.15 100 times is going to make those other cones SMALL, probably to
the point of invisibility, especially since they are currently (?) hidden by the
first cone, since all the others don't get translated far enough away from the
first one. (speculating)

What you want to do is plan out a little more clearly what ought to be
happening.
Include some comments describing exactly what you want to happen at each stage,
and then comment each line to describe what each line actually does.

I'd probably make the macro determine the location and scale of the cone, and
instantiate it, an put the macro call(s) in the while loop.  Just to make things
clearer.  Maybe calculate the translate and scaling separately, and output those
values to the debug stream, so you can see what's _actually_ happening
(numerically)

I'd also calculate your n value, check to make sure it's non-zero, and THEN call
the macro recursively if that's the case.  seems clearer.

- BW

I think you're close, but the logic of the scene needs to be cleaned up a bit.


Post a reply to this message

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