POV-Ray : Newsgroups : povray.general : Need math help : Re: Need math help Server Time
10 Aug 2024 03:15:53 EDT (-0400)
  Re: Need math help  
From: John VanSickle
Date: 9 Mar 2000 19:27:56
Message: <38C843DB.427C43AA@erols.com>
Sebastian Strand wrote:
> 
> I've been trying to create a macro that would seamlessly connect two
> toruses, just like John VanSickle's Connect macro does for spheres. I
> can't seem to get it right, however, so I'd be very grateful if
> someone with more math skills than me could help me.

Question:  Do the torii share the same axis?

If the answer to is yes, the macro goes like this:

#macro TorusConnect(StartPoint,StartMajorRadius,StartMinorRadius,
  EndPoint,EndMajorRadius,EndMinorRadius)

#local pS=StartPoint;
#local pE=EndPoint;
#local rSJ=StartMajorRadius;
#local rSN=StartMinorRadius;
#local rEJ=EndMajorRadius;
#local rEN=EndMinorRadius;
#local sL1=vlength(pE-pS);
#local vA=vnormalize(pE-pS);

#local sL2=vlength(<sL1,rEJ-rSJ,0>);

#local sL3=sqrt(sL2*sL2-(rEN-rSN)*(rEN-rSN));

#local sC1=sL1/sL2;
#local sS1=(rSJ-rEJ)/sL2;

#local sC2=sL3/sL2;
#local sS2=(rSN-rEN)/sL2;

#local xS=rSJ+(sC1*sC2-sS1*sS2)*rSN;
#local yS=(sC1*sS2+sC2*sS1)*rSN;

#local xE=rEJ+(sC1*sC2-sS1*sS2)*rEN;
#local yE=sL1+(sC1*sS2+sC2*sS1)*rEN;

cone { pS+vA*yS,xS,pS+vA*yE,xE }

#end

I've tested it and it appears to work.  Note that it makes a solid
connector, with no hole in the middle to connect the holes in the torii.

There's no error-checking, so don't give it any strange parameters.

I'll probably toss this into the Thoroughly Useful Macros file,
probably once I get the connecting hole added.

Hope this helps,
John
-- 
ICQ: 46085459


Post a reply to this message

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