|
|
Severi Salminen wrote:
> Thanks, but I'm actually interested in general solution without
> resorting to functions provided by PovRay. As it is probably OT here,
> I'll post the question to OT.
The code below is based on John's solution (but with some
simplifications). Most of the functions special to POV-Ray
has been replaced by common functions.
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#version 3.6;
#declare vN = <2, 1, 3>;
#declare SS = seed(6457);
#declare Cnt = 20;
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare vY =
vN/sqrt(vN.x*vN.x + vN.y*vN.y + vN.z*vN.z);
#declare vX =
<vY.z, 0, -vY.x>/sqrt(vY.x*vY.x + vY.z*vY.z);
#declare vZ =
<vX.y*vY.z - vX.z*vY.y, vX.z*vY.x - vX.x*vY.z, vX.x*vY.y - vX.y*vY.x>;
cylinder { 0*y, vX, 0.03 pigment { color rgb <2, 1, 1> } }
cylinder { 0*y, vY, 0.03 pigment { color rgb <1, 2, 1> } }
cylinder { 0*y, vZ, 0.03 pigment { color rgb <1, 1, 2> } }
#declare I = 0;
#while (I < Cnt)
#declare sN = rand(SS);
#declare sL = sqrt(1 - sN*sN);
#declare Angle = -2*pi*rand(SS);
#declare vResult = sN*vY + sL*(cos(Angle)*vX + sin(Angle)*vZ);
cylinder { 0*y, vResult, 0.01 pigment { color rgb <1, 1, 1> } }
#declare I = I + 1;
#end // while
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
background { color rgb <0.0, 0.0, 0.5> }
light_source { <1, 1, 1>*100 color rgb <1, 1, 1> }
camera {
location <3, 1, 2>
look_at <0, 0, 0>
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|