POV-Ray : Newsgroups : povray.programming : "Clean" debugging Server Time
25 Oct 2025 10:58:12 EDT (-0400)
  "Clean" debugging (Message 1 to 5 of 5)  
From: Bald Eagle
Subject: "Clean" debugging
Date: 23 Oct 2025 10:10:00
Message: <web.68fa360b84d70c9376d02faa25979125@news.povray.org>
So, I have had to include a lot of output to the debug stream to inspect values
passed into macros, compare results of macros to tests done in other macros, and
inspect the code flow so that I can see how the logic of various test results
get directed.

Doing
#if (Test)
     #debug (something)
#end

clutters the code, is tedious, and if everything is spread out all across the
code, it is a nightmare to turn on and off.

So what I did was test for a Global_Debug identifier, and if defined, then I
enable the #debug statements.

I do that by creating a macro called Debug ()

Then everything gets wrapped in Debug ( ), sans the #debug statement.
Then it's just one line, can be kept in the code, is trivial to turn on and off,
and all of the #if () #end stuff is in a single tiny macro.

It's simple, and I suppose obvious, but just thought I'd include it here in case
anyone derives benefit from it.

- BE


Post a reply to this message

From: Leroy
Subject: Re: "Clean" debugging
Date: 23 Oct 2025 14:20:00
Message: <web.68fa70f846e6a89d98e0cf93f712fc00@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> So, I have had to include a lot of output to the debug stream to inspect values
> passed into macros, compare results of macros to tests done in other macros, and
> inspect the code flow so that I can see how the logic of various test results
> get directed.
>
> Doing
> #if (Test)
>      #debug (something)
> #end
>
> clutters the code, is tedious, and if everything is spread out all across the
> code, it is a nightmare to turn on and off.
>
> So what I did was test for a Global_Debug identifier, and if defined, then I
> enable the #debug statements.
>
> I do that by creating a macro called Debug ()
>
> Then everything gets wrapped in Debug ( ), sans the #debug statement.
> Then it's just one line, can be kept in the code, is trivial to turn on and off,
> and all of the #if () #end stuff is in a single tiny macro.
>
> It's simple, and I suppose obvious, but just thought I'd include it here in case
> anyone derives benefit from it.
>
> - BE

How about using debug.inc? It has some of the stuff you talked about. I debug
everything and I normally don't delete a debug but comment it out(never know
when ya might need it again)
Have Fun!


Post a reply to this message

From: Bald Eagle
Subject: Re: "Clean" debugging
Date: 23 Oct 2025 15:40:00
Message: <web.68fa83c846e6a89d9a57bf1d25979125@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:

> How about using debug.inc? It has some of the stuff you talked about.

1. Because I haven't used that file in over a decade, and forgot about it.

2. Why do that when I can reinvent the wheel?   :D

Thanks,

- BW


Post a reply to this message

From: Maetes
Subject: Re: "Clean" debugging
Date: 24 Oct 2025 08:55:00
Message: <web.68fb76ea46e6a89d1dcfd1bf30225ff5@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> So, I have had to include a lot of output to the debug stream to inspect values
> passed into macros, compare results of macros to tests done in other macros, and
> inspect the code flow so that I can see how the logic of various test results
> get directed.
>

I've also been on the verge of writing a pseudo debug class for Povray several
times

If you want to output arrays into a file, you can give my function a chance.

See:
https://www.maetes.com/en/povray-os/ma_helpers#ma-outputarraystring

ma


Post a reply to this message

From: Bald Eagle
Subject: Re: "Clean" debugging
Date: 24 Oct 2025 09:30:00
Message: <web.68fb7f3046e6a89d7f81dbac25979125@news.povray.org>
"Maetes" <nomail@nomail> wrote:

> See:
> https://www.maetes.com/en/povray-os/ma_helpers#ma-outputarraystring
>
> ma

Hey - that's a really nice page with some useful stuff!
I especially like the look of that deprecated macro tool.

I will hopefully get a chance to look that over in depth at some point, and my
personal wish is that we get a lot of your ideas formally logged on the
newsgroup website or wiki in some way.

I would love to see more exposure of people's work like yours, and some
collaborative projects to develop equations, macros, and other tools to help
keep things moving forward, so that we can make coding scenes easier and more
efficient, identify and hopefully fix bugs, and create new features.

As a small thanks, try the inverse macro following you own, and let me know if
there are any problems.

#macro MA_Deg2Vector  (RightAscension, Declination, mRadius)
 #local mRect = radians(RightAscension + MA_Deg2Vector_RA_Offset);
 #local Declination = radians(Declination);
 //Here we have the critical lines
 #local mPosX = mRadius * sin(Declination) * cos (mRect);
 #local mPosY = mRadius * cos(Declination);
 #local mPosZ = mRadius * sin(Declination) * sin (mRect);
 #local mVector = <mPosX, mPosY * -1, mPosZ>;
 mVector
#end

Inverse:

#declare MA_Deg2Vector_RA_Offset = 0; // Define this globally if not already

#macro MA_Vector2Deg(Vector)
  #local x =  Vector.x;
  #local y = -Vector.y; // Invert Y to match original convention
  #local z =  Vector.z;

  #local Radius = sqrt (x*x + y*y + z*z);
  #local Declination = degrees (asin(z / Radius));
  #local RA = degrees (atan2(x, y)) - MA_Deg2Vector_RA_Offset;

  // Normalize RA to [0, 360)
  #while (RA < 0)
    #local RA = RA + 360;
  #end
  #while (RA >= 360)
    #local RA = RA - 360;
  #end

  array[3] { RA, Declination, Radius }
#end


- BW


Post a reply to this message

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