POV-Ray : Newsgroups : povray.newusers : Intersections not quite working? : Re: Intersections not quite working? Server Time
28 Jul 2024 12:30:57 EDT (-0400)
  Re: Intersections not quite working?  
From: Ian K
Date: 17 Mar 2009 10:45:00
Message: <web.49bfb6e19813c63bf8e064a80@news.povray.org>
Leroy Whetstone <lrw### [at] joplincom> wrote:
> A few questions about the variable you used:
>   'arcSweepStart' & 'arcSweepEnd' are they location vectors or normal
> vectors  because you use them as normals in the planes?
> The way you use them if they're not pointing in the right direction
> it'll get funky.
>    'centre' I'm questing would be the midpoint between two atoms.
>    'arcRadius' This I'm not sure of. If your connection two atoms at
> variable distances from each other, then the radius would have to be
> calculated, so that the end points of your bond would touch both atoms.
> If in your model the atoms are all equal distance the 'arcRadius' is
> redundant


This is supposed to draw arcs between molecular bonds, so if you have 3 atoms:
  1
 /
2--3

'centre' is Origin -> 2
'arcSweepStart' and 'arcSweepEnd' are 2->1 and 2->3 (doesn't matter which way
around).
'arcRadius' is there because I didn't want to draw an arc with the edge at 1 or
3, I wanted a smaller one.

I rechecked on your suggestion, and yes, I was mis-using arcSweepStart and
arcSweepEnd - I needed to rotate them about the cross product to get the proper
vectors for the plane.

My almost finished macro looks like this:

#macro drawArc2(centre, arcSweepStart, arcSweepEnd, arcRadius, borderWidth,
invertArc)
  #local arcDepth = 0.1;
  #local arcNorm = vcross(arcSweepStart,arcSweepEnd);
  #local arcAngle = VRotation(arcSweepStart, arcSweepEnd, arcNorm);
  #debug "drawArc: Arc angle = "
  #debug str(arcAngle/(2*pi/360), 0, 3)
  #debug "\n"

  #if( arcAngle = pi )
    //draw180Arc
  #else
    #local planeNormVectorStart = vaxis_rotate(arcSweepStart,arcNorm, 90);
    #local planeNormVectorEnd   = vaxis_rotate(arcSweepEnd,arcNorm, -90);

    difference{
      cylinder{ centre - 2 * arcDepth * arcNorm, centre + 2 * arcDepth *
arcNorm, arcRadius*2 }
      union{
        plane{ planeNormVectorStart, 0 translate centre }
        plane{ planeNormVectorEnd, 0 translate centre }
      #if (invertArc)
        inverse
      #end
      }
      pigment {rgbf <1,0,0,0.5>}
    }
  #end
#end

It doesn't yet handle 180 degree arcs, but that's just because I haven't decided
how to orient them yet.

And the 'invertArc' variable makes it draw the opposite angle to what it would
without.

Now to polish it off, and test it with Avogadro!

Thanks,
-Ian


Post a reply to this message

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