POV-Ray : Newsgroups : povray.newusers : Losing my mind Server Time
28 Apr 2024 22:15:42 EDT (-0400)
  Losing my mind (Message 1 to 5 of 5)  
From: Bald Eagle
Subject: Losing my mind
Date: 1 Apr 2014 23:10:59
Message: <533b7fc3$1@news.povray.org>
Ok, I've been trying to reproduce the stereographic image on:

http://xahlee.info/3d/illus_geometry.html

I got my sphere made up of a grid formed by rings originating at the 
"north pole" of the sphere, and radiating outwards from there in 2 fans, 
one rotating along the z-axis, and one along the x-axis.
Got my light source near the North pole.
Got my transparent square to fill a space in the grid.

I cannot for the life of me figure out why my cylinders do not line up 
with the intersection points on the grid.  The farther they're rotated, 
the more they are off.  I've checked, and double checked, and quintuple 
checked, and only rendered parts of the scene, and even switched to an 
orthographic camera to eliminate any visual confusion arising from 
perspective / optical illusions.

Maybe I'm old, maybe I'm tired, maybe I'm just geometrically incapable.
I dunno.
It seems to me that if I take a box that's centered on the origin, 
rotate it, and translate it by y* the radius of the sphere, and then 
take a cylinder that originates at the origin and extends downwards, and 
perform the same operations, that they should be aligned.
But they are not.  And I can't figure out why.  :(

SDL:
-----------------------------------------------------------------------

#declare Size = 100;
#declare Height = 100;
#declare Spacing = 300;
#declare Axis = 2;

light_source { < 0, Height + 95, -150>, rgb <1,1,1>}

#declare Axes = union {
cylinder {<0, 0, 0>, <Size, 0, 0>,  Axis texture {pigment {color Red} 
  finish {ambient 0.5} } }
cylinder {<0, 0, 0>, <0, Size, 0>,  Axis texture {pigment {color Green} 
  finish {ambient 0.5} } }
cylinder {<0, 0, 0>, <0, 0, -Size>, Axis texture {pigment {color Yellow} 
finish {ambient 0.5} } }
}

camera { orthographic location <0, Height, -500> look_at <0, Height/2, 
-50> }

//####################################################################################

#declare WIP = union { //object {Axes}

#declare Radius = 100;
#declare Thickness = 1;
#declare Step = 5;
sphere {<0,0,0>, 100 pigment {rgbf <1, 1, 0, 0.9>} }
/*
// "x axis" grid
#declare Loop = -18;
#while (Loop <= 18 )
	intersection {
		difference {
			sphere {<0,0,0>, Radius }
				sphere {<0,0,0>, Radius-Thickness }
				}
		box { <-Thickness/2, -300, -200>, <Thickness/2, 0, 200> rotate 
z*Loop*Step translate y*Radius }
		pigment {rgbf <0, 0, 1, 1>}
		}
	#declare Loop = Loop + 1;
#end

// "z axis" grid
#declare Loop = -18;
#while (Loop <= 18 )
	intersection {
		difference {
			sphere {<0,0,0>, Radius }
				sphere {<0,0,0>, Radius-Thickness }
				}
		box { <-200, -300, -Thickness/2>, <200, 0, Thickness/2> rotate 
x*Loop*Step translate y*Radius }
		pigment {rgbf <1, 0, 0, 1>}
		}
	#declare Loop = Loop + 1;
#end
*/

// Lines and transparent square
#declare Color1 = rgb <0, 1, 0>;
#declare Corner1 = 0;  // z
#declare Corner2 = 15;  // x  (+ = toward camera, - = away)

// boxes for comparison
union {
	box { <-Thickness/2, -Radius*3, -Radius>, <Thickness/2, Radius*3, 
Radius> rotate z* Corner1   *Step translate y*Radius }
	box { <-Thickness/2, -Radius*3, -Radius>, <Thickness/2, Radius*3, 
Radius> rotate z*(Corner1+1)*Step translate y*Radius }
	
	//box { <-Radius*2, -Radius*3, -Thickness/2>, <Radius*2, Radius*3, 
Thickness/2> rotate x* Corner2   *Step translate y*Radius }
	//box { <-Radius*2, -Radius*3, -Thickness/2>, <Radius*2, Radius*3, 
Thickness/2> rotate x*(Corner2+1)*Step translate y*Radius }
	pigment {rgbf <0.9, 0.9, 0.9, 1>}
	}

cylinder { <0, 0, 0>, <0, -Radius*2, 0>, Thickness/2 rotate z* 
Corner1*Step    rotate x* Corner2   *Step translate y*Radius texture 
{pigment {Color1} finish {ambient 0.7} } no_shadow}
cylinder { <0, 0, 0>, <0, -Radius*2, 0>, Thickness/2 rotate 
z*(Corner1+1)*Step rotate x* Corner2   *Step translate y*Radius texture 
{pigment {Color1} finish {ambient 0.7} } no_shadow}
cylinder { <0, 0, 0>, <0, -Radius*2, 0>, Thickness/2 rotate z* 
Corner1*Step    rotate x*(Corner2+1)*Step translate y*Radius texture 
{pigment {Color1} finish {ambient 0.7} } no_shadow}
cylinder { <0, 0, 0>, <0, -Radius*2, 0>, Thickness/2 rotate 
z*(Corner1+1)*Step rotate x*(Corner2+1)*Step translate y*Radius texture 
{pigment {Color1} finish {ambient 0.7} } no_shadow}

difference {
	sphere {<0,0,0>, Radius }
		sphere {<0,0,0>, Radius-Thickness }	
		box { <-Radius*2, -Radius*3, -Radius*2>, <-Thickness/2, Radius*3, 
Radius*2> rotate z* Corner1   *Step translate y*Radius }
		box { < Radius*2, -Radius*3, -Radius*2>, < Thickness/2, Radius*3, 
Radius*2> rotate z*(Corner1+1)*Step translate y*Radius }
		
		box { <-Radius*2, -Radius*3,  Radius*2>, <Radius*2, Radius*3, 
Thickness/2> rotate x* Corner2   *Step translate y*Radius }
		box { <-Radius*2, -Radius*3, -Radius*2>, <Radius*2, Radius*3, 
-Thickness/2> rotate x*(Corner2+1)*Step translate y*Radius }
		pigment {Color1 filter 1}
	}	

} // end WIP


//####################################################################################
	
// Plot objects
object {WIP translate <0, Height, -150> }


Post a reply to this message

From: Samuel Benge
Subject: Re: Losing my mind
Date: 2 Apr 2014 18:15:00
Message: <web.533c8b06f07ab8a2f040ad170@news.povray.org>
Bald Eagle <cre### [at] netscapenet> wrote:
> Ok, I've been trying to reproduce the stereographic image on:
>
> http://xahlee.info/3d/illus_geometry.html
>
> I got my sphere made up of a grid formed by rings originating at the
> "north pole" of the sphere, and radiating outwards from there in 2 fans,
> one rotating along the z-axis, and one along the x-axis.
> Got my light source near the North pole.
> Got my transparent square to fill a space in the grid.
>
> I cannot for the life of me figure out why my cylinders do not line up
> with the intersection points on the grid.  The farther they're rotated,
> the more they are off.  I've checked, and double checked, and quintuple
> checked, and only rendered parts of the scene, and even switched to an
> orthographic camera to eliminate any visual confusion arising from
> perspective / optical illusions.
>
> Maybe I'm old, maybe I'm tired, maybe I'm just geometrically incapable.
> I dunno.
> It seems to me that if I take a box that's centered on the origin,
> rotate it, and translate it by y* the radius of the sphere, and then
> take a cylinder that originates at the origin and extends downwards, and
> perform the same operations, that they should be aligned.
> But they are not.  And I can't figure out why.  :(

No need to lose your mind :)

I didn't try to debug your code, but I do have an alternate solution: use
trace() to project the plane's grid points onto the globe.

// ------- code -------

plane{y, 0 pigment{rgb .5}}

#declare SP = <0, 7, 0>; // sphere position
#declare SS = 4; // sphere size
#declare NP = SP + y*SS; // north pole

#declare TO = sphere{SP, SS}; // globe for rendering and trace()ing

object{TO pigment{rgb .5}}
sphere{NP, .2 pigment{rgb <1, 1, .1>}}

union{
 #local GS = 20;
 #for(Z, 0, GS-1)
  #for(X, 0, GS-1)

   #declare GP = <X, 0, Z>; // grid point
   #declare GP = GP - (x+z)*(GS-1)/2; // center the grid
   #declare TP = trace(TO, GP, NP-GP); // trace point

   sphere{GP, .2} // grid spheres on the plane
   sphere{TP, .1} // grid spheres on the globe

  #end
 #end
 pigment{rgb <1, 1, .1>}
}

// ------- ~code -------

Hopefully that example is basic enough to make a good starting point, should you
go that route.

Sam


Post a reply to this message

From: Samuel Benge
Subject: Re: Losing my mind
Date: 2 Apr 2014 18:25:00
Message: <web.533c8d37f07ab8a2f040ad170@news.povray.org>
// this code is better (the last version had size/alignment issues)

plane{y, 0 pigment{rgb .5}}

#declare SP = <0, 7, 0>; // sphere position
#declare SS = 4; // sphere size
#declare NP = SP + y*SS; // north pole

#declare TO = sphere{SP, SS}; // globe for rendering and trace()ing

object{TO pigment{rgb .5}}
sphere{NP, .2 pigment{rgb <1, 1, .1>}}

union{
 #local GS = 20;
 #for(Z, 0, GS)
  #for(X, 0, GS)

   #declare GP = <X, 0, Z>; // grid point
   #declare GP = GP - (x+z)*GS/2; // center the grid
   #declare TP = trace(TO, GP, NP-GP); // trace point

   sphere{GP, .2} // grid spheres on the plane
   sphere{TP, .1} // grid spheres on the globe

  #end
 #end
 pigment{rgb <1, 1, .1>}
}


Post a reply to this message

From: Bald Eagle
Subject: Re: Losing my mind
Date: 2 Apr 2014 19:01:08
Message: <533c96b4$1@news.povray.org>
Thanks Sam,

Yes, I actually had thought to use Trace() to do what you're suggesting, 
but  I was concerned that if I "cheated" and did that, I wouldn't 
understand what I wasn't getting right with the simple task of aligning 
CSG primitives.
And I'd like to eventually know what my major malfunction is before I 
forge ahead and repeatedly run into the same problem again.

I will however give your trace codes a look, as I'm interested in doing 
other projects where that would be a prime way to radiate out through a 
grid intersection.


Post a reply to this message

From: Samuel Benge
Subject: Re: Losing my mind
Date: 3 Apr 2014 12:50:01
Message: <web.533d90bdf07ab8a2c03071cc0@news.povray.org>
Bald Eagle <cre### [at] netscapenet> wrote:
> Thanks Sam,
>
> Yes, I actually had thought to use Trace() to do what you're suggesting,
> but  I was concerned that if I "cheated" and did that, I wouldn't
> understand what I wasn't getting right with the simple task of aligning
> CSG primitives.
> And I'd like to eventually know what my major malfunction is before I
> forge ahead and repeatedly run into the same problem again.
>
> I will however give your trace codes a look, as I'm interested in doing
> other projects where that would be a prime way to radiate out through a
> grid intersection.

In your first post you said that you rendered only parts of the scene. How far
did you take that?

Try this: make a new scene and rewrite your projection/transformation code.
Leave out the #while loops, extraneous geometry, commented code, etc., and focus
on projecting just /one/ single point, testing it for accuracy. Strip it all
down to the barest minimum and work from there.

If you're still having problems even after that, then post that new
stripped-down version here and I will try to help you. It's much easier for us
to help out when the code is as simple as possible :)

Sam


Post a reply to this message

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