  | 
  | 
 
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
I was experimenting with the mapping equations in:
https://archive.bridgesmathart.org/2018/bridges2018-59.pdf
and crashed POV-Ray (3.8) about 6 times.
I'm guessing it has to do with trying to take square roots of something divided
by 0, or 0/0.
I haven't had a chance to scribble out a minimal .pov script to see what
triggers it.
I also was not able to get the mapping to work correctly - I'm guessing that I'm
going to have to apply the _inverse_ of the mapping - but I'm out of practice,
and can't see an easy way to go about that.
Any suggestions?
- BW
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
On 14/10/2024 18:16, Bald Eagle wrote:
> I was experimenting with the mapping equations in:
> 
> https://archive.bridgesmathart.org/2018/bridges2018-59.pdf
Really interesting article...
> and crashed POV-Ray (3.8) about 6 times.
> 
> I'm guessing it has to do with trying to take square roots of something divided
> by 0, or 0/0.
> I haven't had a chance to scribble out a minimal .pov script to see what
> triggers it.
> 
> 
> 
> I also was not able to get the mapping to work correctly - I'm guessing that I'm
> going to have to apply the _inverse_ of the mapping - but I'm out of practice,
> and can't see an easy way to go about that.
> 
> Any suggestions?
I quickly did these two scenes.
I used the silly method that gives the images as attachments.
I don't know why you have crashes.
Here is some of my code :
-- begin code ---
#declare Sq = function(x) { x*x }
#declare fnDisc2Square = function(u,v) {
 
sgn(u*v)*sqrt(((-Sq(u)-Sq(v)+sqrt((Sq(u)+Sq(v))*(Sq(u)+Sq(v)+4*Sq(u)*Sq(v)*(Sq(u)+Sq(v)-2)))))/(2*(Sq(u)+Sq(v)-2)))
  }
#declare fnSquare2Disc = function(x,y) {
  sqrt((Sq(x)+Sq(y)-(2*Sq(x)*Sq(y)))/((Sq(x)+Sq(y))*(1-Sq(x)*Sq(y))))
  }
#macro Disc2Square(U,V)
  <fnDisc2Square(U,V)/V, fnDisc2Square(U,V)/U, -0.10>
#end
#macro Square2Disc(X,Y)
  <fnSquare2Disc(X,Y)*X, fnSquare2Disc(X,Y)*Y, -0.10>
#end
--- end code ---
Values between -1 and 1 go through zero, but I don't have any crashes.
I don't know if this will help you..
-- 
Kurtz le pirate
Compagnie de la banquise
 Post a reply to this message 
 
Attachments: 
Download 'square2disc.png' (411 KB)
Download 'disc2square.png' (440 KB)
 
  
Preview of image 'square2disc.png'
   
Preview of image 'disc2square.png'
   
   
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
kurtz le pirate <kur### [at] gmail com> wrote:
> I quickly did these two scenes.
> I used the silly method that gives the images as attachments.
> I don't know why you have crashes.
>
> Here is some of my code :
 ....
> Values between -1 and 1 go through zero, but I don't have any crashes.
> I don't know if this will help you..
Hey - you got it to work, which is more than I got.
When I next get a chance (it may be a while), I can compare your code to mine.
In the meantime:
Can you try a simple "scene" where you try to take the sqrt of 0, N/0, and 0/0?
Thanks
- BW
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
On 15/10/2024 16:10, Bald Eagle wrote:
> In the meantime:
> Can you try a simple "scene" where you try to take the sqrt of 0, N/0, and 0/0?
Sure :
#debug "Begin -------------\n"
#declare a = sqrt(0);
#debug concat("sqrt(0) = ",str(a,0,-1),"\n")
#declare b = sqrt(1/0);
#debug concat("sqrt(1/0) = ",str(b,0,-1),"\n")
#declare c = sqrt(0/0);
#debug concat("sqrt(0/0) = ",str(c,0,-1),"\n")
#debug "End-----------------\n"
#error "nothing to draw"
Output :
Begin -------------
sqrt(0) = 0.000000
sqrt(1/0) = inf
sqrt(0/0) = inf
End-----------------
Parse Warning: Divide by zero.
Parse Warning: Divide by zero.
-- 
Kurtz le pirate
Compagnie de la banquise
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
So here's how I got it to NOT crash, but my mapping results suck.
Remove all of the protective select () and mod () functions, and it will crash.
#version 3.8;
global_settings {assumed_gamma 1.0 }
#include "math.inc"
#declare Zoom = 300;
camera {
 orthographic
 location <0, 0, -50>
 right x*image_width/Zoom
 up y*image_height/Zoom
 look_at <0, 0, 0>
 rotate y*0
}
light_source {<10, 10, -20> rgb 1}
sky_sphere {pigment {rgb 1}}
#declare Image = pigment {image_map {"HyperbolicSoccerBall.jpg"} translate-0.5}
#declare f_Image = function {pigment {Image}}
#declare d2s = function (M, N, U, V) {
 select (M,
  select (2*(U*U + V*V - 2),
   sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
*(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M,
   M,
   sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
*(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M
  ),
  M,
  select (2*(U*U + V*V - 2),
   sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
*(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M,
   M,
   sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
*(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M
  )
 )
}
#local FF = 0.0000001;
#declare s2d = function (M, N, X, Y) {
 select (mod (M+FF, 1),
  sqrt ((X*X + Y*Y - 2*X*X*Y*Y)/((X*X + Y*Y)*(1 - X*X*Y*Y))),
  M,
  sqrt ((X*X + Y*Y - 2*X*X*Y*Y)/((X*X + Y*Y)*(1 - X*X*Y*Y)))
 )
}
box {0, 1 translate -0.5 pigment {Image} translate -x}
//box {0, 1 translate -0.5 pigment {function {f_Image (d2s (x, y, x, y), d2s (y,
x, x, y), z).red}} }
//box {0, 1 translate -0.5 pigment {function {f_Image (s2d (x, y, x, y), s2d (y,
x, x, y), z).red}} translate x}
#declare Step = 0.01;
union {
 #for (Y, 0, 1, Step)
  #for (X, 0, 1, Step)
   #declare C = f_Image (X, Y, 0).red;
   #declare X2 = d2s (X, Y, X, Y)*Step;
   #declare Y2 = d2s (Y, X, X, Y)*Step;
   box {<X2, Y2, 0>, <X2+Step, Y2+Step, 1> pigment {rgb C}}
  #end
 #end
}
#local FF = 0.0000001;
#for (N, 0, 1, 0.1)
 #debug concat ("mod (", str(N, 0, 1),  ", 1) = ", str(mod (N+FF, 1), 0, 3),
"\n")
#end
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
"Bald Eagle" <cre### [at] netscape net> wrote:
> ... 0, N/0, and 0/0?
<https://www.quantamagazine.org/how-the-human-brain-contends-with-the-strangeness-of-zero-20241018/>
</grin>
regards, jr.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
"Bald Eagle" <cre### [at] netscape net> wrote:
> So here's how I got it to NOT crash, but my mapping results suck.
>
> Remove all of the protective select () and mod () functions, and it will crash.
>
Here's what you can do to make it work:
(Note that I might change my mind later about what values should
be used when the first expressions in the select statements
evaluates to zero. I may do some more testing in Python to be sure.)
> #version 3.8;
Replace with:
#version 3.7;  // I have not tested with v3.8
> #declare Zoom = 300;
Replace with:
#declare Zoom = 100;  // To see all the results
> #declare Image = pigment {image_map {"HyperbolicSoccerBall.jpg"} translate-0.5}
Replace with:
#declare Image =
    pigment {
        image_map { "HyperbolicSoccerBall.jpg" }
        scale <2, 2, 1>
        translate -<1, 1, 0>
    }
/*
To move the image from the region from x = 0 and y = 0 to
x = +1 and y = +1 into the region from x = -1 and y = -1 to
x = +1 and y = +1, as these are the intervals that the functions
below are made for.
*/
> #declare d2s = function (M, N, U, V) {
>  select (M,
>   select (2*(U*U + V*V - 2),
>    sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
> *(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M,
>    M,
>    sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
> *(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M
>   ),
>   M,
>   select (2*(U*U + V*V - 2),
>    sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
> *(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M,
>    M,
>    sgn (M) * sqrt (abs (-U*U -V*V + sqrt ((U*U + V*V)+(U*U + V*V + 4*U*U*V*V
> *(U*U+V*V-2)) )  / (2*(U*U + V*V - 2))) ) / M
>   )
>  )
> }
Replace with:
#declare d2s =
    function(U, V) {
        select(
            V,
            select(
                U*U + V*V - 2,
                sgn(U*V)*
                sqrt(
                    (
                        -U*U -V*V +
                        sqrt(
                            (U*U + V*V)*
                            (U*U + V*V + 4*U*U*V*V*(U*U + V*V - 2))
                        )
                    )/(2*(U*U + V*V - 2))
                )/V,
                U,
                sgn(U*V)*
                sqrt(
                    (
                        -U*U -V*V +
                        sqrt(
                            (U*U + V*V)*
                            (U*U + V*V + 4*U*U*V*V*(U*U + V*V - 2))
                        )
                    )/(2*(U*U + V*V - 2))
                )/V
            ),
            U,
            select(
                U*U + V*V - 2,
                sgn(U*V)*
                sqrt(
                    (
                        -U*U -V*V +
                        sqrt(
                            (U*U + V*V)*
                            (U*U + V*V + 4*U*U*V*V*(U*U + V*V - 2))
                        )
                    )/(2*(U*U + V*V - 2))
                )/V,
                U,
                sgn(U*V)*
                sqrt(
                    (
                        -U*U -V*V +
                        sqrt(
                            (U*U + V*V)*
                            (U*U + V*V + 4*U*U*V*V*(U*U + V*V - 2))
                        )
                    )/(2*(U*U + V*V - 2))
                )/V
            )
        )
    }
;
/*
Note that the plus symbols between the parentheses in the inner square roots
in your expressions are wrong; they should be multiplication symbols.
Also abs() should not be needed.
*/
> #declare s2d = function (M, N, X, Y) {
>  select (mod (M+FF, 1),
>   sqrt ((X*X + Y*Y - 2*X*X*Y*Y)/((X*X + Y*Y)*(1 - X*X*Y*Y))),
>   M,
>   sqrt ((X*X + Y*Y - 2*X*X*Y*Y)/((X*X + Y*Y)*(1 - X*X*Y*Y)))
>  )
> }
Replace with:
#declare s2d =
    function(X, Y) {
        select(
            X*X + Y*Y,
            select(
                1 - X*X*Y*Y,
                sqrt(
                    (X*X + Y*Y - 2*X*X*Y*Y)/
                     ((X*X + Y*Y)*(1 - X*X*Y*Y))
                )*X,
                sqrt(0.5)*X,
                sqrt(
                    (X*X + Y*Y - 2*X*X*Y*Y)/
                     ((X*X + Y*Y)*(1 - X*X*Y*Y))
                )*X
            )*X,
            0,
            select(
                1 - X*X*Y*Y,
                sqrt(
                    (X*X + Y*Y - 2*X*X*Y*Y)/
                     ((X*X + Y*Y)*(1 - X*X*Y*Y))
                )*X,
                sqrt(0.5)*X,
                sqrt(
                    (X*X + Y*Y - 2*X*X*Y*Y)/
                     ((X*X + Y*Y)*(1 - X*X*Y*Y))
                )*X
            )
        )
    }
;
> box {0, 1 translate -0.5 pigment {Image} translate -x}
Replace with:
box {
    -<1, 1, 0>, +<1, 1, 1>
    pigment { Image }
    translate +1.0*y
}
> //box {0, 1 translate -0.5 pigment {function {f_Image (s2d (x, y, x, y), s2d (y,
> x, x, y), z).red}} translate x}
Replace with:
box {
    -<1, 1, 0>,
    +<1, 1, 1>
    pigment {
        function {
            f_Image(
                s2d(x, y),
                s2d(y, x),
                0
            ).gray
        }
    }
    translate -2.5*x -1.0*y
}
> union {
>  #for (Y, 0, 1, Step)
>   #for (X, 0, 1, Step)
>    #declare C = f_Image (X, Y, 0).red;
>    #declare X2 = d2s (X, Y, X, Y)*Step;
>    #declare Y2 = d2s (Y, X, X, Y)*Step;
>    box {<X2, Y2, 0>, <X2+Step, Y2+Step, 1> pigment {rgb C}}
>   #end
>  #end
> }
Replace with:
union {
    #for (Y, -1, +1, Step)
        #for (X, -1, +1, Step)
            #declare C = f_Image(X, Y, 0).gray;
            #declare X2 = d2s(X, Y);
            #declare Y2 = d2s(Y, X);
            box {
                <X2, Y2, 0>, <X2 + Step, Y2 + Step, 1>
                pigment { color rgb C*<1, 1, 1> }
            }
        #end // for
    #end // for
    translate +2.5*x -1.0*y
}
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmail com> wrote:
> "Bald Eagle" <cre### [at] netscape net> wrote:
> > So here's how I got it to NOT crash, but my mapping results suck.
> >
> > Remove all of the protective select () and mod () functions, and it will crash.
> >
>
> Here's what you can do to make it work:
>...
Sorry, I made a little mistake in the code below:
>...
> #declare s2d =
>     function(X, Y) {
>         select(
>             X*X + Y*Y,
>             select(
>                 1 - X*X*Y*Y,
>                 sqrt(
>                     (X*X + Y*Y - 2*X*X*Y*Y)/
>                      ((X*X + Y*Y)*(1 - X*X*Y*Y))
>                 )*X,
>                 sqrt(0.5)*X,
>                 sqrt(
>                     (X*X + Y*Y - 2*X*X*Y*Y)/
>                      ((X*X + Y*Y)*(1 - X*X*Y*Y))
>                 )*X
>             )*X,
Remove the last *X above
>             0,
>             select(
>                 1 - X*X*Y*Y,
>                 sqrt(
>                     (X*X + Y*Y - 2*X*X*Y*Y)/
>                      ((X*X + Y*Y)*(1 - X*X*Y*Y))
>                 )*X,
>                 sqrt(0.5)*X,
>                 sqrt(
>                     (X*X + Y*Y - 2*X*X*Y*Y)/
>                      ((X*X + Y*Y)*(1 - X*X*Y*Y))
>                 )*X
>             )
>         )
>     }
> ;
>...
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 
 | 
  |