POV-Ray : Newsgroups : povray.general : 3D Math (Reply to Spider) Server Time
5 Nov 2024 03:16:21 EST (-0500)
  3D Math (Reply to Spider) (Message 1 to 9 of 9)  
From: Stephen Lavedas
Subject: 3D Math (Reply to Spider)
Date: 15 Dec 1998 01:22:05
Message: <3676016C.47DB0D4E@virginia.edu>
I tweaked your code a bit... First thing I did was actually translate
the spheres (which I made larger at a radius of 0.25.  Then I changed
your random functions to rand(s)*(Radius * 2) - Radius so that the
values could be positive or negative.  Now, I expected I would be
treated to a roughly spherical shape made up of spheres.  Wrong.  I got
a roughly cubical shape made up of spheres.  This is baffling me,
because your test should eliminate the corners (The corners would occur
when all of vd's vector components were 11s (positive and negative) but
that should end up having a distance greater than 11.  I guess you could
revert to the trig.  (triangles and all...but damned if the distance
formula shouldn't have worked...)  

Steve
(I'll be messing with this, email me if you like and we'll figure this
sucker out)


Post a reply to this message

From: Stephen Lavedas
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 01:35:05
Message: <36760478.25A7DA72@virginia.edu>
GOT IT!  (You needed an Or instead of an AND for the test...)  As part
of my testing, I replaced vlength with the distance formula, for
simplicity, I would suggest returning it to normal.  Also, to see the
spheres better, I changed the finish.  Hope this helps

Steve


#declare Radius = 11;
#declare N = 2500;
#declare C = <0,8,0>;
#declare s = seed(pi);
#while (N>0)
   sphere {   
    C
    0.25
    pigment { rgb <1,1,1>} finish { ambient 0.2 diffuse 0.6 }
    #local vd=<rand(s)*(Radius * 2) - Radius,rand(s)*(Radius * 2) -
Radius,rand(s)*(Radius * 2) - Radius>;
    #local vld = sqrt(vd.x*vd.x + vd.y*vd.y + vd.z*vd.z);     
    #while((vld>Radius) | (vld<-Radius))
      #local vd=<rand(s)*(Radius * 2) - Radius,rand(s)*(Radius * 2) -
Radius,rand(s)*(Radius * 2) - Radius>;
      #local vld = sqrt(vd.x*vd.x + vd.y*vd.y + vd.z*vd.z); 
    #end                        
    translate vd
  }
  #declare N=N-1;
#end

Stephen Lavedas wrote:
> 
> I tweaked your code a bit... First thing I did was actually translate
> the spheres (which I made larger at a radius of 0.25.  Then I changed
> your random functions to rand(s)*(Radius * 2) - Radius so that the
> values could be positive or negative.  Now, I expected I would be
> treated to a roughly spherical shape made up of spheres.  Wrong.  I got
> a roughly cubical shape made up of spheres.  This is baffling me,
> because your test should eliminate the corners (The corners would occur
> when all of vd's vector components were 11s (positive and negative) but
> that should end up having a distance greater than 11.  I guess you could
> revert to the trig.  (triangles and all...but damned if the distance
> formula shouldn't have worked...)
> 
> Steve
> (I'll be messing with this, email me if you like and we'll figure this
> sucker out)


Post a reply to this message

From: Spider
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 11:33:36
Message: <36768EAE.76B544C9@bahnhof.se>
Thanx...


> 
> I tweaked your code a bit... First thing I did was actually translate
> the spheres (which I made larger at a radius of 0.25.  Then I changed
> your random functions to rand(s)*(Radius * 2) - Radius so that the
> values could be positive or negative.  
This was in my own code, but I added it after posting... *smile* Thanx.

>Now, I expected I would be
> treated to a roughly spherical shape made up of spheres.  Wrong.  I got
> a roughly cubical shape made up of spheres.  
You too.... It really is baffeling...

>This is baffling me,
> because your test should eliminate the corners (The corners would occur
> when all of vd's vector components were 11s (positive and negative) but
> that should end up having a distance greater than 11.  I guess you could
> revert to the trig.  (triangles and all...but damned if the distance
> formula shouldn't have worked...)
I think it should, and it is mentioned in the manual as to work... (Yeah, I ripped
it...)
I could return to trig, but I'm not that good at the math...


> 
> Steve
> (I'll be messing with this, email me if you like and we'll figure this
> sucker out)

I'll keep looking at it...

//Spider


Post a reply to this message

From: Spider
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 11:34:47
Message: <36768EF7.4457459D@bahnhof.se>
Yeee... Thanx  (Booting up POV)!
It sure helps.... 

//Spider

Stephen Lavedas wrote:
> 
> GOT IT!  (You needed an Or instead of an AND for the test...)  As part
> of my testing, I replaced vlength with the distance formula, for
> simplicity, I would suggest returning it to normal.  Also, to see the
> spheres better, I changed the finish.  Hope this helps


> 
> Steve
> 
> #declare Radius = 11;
> #declare N = 2500;
> #declare C = <0,8,0>;
> #declare s = seed(pi);
> #while (N>0)
>    sphere {
>     C
>     0.25
>     pigment { rgb <1,1,1>} finish { ambient 0.2 diffuse 0.6 }
>     #local vd=<rand(s)*(Radius * 2) - Radius,rand(s)*(Radius * 2) -
> Radius,rand(s)*(Radius * 2) - Radius>;
>     #local vld = sqrt(vd.x*vd.x + vd.y*vd.y + vd.z*vd.z);
>     #while((vld>Radius) | (vld<-Radius))
>       #local vd=<rand(s)*(Radius * 2) - Radius,rand(s)*(Radius * 2) -
> Radius,rand(s)*(Radius * 2) - Radius>;
>       #local vld = sqrt(vd.x*vd.x + vd.y*vd.y + vd.z*vd.z);
>     #end
>     translate vd
>   }
>   #declare N=N-1;
> #end
> 
> Stephen Lavedas wrote:
> >
> > I tweaked your code a bit... First thing I did was actually translate
> > the spheres (which I made larger at a radius of 0.25.  Then I changed
> > your random functions to rand(s)*(Radius * 2) - Radius so that the
> > values could be positive or negative.  Now, I expected I would be
> > treated to a roughly spherical shape made up of spheres.  Wrong.  I got
> > a roughly cubical shape made up of spheres.  This is baffling me,
> > because your test should eliminate the corners (The corners would occur
> > when all of vd's vector components were 11s (positive and negative) but
> > that should end up having a distance greater than 11.  I guess you could
> > revert to the trig.  (triangles and all...but damned if the distance
> > formula shouldn't have worked...)
> >
> > Steve
> > (I'll be messing with this, email me if you like and we'll figure this
> > sucker out)


Post a reply to this message

From: Abe
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 13:05:40
Message: <3676A52D.8F5B6F13@atmos.albany.edu>
Pardon me for being intrusive . . . but I wanted to share an alternate
solution to this problem which occured to me. It is a bit cheaper in parsing
time (though not much) and loop cycles.


#declare Radius = 11;
#declare N = 2500;
#declare C = <0,8,0>;
#declare s = seed(pi);
#while (N>0)
  sphere {
    <0, 0, 0>
    0.25
    pigment { rgb <1,1,1>} finish { ambient 0.2 diffuse 0.6 }
    #local D =  pow(rand(s), 1/3)*Radius;        // cube root accounts for
increase in rad. wrt vol. Changing this can change the radial distr. of
spheres.
    #local R = < rand(s)*360, rand(s)*360, rand(s)*360,>;
    translate x*D
    rotate 45
    rotate R
    translate C
   }
   #declare N=N-1;
 #end

. . . for what it's worth. :-)

Abe


Post a reply to this message

From: Spider
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 13:55:06
Message: <3676AFD9.3AEDCA9C@bahnhof.se>
Thanx, I'll test it... And, it comes in under the original topic :-)
THe question was "how" and then my guess that didn't work :-)



//Spider

Abe wrote:
> 
> Pardon me for being intrusive . . . but I wanted to share an alternate
> solution to this problem which occured to me. It is a bit cheaper in parsing
> time (though not much) and loop cycles.
> 
> #declare Radius = 11;
> #declare N = 2500;
> #declare C = <0,8,0>;
> #declare s = seed(pi);
> #while (N>0)
>   sphere {
>     <0, 0, 0>
>     0.25
>     pigment { rgb <1,1,1>} finish { ambient 0.2 diffuse 0.6 }
>     #local D =  pow(rand(s), 1/3)*Radius;        // cube root accounts for
> increase in rad. wrt vol. Changing this can change the radial distr. of
> spheres.
>     #local R = < rand(s)*360, rand(s)*360, rand(s)*360,>;
>     translate x*D
>     rotate 45
>     rotate R
>     translate C
>    }
>    #declare N=N-1;
>  #end
> 
> . . . for what it's worth. :-)
> 
> Abe


Post a reply to this message

From: Stephen Lavedas
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 17:27:19
Message: <3676E392.7BF3E941@virginia.edu>
I like this method a lot better.  It allows for easier adaptation into
spirals, tori and cylinders.  (While I was modifying your code Spider, I
was thinking.. this would be easier in a polar or spherical system)  I
will be playing some games with this now... Thanks Abe.

Steve


Abe wrote:
> 
> Pardon me for being intrusive . . . but I wanted to share an alternate
> solution to this problem which occured to me. It is a bit cheaper in parsing
> time (though not much) and loop cycles.
> 
> #declare Radius = 11;
> #declare N = 2500;
> #declare C = <0,8,0>;
> #declare s = seed(pi);
> #while (N>0)
>   sphere {
>     <0, 0, 0>
>     0.25
>     pigment { rgb <1,1,1>} finish { ambient 0.2 diffuse 0.6 }
>     #local D =  pow(rand(s), 1/3)*Radius;        // cube root accounts for
> increase in rad. wrt vol. Changing this can change the radial distr. of
> spheres.
>     #local R = < rand(s)*360, rand(s)*360, rand(s)*360,>;
>     translate x*D
>     rotate 45
>     rotate R
>     translate C
>    }
>    #declare N=N-1;
>  #end
> 
> . . . for what it's worth. :-)
> 
> Abe


Post a reply to this message

From: Stephen Lavedas
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 18:04:55
Message: <3676EC63.51882DC9@virginia.edu>
If there is any interest, I've written a couple of modifications to
allow for Tori and Spirals... Email me and I'll send them out unless
everyone wants them, then I'll post them (They are both roughly this
length, so I'm wondering if posting them here as text would be rude).
I guess I could post them in Scene files, but I don't normally check
that area.  Let me know.  

Steve


Abe wrote:
> 
> Pardon me for being intrusive . . . but I wanted to share an alternate
> solution to this problem which occured to me. It is a bit cheaper in parsing
> time (though not much) and loop cycles.
> 
> #declare Radius = 11;
> #declare N = 2500;
> #declare C = <0,8,0>;
> #declare s = seed(pi);
> #while (N>0)
>   sphere {
>     <0, 0, 0>
>     0.25
>     pigment { rgb <1,1,1>} finish { ambient 0.2 diffuse 0.6 }
>     #local D =  pow(rand(s), 1/3)*Radius;        // cube root accounts for
> increase in rad. wrt vol. Changing this can change the radial distr. of
> spheres.
>     #local R = < rand(s)*360, rand(s)*360, rand(s)*360,>;
>     translate x*D
>     rotate 45
>     rotate R
>     translate C
>    }
>    #declare N=N-1;
>  #end
> 
> . . . for what it's worth. :-)
> 
> Abe


Post a reply to this message

From: Spider
Subject: Re: 3D Math (Reply to Spider)
Date: 15 Dec 1998 19:36:39
Message: <3676FFE6.CF56D6B1@bahnhof.se>
I'm always interested.... 
Anything I can learn from is good. :-)

//Spider
Stephen Lavedas wrote:
> 
> If there is any interest, I've written a couple of modifications to
> allow for Tori and Spirals... Email me and I'll send them out unless
> everyone wants them, then I'll post them (They are both roughly this
> length, so I'm wondering if posting them here as text would be rude).
> I guess I could post them in Scene files, but I don't normally check
> that area.  Let me know.
> 
> Steve
>


Post a reply to this message

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