From: <ha...@us...> - 2009-08-17 15:54:42
|
Revision: 11322 http://jmol.svn.sourceforge.net/jmol/?rev=11322&view=rev Author: hansonr Date: 2009-08-17 15:54:32 +0000 (Mon, 17 Aug 2009) Log Message: ----------- version=11.8.RC6_dev # new features for the 238th American Chemical Society National Meeting, Washington, D.C., Aug. 19, 2009 Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelsetbio/Monomer.java trunk/Jmol/src/org/jmol/util/Measure.java trunk/Jmol/src/org/jmol/viewer/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/viewer/Token.java Modified: trunk/Jmol/src/org/jmol/modelsetbio/Monomer.java =================================================================== --- trunk/Jmol/src/org/jmol/modelsetbio/Monomer.java 2009-08-16 17:52:26 UTC (rev 11321) +++ trunk/Jmol/src/org/jmol/modelsetbio/Monomer.java 2009-08-17 15:54:32 UTC (rev 11322) @@ -26,7 +26,6 @@ import org.jmol.modelset.Atom; import org.jmol.modelset.Chain; import org.jmol.modelset.Group; -import org.jmol.util.Escape; import org.jmol.util.Logger; import org.jmol.util.Measure; import org.jmol.util.Quaternion; @@ -36,7 +35,6 @@ import java.util.Hashtable; import java.util.BitSet; import javax.vecmath.Point3f; -import javax.vecmath.Tuple3f; public abstract class Monomer extends Group { @@ -338,19 +336,8 @@ return super.getHelixData(tokType, qType, mStep); Point3f a = (mStep < 1 ? new Point3f(0, 0, 0) : (Point3f) prev.getQuaternionFrameCenter(qType)); Point3f b = getQuaternionFrameCenter(qType); - Object ret = Measure.computeHelicalAxis(tokType == Token.draw ? "helixaxis" + getUniqueID() : null, - tokType, (Point3f) a, (Point3f) b, q1, q2); - if (!(ret instanceof Object[])) - return ret; - Object[] o = (Object[])ret; - return new String[] { - Escape.escape((Tuple3f)o[0]), // a' - Escape.escape((Tuple3f)o[1]), // n - Escape.escape((Tuple3f)o[2]), // r - "" + o[3], // theta (degrees) - "" + o[4], // pitch - "" + o[5], // residuesPerTurn - }; + return Measure.computeHelicalAxis(tokType == Token.draw ? "helixaxis" + getUniqueID() : null, + tokType, (Point3f) a, (Point3f) b, q2.div(q1)); } public void resetHydrogenPoint() { Modified: trunk/Jmol/src/org/jmol/util/Measure.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Measure.java 2009-08-16 17:52:26 UTC (rev 11321) +++ trunk/Jmol/src/org/jmol/util/Measure.java 2009-08-17 15:54:32 UTC (rev 11322) @@ -91,7 +91,7 @@ } public static Object computeHelicalAxis(String id, int tokType, Point3f a, Point3f b, - Quaternion q1, Quaternion q2) { + Quaternion dq) { /* b | /| @@ -120,17 +120,21 @@ aa.y = vab.y; aa.z = vab.z; boolean asdirected = false; - Quaternion dq = q2.div(q1); float theta = (asdirected ? dq.getThetaDirected(aa).w : dq.getTheta());// .Directed(aa).w; Vector3f n = (asdirected ? dq.getNormalDirected(vab) : dq.getNormal());// Directed(vab); aa.x = vab.x; aa.y = vab.y; aa.z = vab.z; float v_dot_n = vab.dot(n); + if (Math.abs(v_dot_n) < 0.0001f) + v_dot_n = 0; if (tokType == Token.axis) { - n.scale(v_dot_n); + if (v_dot_n != 0) + n.scale(v_dot_n); return n; } + if (v_dot_n == 0) + v_dot_n = Float.MIN_VALUE; // allow for perpendicular axis to vab Vector3f vcb = new Vector3f(n); vcb.scale(v_dot_n); Vector3f va_prime_d = new Vector3f(); @@ -139,10 +143,11 @@ Vector3f vda = new Vector3f(); vda.sub(vcb, vab); vda.scale(0.5f); - va_prime_d.scale((float) (vda.length() / Math + va_prime_d.scale(theta == 0 ? 0 : (float) (vda.length() / Math .tan(theta / 2 / 180 * Math.PI))); Vector3f r = new Vector3f(va_prime_d); - r.add(vda); + if (theta != 0) + r.add(vda); if (tokType == Token.radius) return r; Point3f pt_a_prime = new Point3f(a); @@ -150,11 +155,14 @@ if (tokType == Token.point) { return pt_a_prime; } - n.scale(v_dot_n); + if (v_dot_n != Float.MIN_VALUE) + n.scale(v_dot_n); // must calculate directed angle: Point3f pt_b_prime = new Point3f(pt_a_prime); pt_b_prime.add(n); theta = computeTorsion(a, pt_a_prime, pt_b_prime, b, true); + if (Float.isNaN(theta)) + theta = (float) (dq.getTheta() / 180 * Math.PI); // allow for r = 0 if (tokType == Token.angle) return new Float(theta); if (tokType == Token.draw) { @@ -167,9 +175,19 @@ return s; } // for now... array: - float residuesPerTurn = 360f / theta; - float pitch = Math.abs(n.length() * residuesPerTurn); - return new Object[] {pt_a_prime, n, r, new Float(theta), new Float(pitch), new Float(residuesPerTurn)}; + float residuesPerTurn = (theta == 0 ? 0 : 360f / theta); + float pitch = Math.abs(v_dot_n == Float.MIN_VALUE ? 0 : n.length() * theta / 360f); + Object[] ret = new Object[] {pt_a_prime, n, r, new Point3f(theta, pitch, residuesPerTurn)}; + if (tokType == Token.array) + return ret; + else if (tokType == Token.list) + return new String[] { + Escape.escape(pt_a_prime), // a' + Escape.escape(n), // n + Escape.escape(r), // r + Escape.escape(new Point3f(theta /*(degrees)*/,pitch, residuesPerTurn)) + }; + return null; } } Modified: trunk/Jmol/src/org/jmol/viewer/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ScriptMathProcessor.java 2009-08-16 17:52:26 UTC (rev 11321) +++ trunk/Jmol/src/org/jmol/viewer/ScriptMathProcessor.java 2009-08-17 15:54:32 UTC (rev 11322) @@ -696,33 +696,66 @@ return addX(sout); } - private boolean evaluateHelix(ScriptVariable[] args) { + private boolean evaluateHelix(ScriptVariable[] args) throws ScriptException { if (args.length < 1) return false; - BitSet bs = (args[0].value instanceof BitSet ? (BitSet) args[0].value - : eval.compareInt(Token.resno, null, Token.opEQ, ScriptVariable.iValue(args[0]))); - String type = (args.length == 1 ? "array" : ScriptVariable.sValue(args[1])) - .toLowerCase(); - if (type.equals("point")) - return addX(isSyntaxCheck ? new Point3f() : (Point3f) viewer - .getHelixData(bs, Token.point)); - if (type.equals("axis")) - return addX(isSyntaxCheck ? new Vector3f() : (Vector3f) viewer - .getHelixData(bs, Token.axis)); - if (type.equals("radius")) - return addX(isSyntaxCheck ? new Vector3f() : (Vector3f) viewer - .getHelixData(bs, Token.radius)); - if (type.equals("angle")) - return addX(isSyntaxCheck ? 0 : ((Float) viewer - .getHelixData(bs, Token.angle)).floatValue()); - if (type.equals("draw")) - return addX(isSyntaxCheck ? "" : (String) viewer - .getHelixData(bs, Token.draw)); - if (type.equals("array")) { - String[] data = (String[]) viewer.getHelixData(bs, Token.array); - if (data == null) + // helix({resno=3}) + // helix({resno=3},"point|axis|radius|angle|draw|array") + // helix(resno,"point|axis|radius|angle|draw|array") + // helix(pt1, pt2, dq, "point|axis|radius|angle|array|[someID]") + // helix(pt1, pt2, dq) + int pt = (args.length > 2 ? 3 : 1); + String type = (pt >= args.length ? "array" : ScriptVariable + .sValue(args[pt])).toLowerCase(); + Token t = Token.getTokenFromName(type); + if (args.length > 2) { + Point3f pta = ptValue(args[0]); + Point3f ptb = ptValue(args[1]); + if (args[2].tok != Token.point4f) return false; - return addX(data); + Quaternion dq = new Quaternion((Point4f) args[2].value); + switch (t == null ? Token.nada : t.tok) { + case Token.nada: + break; + case Token.point: + case Token.axis: + case Token.radius: + case Token.angle: + return addX(Measure.computeHelicalAxis(null, t.tok, pta, ptb, dq)); + case Token.array: + String[] data = (String[]) Measure.computeHelicalAxis(null, Token.list, pta, ptb, dq); + if (data == null) + return false; + return addX(data); + default: + return addX(Measure.computeHelicalAxis(type, Token.draw, pta, ptb, dq)); + } + } else { + BitSet bs = (args[0].value instanceof BitSet ? (BitSet) args[0].value + : eval.compareInt(Token.resno, null, Token.opEQ, ScriptVariable + .iValue(args[0]))); + switch (t == null ? Token.nada : t.tok) { + case Token.point: + return addX(isSyntaxCheck ? new Point3f() : (Point3f) viewer + .getHelixData(bs, Token.point)); + case Token.axis: + return addX(isSyntaxCheck ? new Vector3f() : (Vector3f) viewer + .getHelixData(bs, Token.axis)); + case Token.radius: + return addX(isSyntaxCheck ? new Vector3f() : (Vector3f) viewer + .getHelixData(bs, Token.radius)); + case Token.angle: + return addX(isSyntaxCheck ? 0 : ((Float) viewer.getHelixData(bs, + Token.angle)).floatValue()); + case Token.draw: + return addX(isSyntaxCheck ? "" : (String) viewer.getHelixData(bs, + Token.draw)); + case Token.array: + String[] data = (String[]) viewer.getHelixData(bs, Token.list); + if (data == null) + return false; + return addX(data); + } } return false; } Modified: trunk/Jmol/src/org/jmol/viewer/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Token.java 2009-08-16 17:52:26 UTC (rev 11321) +++ trunk/Jmol/src/org/jmol/viewer/Token.java 2009-08-17 15:54:32 UTC (rev 11322) @@ -74,7 +74,7 @@ final static int decimal = 3; final public static int string = 4; final static int seqcode = 5; - final static int list = 6; + public final static int list = 6; final public static int point3f = 7; final public static int point4f = 8; final private static int keyword = 9; @@ -590,13 +590,12 @@ final static int trim = 6 | 1 << 9 | mathfunc | mathproperty; // xxx(a,b) - + public final static int cross = 1 | 2 << 9 | mathfunc; - public final static int helix = 2 | 2 << 9 | mathfunc | predefinedset; - final static int load = 3 | 2 << 9 | mathfunc | command; - final static int random = 4 | 2 << 9 | mathfunc; - final static int script = 5 | 2 << 9 | mathfunc | command; - public final static int symop = 6 | 2 << 9 | mathfunc | intproperty; + final static int load = 2 | 2 << 9 | mathfunc | command; + final static int random = 3 | 2 << 9 | mathfunc; + final static int script = 4 | 2 << 9 | mathfunc | command; + public final static int symop = 5 | 2 << 9 | mathfunc | intproperty; // ___.xxx(a,b) @@ -621,12 +620,13 @@ // xxx(a,b,c,d) - public final static int angle = 1 | 4 << 9 | mathfunc; + public final static int angle = 1 | 4 << 9 | mathfunc; public final static int data = 2 | 4 << 9 | mathfunc | command; - final static int plane = 3 | 4 << 9 | mathfunc; - public final static int point = 4 | 4 << 9 | mathfunc; - final static int quaternion = 5 | 4 << 9 | mathfunc | command; - final static int axisangle = 6 | 4 << 9 | mathfunc; + public final static int helix = 3 | 4 << 9 | mathfunc | predefinedset; + final static int plane = 4 | 4 << 9 | mathfunc; + public final static int point = 5 | 4 << 9 | mathfunc; + final static int quaternion = 6 | 4 << 9 | mathfunc | command; + final static int axisangle = 7 | 4 << 9 | mathfunc; // xxx(a,b,c,d,e) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |