 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Leroy" <whe### [at] gmail com> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bald Eagle" <cre### [at] netscape net> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2025-10-23 10:04 (-4), Bald Eagle wrote:
>
> It's simple, and I suppose obvious, but just thought I'd include it here in case
> anyone derives benefit from it.
I've done that on occasion. I should perhaps do it more often.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2025-10-23 14:16 (-4), Leroy wrote:
> 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!
I looked at it years ago, and decided it didn't *quite* fit my needs.
Taking another look at it just now, it seems that the macros are too
general for my tastes. I might use it if it fits exactly my needs, but
then I'd have to remember check it for every project. It just seems
easier to write custom macros for each project.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
> "Maetes" <nomail@nomail> wrote:
>
> > See:
> > https://www.maetes.com/en/povray-os/ma_helpers#ma-outputarraystring
> Hey - that's a really nice page with some useful stuff!
Tanks for that!
Since I have no idea if anyone uses my scripts at all, I have neglected new
releases for the last months. Halfway completing the code, documenting it
and presenting it on a page takes an enormous amount of time.
> 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.
These could be my words. Maybe we will manage to exchange ideas better in the
future.
> As a small thanks, try the inverse macro following you own, and let me know if
> there are any problems.
Tanks, but unfortunately it crashes in the first line. After I fixed it, the
result wasnt as expected. I tried more than an hour, without success.
I will give it somewhen later anoter try.
The first and last output should be the same.
*** MA => Deg2Vector-Input: 100.000000,-50.000000,333.000000
*** MA => Deg2Vector-Result: 251.217,-214.048,44.296,0.000,0.000
*** MA => Vector2Deg-Result: 49.567539,7.644270,333.000000
Code:
--------
#local mRA = 100;
#local mDE = -50;
#local mRadius = 333;
MA_Terminal_AF("Deg2Vector-Input", array[3] { mRA, mDE, mRadius})
#local vResult = MA_Deg2Vector00 ( mRA, mDE, mRadius );
MA_Terminal_V("Deg2Vector-Result", vResult)
#local aResult = MA_Vector2Deg(vResult);
MA_Terminal_AF("Vector2Deg-Result", aResult)
Macro:
--------
#declare MA_Deg2Vector_RA_Offset = 0; // Define this globally if not already
#macro MA_Vector2Deg(mVector)
#local mX = mVector.x;
#local mY = -mVector.y; // Invert Y to match original convention
#local mZ = mVector.z;
#local Radius = sqrt (mX*mX + mY*mY + mZ*mZ);
#local Declination = degrees (asin(mZ / Radius));
#local RA = degrees (atan2(mX, mY)) - 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
ma
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Cousin Ricky <ric### [at] yahoo com> wrote:
> On 2025-10-23 14:16 (-4), Leroy wrote:
> > How about using debug.inc? It has some of the stuff you talked about.
>
> I looked at it years ago, and decided it didn't *quite* fit my needs.
> Taking another look at it just now, it seems that the macros are too
> general for my tastes. I might use it if it fits exactly my needs, but
> then I'd have to remember check it for every project. It just seems
> easier to write custom macros for each project.
What do you expect?
As written, I had already started with something like this. That you can tell
the debug "class" waypoints (executed macro X), pass variables, store everything
in a log file...
We could collect ideas.
I'm good at that. I'm lousy at textures and object design, but a good
programmer. If others would help me in exchange with textures and media without
me having a heart attack ...
...... that would be a extremly good deal for me.
Ma
PS:
I need a damn planetary atmosphere. A variable one, that really works with
serveral objects and sizes, and that I understand. Yes, I have found some
Threads here in the forum, but ... (heart attack)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Maetes" <nomail@nomail> wrote:
> Tanks, but unfortunately it crashes in the first line. After I fixed it, the
> result wasnt as expected. I tried more than an hour, without success.
> I will give it somewhen later anoter try.
Nein.
Try this alternate version:
returns a vector <RA, Declination, Radius> with angles in degrees and RA
normalized to [0,360).
#declare MA_Deg2Vector_RA_Offset = 0;
// Forward: (RA, Dec, Radius) -> <x, y, z>
#macro MA_Deg2Vector(S_RA, S_Dec, S_Radius)
#local S_Rect = radians(S_RA + MA_Deg2Vector_RA_Offset);
#local S_DecRad = radians(S_Dec);
#local S_X = S_Radius * sin(S_DecRad) * cos(S_Rect);
#local S_Y = S_Radius * cos(S_DecRad);
#local S_Z = S_Radius * sin(S_DecRad) * sin(S_Rect);
#local V_Out = <S_X, -S_Y, S_Z>;
V_Out
#end
// Inverse: <x, y, z> -> <RA, Dec, Radius>
#macro MA_Vector2Deg(V_In)
// Undo the original Y inversion
#local S_X = V_In.x;
#local S_Y = -V_In.y;
#local S_Z = V_In.z;
#local S_Radius = sqrt(S_XS_X + S_YS_Y + S_Z*S_Z);
// Handle the degenerate zero-length vector
#if (S_Radius < 1e-12)
<0, 0, 0>
#else
// θ (the "rectangular" angle used in the forward mapping) from x,z
// NOTE: atan2(y, x) in POV-Ray; we want θ = atan2(z, x).
#local S_Theta = atan2(S_Z, S_X); // radians
// Recover sin(Dec) with its sign using both x & z and the θ we just found:
// x = r*sin(Dec)*cosθ, z = r*sin(Dec)*sinθ
// => x*cosθ + z*sinθ = r*sin(Dec)
#local S_SinDec = (S_X * cos(S_Theta) + S_Z * sin(S_Theta)) / S_Radius;
// Clamp for numeric safety
#if (S_SinDec > 1) #local S_SinDec = 1; #end
#if (S_SinDec < -1) #local S_SinDec = -1; #end
#local S_Dec = degrees(asin(S_SinDec));
#local S_RA = degrees(S_Theta) - MA_Deg2Vector_RA_Offset;
// Normalize RA into [0, 360)
#while (S_RA < 0)
#local S_RA = S_RA + 360;
#end
#while (S_RA >= 360)
#local S_RA = S_RA - 360;
#end
<S_RA, S_Dec, S_Radius>
#end
#end
// Example round-trip test
//#declare V1 = MA_Deg2Vector(35, -20, 10);
//#declare P1 = MA_Vector2Deg(V1); // P1 = <RA, Dec, R>
//#debug concat("RA=",str(P1.x,0,3),", Dec=",str(P1.y,0,3),",
R=",str(P1.z,0,3),"\n")
// end of code
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
>
> Try this alternate version:
Doesnt work.
It's untested AI-shit, right?
Please forget this macro.
I had hoped to get the invers-version of the Deg2Vector macro, but it has no
priority. Somewhen I will find the solution, but I will not invest another hour
in it.
ma
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Worked it out by hand.
Tested.
Works for all but the edge cases where X and Z are 0.
Fair notice: There's a weird hack or two in there.
:)
#declare MA_Deg2Vector_RA_Offset = 180;
// Forward: (RA, Dec, Radius) -> <x, y, z>
#local E = 1E-6;
#macro Sign (N)
select (N, -1, 0, 1)
#end
#macro MA_Deg2Vector (S_RA, S_Dec, S_Radius)
#local S_RA = S_RA + MA_Deg2Vector_RA_Offset;
#local S_Rect = radians(S_RA);
#local S_Dec = S_Dec + 180;
#local S_DecRad = radians(S_Dec);
#local S_DecRad = S_DecRad/2;
#local S_X = S_Radius * sin(S_DecRad) * cos(S_Rect);
#local S_Y = S_Radius * cos(S_DecRad);
#local S_Z = S_Radius * sin(S_DecRad) * sin(S_Rect);
#local V_Out = <S_X, -S_Y, S_Z>;
V_Out
#end
#macro MA_Vector2Deg (V_In)
// Undo the original Y inversion
#local S_X = V_In.x;
#local S_Y = -V_In.y;
#local S_Z = V_In.z;
#local Radius = sqrt(S_X*S_X + S_Y*S_Y + S_Z*S_Z);
// Handle the degenerate zero-length vector
#if (Radius < 1e-12)
#local Result = <0, 0, 0>;
#else
//#if (abs(S_Z) < E) S_Z = 0 #end
#local PreDecRad = S_Y / Radius;
// Clamp for numeric safety
#local PreDecRad = max (min (PreDecRad, 1), -1);
#local DecRad1 = acos (PreDecRad);
#local DecRad = DecRad1 * 2;
#local Dec = degrees (DecRad);
#local Dec = Dec - 180;
// Try to fix edge cases
//====================================================
#if (abs(S_X) < E)
#local FF = E;
#local S_X2 = FF*Sign(S_X);
#local S_Y2 = S_Y + FF*Sign(S_X);
#local S_Z2 = FF*Sign(S_X);
#local PreDecRad = S_Y2 / Radius;
#local PreDecRad = max (min (PreDecRad, 1), -1);
#local DecRad1 = acos (PreDecRad);
#else
#local S_X2 = S_X;
#local S_Y2 = S_Y;
#local S_Z2 = S_Z;
#end
//====================================================
#local SinDecRad1 = sin (DecRad1);
#if (abs(SinDecRad1) < E)
#local SinDecRad1 = 1;
#end
#local PreRect = S_Z2 / (Radius * SinDecRad1);
#local PreRect = max (min (PreRect, 1), -1);
#local Rect = asin (PreRect);
#local RectDeg = degrees (Rect);
#local RA = RectDeg - MA_Deg2Vector_RA_Offset;
#if (abs(RA) < E) #local RA = 0; #end
#while (RA < 0)
#local RA = RA + 180;
#end
#if (S_X <= 0 & S_Z >=0)
#local RA = 360 - RA;
#end
#if (S_X > 0 & S_Z >=0)
#local RA = RA + 180;
#end
#if (S_X <= 0 & S_Z <=0)
#local RA = 180 - RA;
#end
#if (S_X < 0 & S_Z =0)
#local RA = 180 + RA;
#end
#local Result = <RA, Dec, Radius>;
#end
Result
#end
// Example round-trip test
#for (RA, 0, 360, 10)
#for (Dec, -180, 180, 18)
#local V = <RA, Dec, 10>;
#debug concat("RA = ", str(V.x,0,3), ", Dec = ", str(V.y,0,3), ", R = ",
str(V.z,0,3), " -----> ")
#declare V1 = MA_Deg2Vector (V.x, V.y, V.z);
#debug concat("X = ", str(V1.x,0,8), ", Y = ", str(V1.y,0,8), ", Z = ",
str(V1.z,0,3), " -----> ")
#declare P1 = MA_Vector2Deg (V1); // P1 = <RA, Dec, R>
#debug concat("RA = ", str(P1.x,0,3), ", Dec = ", str(P1.y,0,3), ", R = ",
str(P1.z,0,3),"\n")
#end
#debug "\n"
#end
#error "No objects in scene"
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |