|
![](/i/fill.gif) |
Wasn't it Ian K who wrote:
>So, I'm pretty new at this, but I'm trying to render arcs to display the angles
>between bonds in molecules, using a function that takes the vectors of the
>bonds and uses the intersection of two semicircular prisms to draw an acute arc
>- something like this:
>
>
>#macro drawAcuteArc(centre, arcSweepStart, arcSweepEnd, arcRadius, borderWidth)
> #local arcDepth = 0.1;
> #local arcNorm = vcross(arcSweepStart,arcSweepEnd);
> #local arcAngle = VRotation(arcSweepStart, arcSweepEnd, arcNorm);
> #debug "Angle = "
> #debug str(arcAngle, 0, 3)
>
> intersection {
> //Semicircle 1
> difference{
> cylinder{ centre - arcDepth * arcNorm, centre + arcDepth * arcNorm,
>arcRadius }
> plane{ arcSweepStart, 0 translate centre }
> }
>
> //Semicircle 2
> difference{
> cylinder{ centre - arcDepth * arcNorm, centre + arcDepth * arcNorm,
>arcRadius }
> plane{ arcSweepEnd, 0 translate centre}
> }
>
> pigment {rgbf <1,0,0,0>}
> }
>#end
>
>drawAcuteArc(0, <0,1,1>, <1,0,0>, 5.5, 0.5)
>
>
>
>The only problem is that this doesn't do that. It seems to instead give me a
>slice where the arc would start, and a slice where the arc would stop, and no
>arc.
>
>If I make the faces more differently placed, it seems to intersect
>correctly - I
>tried making one of the cylinders bigger than the other, and it seemed
>that only
>faces that were created by the intersection, rather than faces which were
>coincident in the creating models, were shown. This seems a little dodgy - is
>it a bug?
Things like that can happen with coincident surfaces.
In the general case, the workround is to displace one of the components
slightly
#local arcDepth2 = arcDepth*1.00001;
//Semicircle 2
difference{
cylinder{ centre - arcDepth2 * arcNorm, centre + arcDepth2 *
arcNorm, arcRadius }
plane{ arcSweepEnd, 0 translate centre}
}
However, in this case you don't need a second cylinder. You can just
difference both planes from the same one:
#macro drawAcuteArc(centre, arcSweepStart, arcSweepEnd, arcRadius,
borderWidth)
#local arcDepth = 0.1;
#local arcNorm = vcross(arcSweepStart,arcSweepEnd);
difference{
cylinder{ centre - arcDepth * arcNorm, centre + arcDepth
* arcNorm, arcRadius }
plane{ arcSweepStart, 0 translate centre }
plane{ arcSweepEnd, 0 translate centre}
pigment {rgbf <1,0,0,0>}
}
#end
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |