From: Robert H. <ha...@st...> - 2012-10-06 20:12:20
|
Eric, there are a number of problems with that page. I don't know about the signed/unsigned business, but first let's get this part fixed: // calculate the three dimensions of the box jmolScript("Vx = (V1.x - V5.x)"); jmolScript("Vy = (V1.y - V5.y)"); jmolScript("Vz = (V1.z - V5.z)"); jmolScript("a = sqrt(Vx*Vx + Vy*Vy + Vz*Vz)"); jmolScript("Vx = (V1.x - V3.x)"); jmolScript("Vy = (V1.y - V3.y)"); jmolScript("Vz = (V1.z - V3.z)"); jmolScript("b = sqrt(Vx*Vx + Vy*Vy + Vz*Vz)"); jmolScript("Vx = (V1.x - V2.x)"); jmolScript("Vy = (V1.y - V2.y)"); jmolScript("Vz = (V1.z - V2.z)"); jmolScript("c = sqrt(Vx*Vx + Vy*Vy + Vz*Vz)"); // calculate the box volume jmolScript("volume = a * b * c "); vol=jmolEvaluate("volume%1"); aa =jmolEvaluate("a%1"); bb =jmolEvaluate("b%1"); cc =jmolEvaluate("c%1"); This will not work properly and is very inefficient. First, get all those script calls into one string: "Vx = (V1.x - V5.x);Vy = (V1.y - V5.y);Vz = (V1.z - V5.z);a = sqrt(Vx*Vx + Vy*Vy + Vz*Vz);Vx = (V1.x - V3.x)..." With that in mind, you should probably just use: "V1.distance(V5)" But the more important thing is that jmolScript is asynchronous, and jmolEvaluate is not. Really what you want is this: a = jmolEvaluate(V1.distance(V5)) b = jmolEvaluate(V1.distance(V3)) c = jmolEvaluate(V1.distance(V2)) vol = a * b * c you can do the rounding in JavaScript. But.... on the other hand, it will work fine with just this little tweak: At the top of your script tag, add this to buffer the script into Jmol: jmolScript0 = jmolScript; script = "" jmolScript = function(a) { // buffer these into jmol -- jmolScript() by itself clears the buffer if (a) { script += ";" + a; } else { jmolScript0(script); script = ""; } } then add jmolScript() just before vol=jmolEvaluate("volume%1"); and just at the end of the drawBox() function. You should be all set. Really a very cool page! Bob On Fri, Oct 5, 2012 at 11:20 PM, eric henon <eri...@un...>wrote: > Dear all, > > once more I meet one > problem using my jMol code (attached). > > When using the signed applet, > the applet becomes very very slow. > > For example, > rotating my box into the jMol windows > (I built a box that I can translate, rotate, scale) > takes about 3-4s for each rotation, while > it is quasi-instantaneous using the unsigned applet. > > Thus, only adding the true parameter in the jmolInitialize > method substantially influences the performance > of the applet. > > Is it a "standard" behavior ? > > Thanks in advance. > Best regards. > Eric Henon > > > > > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Jmol-developers mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-developers > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |