|
![](/i/fill.gif) |
>
> On Sat, 05 Jan 2002 04:33:15 +0100, Tor Olav Kristensen <tor### [at] hotmail com>
> wrote:
>
> > I thought that maybe
> > the source code below could be of interest
> > for you.
>
> What do you think about below ?
> I separated rounded endcaps into another function.
>
> #macro f_sphere_sweep_linear_segment(A,B,R)
> #local D=(B-A)+0*x;
> #local T=transform{
> translate -A
> Reorient_Trans(vnormalize(D),y)
> scale <1,1/vlength(D),1>
> }
> #local O=-vtransform(0*x,T);
> #local Ox=O.x;
> #local Oy=O.y+.5;
> #local Oz=O.z;
> #local V=vtransform(x,T)+O;
> #local Xx=V.x;
> #local Xy=V.y;
> #local Xz=V.z;
> #local V=vtransform(y,T)+O;
> #local Yx=V.x;
> #local Yy=V.y;
> #local Yz=V.z;
> #local V=vtransform(z,T)+O;
> #local Zx=V.x;
> #local Zy=V.y;
> #local Zz=V.z;
> function{
> "test.txt"
> (abs(
> #if(Xy!=0) +Xy*x #end
> #if(Yy!=0) +Yy*y #end
> #if(Zy!=0) +Zy*z #end
> #if(Oy!=0) -Oy #end
> )-.5)
> |
> f_sphere(
> #if(Xx!=0) +Xx*x #end
> #if(Yx!=0) +Yx*y #end
> #if(Zx!=0) +Zx*z #end
> #if(Ox!=0) -Ox #end
> ,0,
> #if(Xz!=0) +Xz*x #end
> #if(Yz!=0) +Yz*y #end
> #if(Zz!=0) +Zz*z #end
> #if(Oz!=0) -Oz #end
> ,
> R
> )
> }
> #end
It looks good.
Are all the ifs for speeding up the rendering in cases
where the line segments lies in planes parallel to either
the x, y, or z-planes ?
I'm not sure if I understand why you have decided to make
all the spheres for the joints in separate functions.
Is it because you are assembling it all "later on" with
the & operator ?
If you fetch my TransformFunction() macro from this thread:
"How to transform and blob together iso-shapes in v3.5"
(1. Oct. 2001 to povray.general)
http://news.povray.org/povray.general/18830/
news://news.povray.org/3BB8D35B.BB527254%40hotmail.com
and my ReorientMatrix() macro from this thread:
"Re: Rotations..." (7. Aug. 2001 to povray.general):
http://news.povray.org/povray.general/16859/108164/
news://news.povray.org/3B700B1D.3DF5ED5F%40hotmail.com
- then the code below will render a line segment with
rounded end caps (slightly faster than the code above).
#macro LineSegmentFunction(pA, pB, R)
#local vD = pB - pA;
#local lD = vlength(vD);
TransformFunction(
function {
f_sphere(
x,
select(y, y, select(y - lD, 0, y - lD)),
z,
R
)
},
transform {
ReorientMatrix(y, vD)
translate pA
}
)
#end // macro LineSegmentFunction
If there is anyone that wants an example that shows how
to use this code, then try this. (Just Remember to include
the functions.inc file to get access to the internal
f_sphere() function.)
#declare p0 = <-1, 0, -2>;
#declare p1 = <1, 1, 3>;
#declare R = 0.3;
//sphere { p0, R*1.4 pigment { color Yellow } }
//sphere { p1, R*1.4 pigment { color Green } }
//#declare SSA_Fn = f_sphere_sweep_linear_segment(p0, p1, R)
#declare SSB_Fn = LineSegmentFunction(p0, p1, R)
isosurface {
// function { SSA_Fn(x, y, z) }
function { SSB_Fn(x, y, z) }
contained_by { sphere { <0, 0, 0>, 6 } }
pigment { color White }
}
background { color rgb <0, 1, 2>/4 }
light_source { <1, 1, -1>*100, color rgb <1, 1, 1> }
camera {
location <1, 1, -4>*2
look_at <0, 0, 0>
}
Tor Olav
Post a reply to this message
|
![](/i/fill.gif) |