Revision: 18588 http://sourceforge.net/p/jmol/code/18588 Author: hansonr Date: 2013-08-17 17:13:40 +0000 (Sat, 17 Aug 2013) Log Message: ----------- ___JmolVersion="13.3.4_dev_2013.08.17"
new feature: show ROTATION VOLUME -- calculates approximate best box (from 1495 quaternion-based alternatives) -- reports "{quaternion} volume {dx dy dz}" where dx > dy > dz new feature: show ROTATION BEST -- just reports "{quaternion}" new feature: quaternion("best") -- delivers actual quaternion new feature: rotate BEST new feature: rotate SELECTED BEST Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/popup/MainPopupResourceBundle.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/script/T.java trunk/Jmol/src/org/jmol/scriptext/ScriptExt.java trunk/Jmol/src/org/jmol/symmetry/PointGroup.java trunk/Jmol/src/org/jmol/util/BoxInfo.java trunk/Jmol/src/org/jmol/util/Measure.java trunk/Jmol/src/org/jmol/util/Quaternion.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StateCreator.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -317,7 +317,7 @@ } public Point3fi[] getBboxVertices() { - return boxInfo.getBboxVertices(); + return boxInfo.getBoundBoxVertices(); } public Map<String, Object> getBoundBoxInfo() { @@ -3497,5 +3497,103 @@ //System.out.println(a.x + " " + a.y + " " + a.z + " ms is " + ms + " " + ms.enabled + " " + ms.t); } } + + private Quaternion[] vOrientations; + + public String getBoundBoxOrientation(int type, BS bsAtoms) { + int j0 = bsAtoms.nextSetBit(0); + if (j0 < 0) + return "{0 0 0 1}"; + int n = (vOrientations == null ? 0 : vOrientations.length); + if (n == 0) { + V3[] av = new V3[15*15*15]; + n = 0; + P4 p4 = new P4(); + for (int i = -7; i <= 7; i++) + for (int j = -7; j <= 7; j++) + for (int k = 0; k <= 14; k++, n++) + if ((av[n] = V3.new3(i / 7f, j / 7f, k / 14f)).length() > 1) + --n; + vOrientations = new Quaternion[n]; + for (int i = n; --i >= 0;) { + float cos = (float) Math.sqrt(1 - av[i].lengthSquared()); + if (Float.isNaN(cos)) + cos = 0; + p4.set(av[i].x, av[i].y, av[i].z, cos); + vOrientations[i] = Quaternion.newP4(p4); + } + } + P3 pt = new P3(); + float vMin = Float.MAX_VALUE; + Quaternion q, qBest = null; + BoxInfo bBest = null; + float v; + for (int i = 0; i < n; i++) { + q = vOrientations[i]; + BoxInfo b = new BoxInfo(); + b.setMargin(0); + for (int j = j0; j >= 0; j = bsAtoms.nextSetBit(j + 1)) + b.addBoundBoxPoint((P3) q.transformP2(atoms[j], + pt)); + switch (type) { + default: + case T.volume: + case T.best: + v = (b.bbCorner1.x - b.bbCorner0.x) * (b.bbCorner1.y - b.bbCorner0.y) + * (b.bbCorner1.z - b.bbCorner0.z); + break; + case T.x: + v = b.bbCorner1.x - b.bbCorner0.x; + break; + case T.y: + v = b.bbCorner1.y - b.bbCorner0.y; + break; + case T.z: + v = b.bbCorner1.z - b.bbCorner0.z; + break; + } + if (v < vMin) { + qBest = q; + bBest = b; + vMin = v; + } + } + if (type != T.volume && type != T.best) + return qBest.toString(); + // we want dz < dy < dx + q = Quaternion.newQ(qBest); + float dx = bBest.bbCorner1.x - bBest.bbCorner0.x; + float dy = bBest.bbCorner1.y - bBest.bbCorner0.y; + float dz = bBest.bbCorner1.z - bBest.bbCorner0.z; + if (dx < dy) { + pt.set(0, 0, 1); + q = Quaternion.newVA(pt, 90).mulQ(q); + float f = dx; + dx = dy; + dy = f; + } + if (dy < dz) { + if (dz > dx) { + // is dy < dx < dz + pt.set(0, 1, 0); + q = Quaternion.newVA(pt, 90).mulQ(q); + float f = dx; + dx = dz; + dz = f; + } + // is dy < dz < dx + pt.set(1, 0, 0); + q = Quaternion.newVA(pt, 90).mulQ(q); + float f = dy; + dy = dz; + dz = f; + } + v = q.getTheta(); + if (v == 180 || v == 0) + return "{0 0 0 1}"; + V3 vec = V3.new3(dx, dy, dz); + return q.toString() + (type == T.best ? "" : " " + vMin + " " + Escape.eP(vec)); + } } + \ No newline at end of file Modified: trunk/Jmol/src/org/jmol/popup/MainPopupResourceBundle.java =================================================================== --- trunk/Jmol/src/org/jmol/popup/MainPopupResourceBundle.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/popup/MainPopupResourceBundle.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -90,7 +90,7 @@ + "Ligand exceptWater nonWaterSolvent" }, { "viewMenu", - "front left right top bottom back" }, + "best front left right top bottom back" }, { "renderMenu", "perspectiveDepthCB showBoundBoxCB showUNITCELLCB showAxesCB stereoMenu - renderSchemeMenu - atomMenu labelMenu bondMenu hbondMenu ssbondMenu - " @@ -305,6 +305,7 @@ // not implemented { "Lipid", "SELECT lipid" }, { "PDBnoneOfTheAbove", "SELECT not(hetero,protein,nucleic,carbohydrate)" }, + { "best", "rotate best -1.0" }, { "front", Box( "moveto 2.0 front;delay 1" ) }, { "left", Box( "moveto 1.0 front;moveto 2.0 left;delay 1" ) }, { "right", Box( "moveto 1.0 front;moveto 2.0 right;delay 1" ) }, @@ -592,6 +593,7 @@ "invertSelection", GT._("Invert Selection"), "viewMenu", GT._("View"), + "best", GT._("Best"), "front", GT._("Front"), "left", GT._("Left"), "right", GT._("Right"), Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -6559,7 +6559,7 @@ q = (chk ? new Quaternion() : viewer.getAtomQuaternion(bsCenter .nextSetBit(0))); } else { - q = getQuaternionParameter(i); + q = getQuaternionParameter(i, null); } i = iToken + 1; if (q == null) @@ -10097,12 +10097,15 @@ case T.point4f: case T.quaternion: + case T.best: if (tok == T.quaternion) i++; haveRotation = true; - q = getQuaternionParameter(i); - rotAxis.setT(q.getNormal()); - endDegrees = q.getTheta(); + q = getQuaternionParameter(i, isSelected || tok != T.best ? null : viewer.getRotationQuaternion().mul(-1)); + if (q != null) { + rotAxis.setT(q.getNormal()); + endDegrees = q.getTheta(); + } break; case T.axisangle: haveRotation = true; @@ -10333,15 +10336,26 @@ } } - private Quaternion getQuaternionParameter(int i) throws ScriptException { - if (tokAt(i) == T.varray) { + private Quaternion getQuaternionParameter(int i, Quaternion q0) + throws ScriptException { + Quaternion q; + switch (tokAt(i)) { + case T.varray: JmolList<SV> sv = ((SV) getToken(i)).getList(); P4 p4 = null; if (sv.size() == 0 || (p4 = SV.pt4Value(sv.get(0))) == null) invArg(); - return Quaternion.newP4(p4); + q = Quaternion.newP4(p4); + break; + case T.best: + if (chk) + return null; + q = Quaternion.newP4((P4) Escape.uP(viewer.getOrientationText(T.best, null))); + break; + default: + q = Quaternion.newP4(getPoint4f(i)); } - return Quaternion.newP4(getPoint4f(i)); + return (q0 == null ? q : q.mulQ(q0)); } JmolList<P3> getPointVector(T t, int i) throws ScriptException { @@ -11821,12 +11835,9 @@ // deprecated //$FALL-THROUGH$ case T.surfacedistance: - /* - * preferred: - * - * calculate surfaceDistance FROM {...} calculate surfaceDistance WITHIN - * {...} - */ + // preferred + // calculate surfaceDistance FROM {...} + // calculate surfaceDistance WITHIN {...} boolean isFrom = false; switch (tokAt(2)) { case T.within: @@ -15004,8 +15015,14 @@ if (!chk) msg = viewer.getMeasurementInfoAsString(); break; + case T.rotation: + tok = tokAt(2); + if (tok == T.nada) + tok = T.rotation; + else + len = 3; + //$FALL-THROUGH$ case T.translation: - case T.rotation: case T.moveto: if (!chk) msg = viewer.getOrientationText(tok, null); @@ -15024,7 +15041,7 @@ break; default: name = optParameterAsString(2); - msg = viewer.getOrientationText(0, name); + msg = viewer.getOrientationText(T.name, name); } len = slen; break; Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -2148,6 +2148,7 @@ // quaternion(vector, theta) // quaternion(q0, q1, q2, q3) // quaternion("{x, y, z, w"}) + // quaternion("best") // quaternion(center, X, XY) // quaternion(mcol1, mcol2) // quaternion(q, "id", center) // draw code @@ -2224,7 +2225,8 @@ } else if (args[0].tok == T.point4f) { p4 = (P4) args[0].value; } else { - Object v = Escape.uP(SV.sValue(args[0])); + String s = SV.sValue(args[0]); + Object v = Escape.uP(s.equalsIgnoreCase("best") ? viewer.getOrientationText(T.best, null) : s); if (!(v instanceof P4)) return false; p4 = (P4) v; Modified: trunk/Jmol/src/org/jmol/script/T.java =================================================================== --- trunk/Jmol/src/org/jmol/script/T.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/script/T.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -1092,7 +1092,8 @@ public final static int back = misc | 35; public final static int balls = misc | 36; public final static int barb = misc | 37; - public final static int backlit = misc | 38; + public final static int backlit = misc | 38; + public final static int best = misc | 39; public final static int basepair = misc | 40; public final static int binary = misc | 42; public final static int blockdata = misc | 44; @@ -1791,6 +1792,7 @@ "backlit", T.t(backlit), "balls", T.t(balls), "baseModel", T.t(basemodel), // Jmol 12.3.19 + "best", T.t(best), // rotate BEST "bin", T.t(bin), "bondCount", T.t(bondcount), "bottom", T.t(bottom), Modified: trunk/Jmol/src/org/jmol/scriptext/ScriptExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/ScriptExt.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/scriptext/ScriptExt.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -3833,8 +3833,8 @@ v.addLast(ptc); } else { BoxInfo bbox = viewer.getBoxInfo(bs, -Math.abs(distance)); - pts[0] = bbox.getBboxVertices()[0]; - pts[1] = bbox.getBboxVertices()[7]; + pts[0] = bbox.getBoundBoxVertices()[0]; + pts[1] = bbox.getBoundBoxVertices()[7]; if (bs.cardinality() == 1) v.addLast(viewer.getAtomPoint3f(bs.nextSetBit(0))); } Modified: trunk/Jmol/src/org/jmol/symmetry/PointGroup.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/PointGroup.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/symmetry/PointGroup.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -411,8 +411,7 @@ if (q != null) { pt.setT(a1); pt.sub(center); - q.transformP2(pt, pt); - pt.add(center); + q.transformP2(pt, pt).add(center); } else { pt.setT(a1); } Modified: trunk/Jmol/src/org/jmol/util/BoxInfo.java =================================================================== --- trunk/Jmol/src/org/jmol/util/BoxInfo.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/util/BoxInfo.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -36,12 +36,13 @@ public class BoxInfo { - private final P3 bbCorner0 = new P3(); - private final P3 bbCorner1 = new P3(); + public final P3 bbCorner0 = new P3(); + public final P3 bbCorner1 = new P3(); private final P3 bbCenter = new P3(); private final V3 bbVector = new V3(); private final Point3fi[] bbVertices = new Point3fi[8]; private boolean isScaleSet; + private float margin; { for (int i = 8; --i >= 0;) @@ -234,7 +235,7 @@ bbCorner1 } : new P3[] { bbCorner0, bbCorner1 }); } - public Point3fi[] getBboxVertices() { + public Point3fi[] getBoundBoxVertices() { if (!isScaleSet) setBbcage(1); return bbVertices; @@ -278,9 +279,13 @@ bbCorner1.set(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE); } + public void setMargin(float m) { + margin = m; + } + public void addBoundBoxPoint(P3 pt) { isScaleSet = false; - addPoint(pt, bbCorner0, bbCorner1, 0); + addPoint(pt, bbCorner0, bbCorner1, margin); } public static void addPoint(P3 pt, P3 xyzMin, P3 xyzMax, float margin) { @@ -345,6 +350,4 @@ && pt.z >= bbCorner0.z && pt.z <= bbCorner1.z); } - - } Modified: trunk/Jmol/src/org/jmol/util/Measure.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Measure.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/util/Measure.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -577,8 +577,7 @@ for (int i = n + 1; --i >= 1;) { ptAnew.setT(ptsA[i]); ptAnew.sub(cA); - q.transformP2(ptAnew, ptAnew); - ptAnew.add(cB); + q.transformP2(ptAnew, ptAnew).add(cB); sum2 += ptAnew.distanceSquared(ptsB[i]); } return (float) Math.sqrt(sum2 / n); Modified: trunk/Jmol/src/org/jmol/util/Quaternion.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Quaternion.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/util/Quaternion.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -600,10 +600,11 @@ return ptNew; } - public void transformP2(Tuple3f pt, Tuple3f ptNew) { + public Tuple3f transformP2(Tuple3f pt, Tuple3f ptNew) { if (mat == null) setMatrix(); mat.transform2(pt, ptNew); + return ptNew; } public V3 transform(V3 v) { Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-08-17 17:13:40 UTC (rev 18588) @@ -11,10 +11,22 @@ # The quotes above look odd for a parameter file, but they are # important for the JavaScript version of Jmol. -___JmolVersion="13.3.4_dev_2013.08.16" +___JmolVersion="13.3.4_dev_2013.08.17" +new feature: show ROTATION VOLUME + -- calculates approximate best box (from 1495 quaternion-based alternatives) + -- reports "{quaternion} volume {dx dy dz}" where dx > dy > dz +new feature: show ROTATION BEST + -- just reports "{quaternion}" +new feature: quaternion("best") + -- delivers actual quaternion +new feature: rotate BEST +new feature: rotate SELECTED BEST + bug fix: CIF reader does not find Hall name for space groups -NEW FEATURE: set platformSpeed [0 to 10] (includes wireframeRotation along with cartoons and surfaces) + +new feature: set platformSpeed [0 to 10] (includes wireframeRotation along with cartoons and surfaces) + bug fix: binding names not included in SHOW MOUSE bug fix: "single" touch can fire double-click bug fix: {x}.tensor() command fails when no atom tensors Modified: trunk/Jmol/src/org/jmol/viewer/StateCreator.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateCreator.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/viewer/StateCreator.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -769,7 +769,7 @@ appendCmd(commands, "set navigationMode true"); appendCmd(commands, viewer.getBoundBoxCommand(false)); appendCmd(commands, "center " + Escape.eP(tm.fixedRotationCenter)); - commands.append(viewer.getOrientationText(T.state, null)); + commands.append(viewer.getOrientationText(T.name, null)); appendCmd(commands, moveToText); if (tm.stereoMode != EnumStereoMode.NONE) Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-08-17 08:11:11 UTC (rev 18587) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-08-17 17:13:40 UTC (rev 18588) @@ -1436,9 +1436,20 @@ } public String getOrientationText(int type, String name) { - return (name == null && type != T.state ? transformManager.getOrientationText(type) - : stateManager.getSavedOrientationText(name)); - } + switch (type) { + case T.volume: + case T.best: + case T.x: + case T.y: + case T.z: + case T.quaternion: + return modelSet.getBoundBoxOrientation(type, getSelectionSet(false)); + case T.name: + return stateManager.getSavedOrientationText(name); + default: + return transformManager.getOrientationText(type); + } + } Map<String, Object> getOrientationInfo() { return transformManager.getOrientationInfo(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits