From: <ha...@us...> - 2014-03-02 23:56:30
|
Revision: 19409 http://sourceforge.net/p/jmol/code/19409 Author: hansonr Date: 2014-03-02 23:56:22 +0000 (Sun, 02 Mar 2014) Log Message: ----------- inappropriate calls from javajs Modified Paths: -------------- trunk/Jmol/src/javajs/util/Quat.java trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java trunk/Jmol/src/org/jmol/scriptext/CmdExt.java trunk/Jmol/src/org/jmol/scriptext/MathExt.java trunk/Jmol/src/org/jmol/util/Escape.java Modified: trunk/Jmol/src/javajs/util/Quat.java =================================================================== --- trunk/Jmol/src/javajs/util/Quat.java 2014-03-01 23:01:24 UTC (rev 19408) +++ trunk/Jmol/src/javajs/util/Quat.java 2014-03-02 23:56:22 UTC (rev 19409) @@ -23,11 +23,6 @@ */ package javajs.util; -import org.jmol.util.Escape; -import org.jmol.util.Logger; -import org.jmol.util.Txt; - - /* * Standard UNIT quaternion math -- for rotation. * @@ -472,10 +467,10 @@ } public V3 getVector(int i) { - return getVectorS(i, 1f); + return getVectorScaled(i, 1f); } - private V3 getVectorS(int i, float scale) { + public V3 getVectorScaled(int i, float scale) { if (i == -1) { scale *= getFixFactor(); return V3.new3(q1 * scale, q2 * scale, q3 * scale); @@ -630,26 +625,6 @@ return mulQ(q2adjusted.inv()); } - public String getInfo() { - A4 axis = toAxisAngle4f(); - return Txt.sprintf("%10.6f%10.6f%10.6f%10.6f %6.2f %10.5f %10.5f %10.5f", - "F", new Object[] { new float[] { q0, q1, q2, q3, - (float) (axis.angle * 180 / Math.PI), axis.x, axis.y, axis.z } }); - } - - public String draw(String prefix, String id, P3 ptCenter, - float scale) { - String strV = " VECTOR " + Escape.eP(ptCenter) + " "; - if (scale == 0) - scale = 1f; - return "draw " + prefix + "x" + id + strV - + Escape.eP(getVectorS(0, scale)) + " color red\n" - + "draw " + prefix + "y" + id + strV - + Escape.eP(getVectorS(1, scale)) + " color green\n" - + "draw " + prefix + "z" + id + strV - + Escape.eP(getVectorS(2, scale)) + " color blue\n"; - } - /** * * Java axisAngle / plane / Point4f format @@ -709,7 +684,7 @@ retStddev[0] = stdDev(data, qMean); diff = Math.abs(retStddev[0] - lastStddev); lastStddev = retStddev[0]; - Logger.info(++iter + " sphereMean " + qMean + " stddev=" + lastStddev + " diff=" + diff); + //Logger.info(++iter + " sphereMean " + qMean + " stddev=" + lastStddev + " diff=" + diff); } return qMean; } Modified: trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java =================================================================== --- trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2014-03-01 23:01:24 UTC (rev 19408) +++ trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2014-03-02 23:56:22 UTC (rev 19409) @@ -35,6 +35,7 @@ import org.jmol.util.Logger; +import javajs.util.A4; import javajs.util.OC; import javajs.util.P3; import javajs.util.PT; @@ -700,7 +701,7 @@ continue; } else { q = Quat.newVA(P3.new3(1, 0, 0), angledeg); - strExtra = q.getInfo(); + strExtra = getQInfo(q); if (writeRamachandranStraightness) { z = angledeg; w = straightness; @@ -858,7 +859,7 @@ continue; int deg = (int) Math.floor(Math.acos(w) * 360 / Math.PI); if (derivType == 0) { - pdbATOM.append(q.draw(prefix, id, ptCenter, 1f)); + pdbATOM.append(Escape.drawQuat(q, prefix, id, ptCenter, 1f)); if (qtype == 'n' && isAmino) { P3 ptH = ((AminoMonomer) monomer) .getNitrogenHydrogenPoint(); @@ -882,7 +883,7 @@ .append(qColor[derivType]).append("\n"); continue; } - strExtra = q.getInfo() + strExtra = getQInfo(q) + Txt.sprintf(" %10.5p %10.5p %10.5p", "p", new Object[] { ptCenter }); if (qtype == 'n' && isAmino) { @@ -918,6 +919,26 @@ } } + public String drawQuat(Quat q, String prefix, String id, P3 ptCenter, + float scale) { + String strV = " VECTOR " + Escape.eP(ptCenter) + " "; + if (scale == 0) + scale = 1f; + return "draw " + prefix + "x" + id + strV + + Escape.eP(q.getVectorScaled(0, scale)) + " color red\n" + + "draw " + prefix + "y" + id + strV + + Escape.eP(q.getVectorScaled(1, scale)) + " color green\n" + + "draw " + prefix + "z" + id + strV + + Escape.eP(q.getVectorScaled(2, scale)) + " color blue\n"; + } + + private static String getQInfo(Quat q) { + A4 axis = q.toAxisAngle4f(); + return Txt.sprintf("%10.6f%10.6f%10.6f%10.6f %6.2f %10.5f %10.5f %10.5f", + "F", new Object[] { new float[] { q.q0, q.q1, q.q2, q.q3, + (float) (axis.angle * 180 / Math.PI), axis.x, axis.y, axis.z } }); + } + /** * * @param m Modified: trunk/Jmol/src/org/jmol/scriptext/CmdExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2014-03-01 23:01:24 UTC (rev 19408) +++ trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2014-03-02 23:56:22 UTC (rev 19409) @@ -2186,7 +2186,7 @@ if (isFrame) { eval.checkLast(eval.iToken); if (!chk) - eval.runScript((Quat.newP4((P4) propertyValue)).draw( + eval.runScript(Escape.drawQuat(Quat.newP4((P4) propertyValue), (thisId == null ? "frame" : thisId), " " + swidth, (center == null ? new P3() : center), intScale / 100f)); return false; @@ -2431,8 +2431,8 @@ if (propertyName != null) setShapeProperty(JC.SHAPE_DRAW, propertyName, propertyValue); } - finalizeObject(JC.SHAPE_DRAW, colorArgb[0], translucentLevel, - intScale, havePoints, connections, iptDisplayProperty, null); + finalizeObject(JC.SHAPE_DRAW, colorArgb[0], translucentLevel, intScale, + havePoints, connections, iptDisplayProperty, null); return true; } Modified: trunk/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2014-03-01 23:01:24 UTC (rev 19408) +++ trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2014-03-02 23:56:22 UTC (rev 19409) @@ -1707,8 +1707,7 @@ P4 p4 = null; switch (nArgs) { case 0: - return mp.addXPt4(Quat.newQ(viewer.getRotationQuaternion()) - .toPoint4f()); + return mp.addXPt4(Quat.newQ(viewer.getRotationQuaternion()).toPoint4f()); case 1: default: if (tok == T.quaternion && args[0].tok == T.varray) { @@ -1748,10 +1747,10 @@ return mp.addXFloat(stddev[0]); } if (args[0].tok == T.bitset && args[1].tok == T.bitset) { - Quat[] data1 = viewer.getAtomGroupQuaternions( - (BS) args[0].value, Integer.MAX_VALUE); - Quat[] data2 = viewer.getAtomGroupQuaternions( - (BS) args[1].value, Integer.MAX_VALUE); + Quat[] data1 = viewer.getAtomGroupQuaternions((BS) args[0].value, + Integer.MAX_VALUE); + Quat[] data2 = viewer.getAtomGroupQuaternions((BS) args[1].value, + Integer.MAX_VALUE); qs = Quat.div(data2, data1, nMax, isRelative); break; } @@ -1767,7 +1766,7 @@ if (args[0].tok == T.point4f) { P3 pt = (args[2].tok == T.point3f ? (P3) args[2].value : viewer .getAtomSetCenter((BS) args[2].value)); - return mp.addXStr((Quat.newP4((P4) args[0].value)).draw("q", + return mp.addXStr(Escape.drawQuat(Quat.newP4((P4) args[0].value), "q", SV.sValue(args[1]), pt, 1f)); } P3[] pts = new P3[3]; Modified: trunk/Jmol/src/org/jmol/util/Escape.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Escape.java 2014-03-01 23:01:24 UTC (rev 19408) +++ trunk/Jmol/src/org/jmol/util/Escape.java 2014-03-02 23:56:22 UTC (rev 19409) @@ -83,6 +83,19 @@ return "{" + x.x + " " + x.y + " " + x.z + " " + x.w + "}"; } + public static String drawQuat(Quat q, String prefix, String id, P3 ptCenter, + float scale) { + String strV = " VECTOR " + eP(ptCenter) + " "; + if (scale == 0) + scale = 1f; + return "draw " + prefix + "x" + id + strV + + eP(q.getVectorScaled(0, scale)) + " color red\n" + + "draw " + prefix + "y" + id + strV + + eP(q.getVectorScaled(1, scale)) + " color green\n" + + "draw " + prefix + "z" + id + strV + + eP(q.getVectorScaled(2, scale)) + " color blue\n"; + } + @SuppressWarnings("unchecked") public static String e(Object x) { if (x == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |