|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it kurtz le pirate who wrote:
>hello,
>
>i want to model cable with 2 parts : cylindrical and part of torus.
>
>for cylindrical, i have no problem. code i use is :
>
>#declare p1 = 8; // number of helixes
>#declare p2 = 0.25; // number of turns per unit length
>#declare p3 = 1.75; // minor radius
>#declare p4 = 1.50; // major radius
>#declare p5 = 1.00; // shape parameter
>#declare p6 = 1; // cross section type -> circle
>#declare p7 = 0; // cross section rotation angle
>
>#declare containerSize = 3.20;
>#declare maxGradiantValue = 10;
>
>#declare cableFunction = function { f_helix1(x, y, z, p1, p2, p3, p4,
>p5, p6, p7) }
>
>#declare cableCyl = isosurface {
> function { cableFunction(x,y,z) }
> contained_by {
> box { <+containerSize, 0.00, +containerSize> <-containerSize,
>-cableLen, -containerSize> }
> }
> max_gradient maxGradiantValue
> }
>
>
>for "torus part", i do this code :
>
>#declare cableTorus = isosurface {
> function { cableFunction(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
> contained_by {
> sphere { 0,*MajorRadius1.2 }
> }
> max_gradient maxGradiantValue
> rotate 90*x
> }
>with MajorRadius = 80.00
>
>
>... but all the thing a get is a plain torus !!!
>
>anyone can help me ?
>thanks
The easy problem: If you're trying to follow my example code from
<http://www.econym.demon.co.uk/isotut/substitute.htm#polar>
you'll need to flip the axes like I do.
Try declaring a second cableFunction with flipped axes like this:
#declare cableFunction2 = function { f_helix1(x, z, y, p1, p2, p3,
p4,p5, p6, p7) }
#declare cableTorus = isosurface {
function { cableFunction2(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
contained_by {
sphere { 0,MajorRadius*1.2 }
}
max_gradient 1.3
rotate 90*x
}
The problem you'll then notice is that p2 only relates to the number of
turns per unit length before the substitution, so you only get something
like pi*p2 turns around the whole loop, and that's nowhere near enough.
You might think that would be easy to solve by increasing the value of
p2, but unfortunately you hit the problem that f_helix1 only behaves
predictably when the major radius is larger than the minor radius. If
you increase p2, things go horribly wrong.
So, I think you've got to use f_helix2, like this:
#declare cableFunction2 = function { f_helix2(x, z, y, 0,
p2*MajorRadius, p3, p4,p5, p6, p7) }
#declare cableTorus = isosurface {
function { cableFunction2(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
contained_by {
sphere { 0,MajorRadius*1.2 }
}
max_gradient 1.3
rotate 90*x
}
However, f_helix2 doesn't support multi-stranding, so if you want an
eight strand cable you'll need eight copies of that isosurface. That's
not quite as bad as it seems because the low value of max_gradient means
that it renders pretty quickly.
#declare Angle = 360/p2/MajorRadius/8;
#declare N=0;
#while (N<8)
object {cableTorus pigment {rgb 1} rotate z*Angle*N}
#declare N=N+1;
#end
This then leaves you with the final problem that this cable doesn't look
quite the same as the cylindrical one. That's because it's still using
f_helix1. So you'll need to do the same thing with that if you want them
to match.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it Mike Williams who wrote:
>
>Wasn't it kurtz le pirate who wrote:
>>hello,
>>
>>i want to model cable with 2 parts : cylindrical and part of torus.
Upon further experimentation, I found a much easier way to do it.
You still need to flip the axes, but you could do that in the cableTorus
definition and keep only the single cableFunction definition.
The new trick is to use "f_th(x,y,z)*MajorRadius" in the cableTorus
variable substitution instead of just "f_th(x,y,z)". Multiplying by
MajorRadius increases the number of helical turns and things don't go
horribly wrong this way.
So the whole thing now looks like this:
//hello,
//i want to model cable with 2 parts : cylindrical and part of torus.
//for cylindrical, i have no problem. code i use is :
#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location <0,0,-50> look_at <0,80,0>}
background {rgb 1}
light_source {<0, 100, -30> color rgb 1}
#include "functions.inc"
#declare p1 = 8; // number of helixes
#declare p2 = 0.25; // number of turns per unit length
#declare p3 = 1.75; // minor radius
#declare p4 = 1.50; // major radius
#declare p5 = 1.00; // shape parameter
#declare p6 = 1; // cross section type -> circle
#declare p7 = 0; // cross section rotation angle
#declare containerSize = 3.2;
#declare maxGradiantValue = 2;
#declare cableLen = 80.00;
#declare MajorRadius = 80.00;
#declare cableFunction = function {
f_helix1(x, y, z, p1, p2, p3, p4,p5, p6, p7) }
#declare cableCyl = isosurface {
function { cableFunction(x,y,z) }
contained_by {
box { <+containerSize, 0.00, +containerSize>
<-containerSize, -cableLen, -containerSize> }
}
max_gradient maxGradiantValue
}
#declare maxGradiantValue = 6;
#declare cableTorus = isosurface {
function { cableFunction(f_r(x,y,z)-MajorRadius,
f_th(x,y,z)*MajorRadius, y) }
contained_by {
sphere { 0,MajorRadius*1.2 }
}
max_gradient maxGradiantValue
rotate 90*x
}
intersection {
object {cableTorus}
box {<0,-MajorRadius*1.2,-MajorRadius*1.2>
<MajorRadius,MajorRadius*1.2,MajorRadius*1.2>}
pigment {rgb 1}
}
object {cableCyl pigment {rgb 1} rotate- z*90 translate y*MajorRadius }
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <WASm$FAUWHICFwAT@econym.demon.co.uk>,
Mike Williams <nos### [at] econymdemoncouk> wrote:
>>Wasn't it kurtz le pirate who wrote:
>>>hello,
>>>
>>>i want to model cable with 2 parts : cylindrical and part of torus.
>>>
>>>for cylindrical, i have no problem. code i use is :
>>>
>>>#declare p1 = 8; // number of helixes
>>>#declare p2 = 0.25; // number of turns per unit length
>>>#declare p3 = 1.75; // minor radius
>>>#declare p4 = 1.50; // major radius
>>>#declare p5 = 1.00; // shape parameter
>>>#declare p6 = 1; // cross section type -> circle
>>>#declare p7 = 0; // cross section rotation angle
>>>
>>>#declare containerSize = 3.20;
>>>#declare maxGradiantValue = 10;
>>>
>>>#declare cableFunction = function { f_helix1(x, y, z, p1, p2, p3, p4,
>>>p5, p6, p7) }
>>>
>>>#declare cableCyl = isosurface {
>>> function { cableFunction(x,y,z) }
>>> contained_by {
>>> box { <+containerSize, 0.00, +containerSize> <-containerSize,
>>>-cableLen, -containerSize> }
>>> }
>>> max_gradient maxGradiantValue
>>> }
>>>
>>>
>>>for "torus part", i do this code :
>>>
>>>#declare cableTorus = isosurface {
>>> function { cableFunction(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
>>> contained_by {
>>> sphere { 0,*MajorRadius1.2 }
>>> }
>>> max_gradient maxGradiantValue
>>> rotate 90*x
>>> }
>>>with MajorRadius = 80.00
>>>
>>>
>>>... but all the thing a get is a plain torus !!!
>>>
>>>anyone can help me ?
>>>thanks
>>
>>
>>The easy problem: If you're trying to follow my example code from
>><http://www.econym.demon.co.uk/isotut/substitute.htm#polar>
>>you'll need to flip the axes like I do.
>>
>>Try declaring a second cableFunction with flipped axes like this:
>>
>>#declare cableFunction2 = function { f_helix1(x, z, y, p1, p2, p3,
>>p4,p5, p6, p7) }
>>
>>#declare cableTorus = isosurface {
>> function { cableFunction2(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
>> contained_by {
>> sphere { 0,MajorRadius*1.2 }
>> }
>> max_gradient 1.3
>> rotate 90*x
>> }
>>
>>The problem you'll then notice is that p2 only relates to the number of
>>turns per unit length before the substitution, so you only get something
>>like pi*p2 turns around the whole loop, and that's nowhere near enough.
>>
>>You might think that would be easy to solve by increasing the value of
>>p2, but unfortunately you hit the problem that f_helix1 only behaves
>>predictably when the major radius is larger than the minor radius. If
>>you increase p2, things go horribly wrong.
>>
>>So, I think you've got to use f_helix2, like this:
>>
>>#declare cableFunction2 = function { f_helix2(x, z, y, 0,
>>p2*MajorRadius, p3, p4,p5, p6, p7) }
>>
>>#declare cableTorus = isosurface {
>> function { cableFunction2(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
>> contained_by {
>> sphere { 0,MajorRadius*1.2 }
>> }
>> max_gradient 1.3
>> rotate 90*x
>> }
>>
>>However, f_helix2 doesn't support multi-stranding, so if you want an
>>eight strand cable you'll need eight copies of that isosurface. That's
>>not quite as bad as it seems because the low value of max_gradient means
>>that it renders pretty quickly.
>>
>>#declare Angle = 360/p2/MajorRadius/8;
>>
>>#declare N=0;
>>#while (N<8)
>> object {cableTorus pigment {rgb 1} rotate z*Angle*N}
>> #declare N=N+1;
>>#end
>>
>>This then leaves you with the final problem that this cable doesn't look
>>quite the same as the cylindrical one. That's because it's still using
>>f_helix1. So you'll need to do the same thing with that if you want them
>>to match.
thanks Mike, I will try to put all that into practice
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <kg9### [at] econymdemoncouk>,
Mike Williams <nos### [at] econymdemoncouk> wrote:
>>Upon further experimentation, I found a much easier way to do it.
>>You still need to flip the axes, but you could do that in the cableTorus
>>definition and keep only the single cableFunction definition.
>>
>>The new trick is to use "f_th(x,y,z)*MajorRadius" in the cableTorus
>>variable substitution instead of just "f_th(x,y,z)". Multiplying by
>>MajorRadius increases the number of helical turns and things don't go
>>horribly wrong this way.
>>
>>So the whole thing now looks like this:
YES ! this new trick is great and work very well.
thanks a lot Mike, Gentleman of Leisure and Lord of Isosurfaces
klp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|