This was written off-list. But I wanted to post it here in order to have
it archived:

> Just a quick jmol code question RE: ribbons

I do not know whether or not you know the story behind the reason this
feature is not implemented.

I have applied for a grant. This item is one of the items which is
explicitly mentioned in the grant proposal. They were supposed to give
us an answer in January ... but they have now delayed until June.

> We really badly need ribbons for teaching 2nd year
> biochemistry with jmol

Q: Do you need ribbons for nucleotide chains, or just for proteins?

> I'm going to attempt to implement ribbons
> using an interpolation spline surface rather than a curve
> approximation (such as the hermite curve used for strands currently).
> Interpolated spline gives the helix a greater diameter and intersects
> each alpha carbon. think this is how rasmol does it.

As I understand it, many/most 'spline curves' are special cases of hermite
curves.

For more information check out:
  http://www.cubic.org/~submissive/sourcerer/hermite.htm

(I just put a comment in the Hermite3D.java source code)

The RasMol 2.6b2 source code is in the public domain.
One problem with the RasMol implementation is that it chooses fixed guide
points. That makes the ribbons somewhat discontinuous with flat surfaces.

My plan was/is to extend the strands code to implement ribbons.

> What I wanted to know is basically how the hermite3d.render ->
> g3d.plotPixelClipped methods work... does it plot one pixel of
> the curve (does it calculate points on the curve between CA - CA1,
> then CA1-CA2,etc or does it do CA-CA1-CA2.. All at once ? )  at a time ?

I had a hard time understanding your question. I will try to answer a few
things.

g3d.plotPixelClipped only plots one pixel. It is 'clipped' in the sense
that the bounds are checked to determine whether it is visible, on the Z
(slab) dimension as well as on the X and Y dimensions.

The routine Hermite3D.render takes 4 points and draws the curve between
the center two. At the beginning/end, the first/last two points are
duplicated.

 the four points are p0, p1, p2, & p3
 we are plotting between p1 and p2
 p0 and p3 provide trajectory/velocity information

The code is (essentially) a recursive algorithm with an interative
implementation. A small stack is maintained separately. Basically:

 if (p1 & p2 are adjacent) {
   plot p2;
   pop-the-stack;
 } else {
   calculate the mid-point between p1 & p2;
   recurse;
 }


> **Also**  for a ribbon view, could you just draw a line of length x,
> perpendicular to the trajectory of the point at the position of
> the pixel ?

Yes, that is the general idea.

My thinking is as follows:

One needs to run the existing Hermite3D.render code over the two edges of
the ribbon at the same time. Then, rather than plotting points, one needs
to draw a line between the two edges.

There are, of course, some complications which make it more hairy:

 * each time the line is drawn (from one edge of the ribbon to the other)
the shade color needs to be calculated. Otherwise, the entire ribbon will
be the unshaded base color and it will look flat.

 * the existing 'strands' code does not do this surface-normal color
shading. All dots are the unshaded base color.

 * we need to use the right line-drawing routine in order to ensure that
pixels do not get left out. That is, we are stepping both endpoints and
we need to make sure that the adjacent lines completely fill in the
space. I strongly suspect that this is going to be difficult to
accomplish.

 * if it becomes difficult/impossible to accomplish it with lines, then we
will need to switch and do it with triangles. That is, fill in the solid
ribbon out of adjacent triangles. These triangles might be very thin ...
with the base points being adjacent pixels.

> Hope you can help. my graphics programming and geometry
> knowledge is a bit limited !!!

Hmmm ... then be advised that I suspect this will be a rather steep
learning curve for you.

I don't want to discourage you ... I would very much like to have someone
else who could work on the code ... but it will be a *challenge*.

If you decide to proceed, then I will be happy to provide
assistance/advice/tutoring/code review.

If I have scared you away then don't worry ... I will plan on implementing
it in June/July.


Miguel



-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
Jmol-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to