|
|
"Loki" <nomail@nomail> wrote:
> This is a tricky problem in CSG - I've tried to do something similar in the
> past without resorting to an isosurface and the results weren't too great.
> The surface required to join the two cylinders was beyond my somewhat
> limited CSG abilities. I tried using a sphere_sweep to make a 'bent torus'
> from which to cut, but the precision required by the spline to get a smooth
> join was, I thought, insurmountable.
>
> L
> -
Insurmoutable is about right...unfortunately.
However, after much trial and alot of error, the following variable
substitution will bend (almost) any object in a circular arc around the z
axis:
Let f(x,y,z) be the function you wish to bend.
i.e. f(x,y,z)=f_torus(y,x,z,0.8,0.2) -- a torus in the y-z plane (notice
that it's not in the x-y plane like normal)
The substitution is as follows:
bent_f(x,y,z)=f(sqrt(x*x+y*y)-r,atan2(y,x),z)
"r" is what I call the "radius of curvature" which I shall now explain:
The torus that I provided above is exactly 2 units long in the y-axis. The
bent_f mapping is periodic with a period of (of course) 2*pi.
This means that an object (such as a torus) longer than 2*pi units in length
will map more than once around a circle.
There is no way to stop this, save from scaling the torus. However this
action results in a bent circular path around the torus (just like scaling
any normal torus by more than a factor 1 in any axis). This is something I
wish to avoid.
The "r" variable specifies the radius of the circular arc you are going to
map your function to.
Basically the bent_f substitution bends an object like a torus around a
cylinder of radius r that is travelling down the z axis.
The amount of the circular arc on the cylinder that is taken up by the
mapping is determined completely by the length of the original function in
the y-axis.
Thus if a torus is pi/2 units long (in diameter) then it will occupy an arc
length of (pi/2)/(2*pi) = 1/4 of the entire arc length.
Changing the "r" variable will not change how much of the cylinder is
covered; it will only change how "big" the resulting object will be.
In conclusion this bent torus can be used to cut away a slightly larger
cylinder to give a smooth trnsition between a large cylinder and a
(smaller) one at right angles to the cylinder.
Nathan
Post a reply to this message
|
|