|
|
"Bald Eagle" <cre### [at] netscapenet> 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
|
|