public virtual void calcProteinMainchainHydrogenBonds(BitArray bsA, BitArray bsB) { Point3f carbonPoint; Point3f oxygenPoint; for (int i = 0; i < monomerCount; ++i) { AminoMonomer residue = (AminoMonomer)monomers[i]; mainchainHbondOffsets[i] = 0; /**************************************************************** * This does not acount for the first nitrogen in the chain * is there some way to predict where it's hydrogen is? * mth 20031219 ****************************************************************/ if (i > 0 && residue.GroupID != JmolConstants.GROUPID_PROLINE) { Point3f nitrogenPoint = residue.NitrogenAtomPoint; aminoHydrogenPoint.add(nitrogenPoint, vectorPreviousOC); bondAminoHydrogen(i, aminoHydrogenPoint, bsA, bsB); } carbonPoint = residue.CarbonylCarbonAtomPoint; oxygenPoint = residue.CarbonylOxygenAtomPoint; vectorPreviousOC.sub(carbonPoint, oxygenPoint); vectorPreviousOC.scale(1 / vectorPreviousOC.length()); } }
/// <summary>************************************************************* /// see: /// Defining the Axis of a Helix /// Peter C Kahn /// Computers Chem. Vol 13, No 3, pp 185-189, 1989 /// /// Simple Methods for Computing the Least Squares Line /// in Three Dimensions /// Peter C Kahn /// Computers Chem. Vol 13, No 3, pp 191-195, 1989 /// ************************************************************** /// </summary> public virtual void calcCenter() { if (center == null) { int i = monomerIndex + monomerCount - 1; center = new Point3f(apolymer.getLeadPoint(i)); while (--i >= monomerIndex) { center.add(apolymer.getLeadPoint(i)); } center.scale(1f / monomerCount); // System.out.println("structure center is at :" + center); } }
public virtual void getLeadMidPoint(int groupIndex, Point3f midPoint) { if (groupIndex == monomerCount) { --groupIndex; } else if (groupIndex > 0) { midPoint.set_Renamed(getLeadPoint(groupIndex)); midPoint.add(getLeadPoint(groupIndex - 1)); midPoint.scale(0.5f); return; } midPoint.set_Renamed(getLeadPoint(groupIndex)); }
public virtual void renderAngle(Atom atomA, Atom atomB, Atom atomC, short colix, bool renderArcs) { /* * if (! (atomA.isVisible() && atomB.isVisible() && atomC.isVisible())) * return; */ if (displayModelIndex >= 0 && (displayModelIndex != atomA.modelIndex || displayModelIndex != atomB.modelIndex || displayModelIndex != atomC.modelIndex)) { return; } //g3d.setColix(colix); int zA = atomA.ScreenZ - atomA.ScreenD - 10; int zB = atomB.ScreenZ - atomB.ScreenD - 10; int zC = atomC.ScreenZ - atomC.ScreenD - 10; int zOffset = (zA + zB + zC) / 3; int radius = drawSegment(atomA.ScreenX, atomA.ScreenY, zA, atomB.ScreenX, atomB.ScreenY, zB, colix); radius += drawSegment(atomB.ScreenX, atomB.ScreenY, zB, atomC.ScreenX, atomC.ScreenY, zC, colix); radius = (radius + 1) / 2; if (!renderArcs) { return; } // FIXME mth -- this really should be a function of pixelsPerAngstrom // in addition, the location of the arc is not correct // should probably be some percentage of the smaller distance AxisAngle4f aa = measurement.aa; if (aa == null) { // 180 degrees paintMeasurementString(atomB.ScreenX + 5, atomB.ScreenY - 5, zB, radius, colix); return; } int dotCount = (int)((aa.angle / (2 * System.Math.PI)) * 64); float stepAngle = aa.angle / dotCount; aaT.set_Renamed(aa); int iMid = dotCount / 2; for (int i = dotCount; --i >= 0;) { aaT.angle = i * stepAngle; matrixT.set_Renamed(aaT); pointT.set_Renamed(measurement.pointArc); matrixT.transform(pointT); pointT.add(atomB.point3f); //Point3i screenArc = viewer.transformPoint(pointT); //int zArc = screenArc.z - zOffset; //if (zArc < 0) // zArc = 0; //g3d.drawPixel(screenArc.x, screenArc.y, zArc); //if (i == iMid) //{ // pointT.set_Renamed(measurement.pointArc); // pointT.scale(1.1f); // matrixT.transform(pointT); // pointT.add(atomB.point3f); // Point3i screenLabel = viewer.transformPoint(pointT); // int zLabel = screenLabel.z - zOffset; // paintMeasurementString(screenLabel.x, screenLabel.y, zLabel, radius, colix); //} } }
public void calcLeadMidpointsAndWingVectors() { // System.out.println("Polymer.calcLeadMidpointsAndWingVectors"); int count = monomerCount; leadMidpoints = new Point3f[count + 1]; wingVectors = new Vector3f[count + 1]; bool _hasWingPoints = hasWingPoints(); Vector3f vectorA = new Vector3f(); Vector3f vectorB = new Vector3f(); Vector3f vectorC = new Vector3f(); Vector3f vectorD = new Vector3f(); Point3f leadPointPrev, leadPoint; leadMidpoints[0] = InitiatorPoint; leadPoint = getLeadPoint(0); Vector3f previousVectorD = null; for (int i = 1; i < count; ++i) { leadPointPrev = leadPoint; leadPoint = getLeadPoint(i); Point3f midpoint = new Point3f(leadPoint); midpoint.add(leadPointPrev); midpoint.scale(0.5f); leadMidpoints[i] = midpoint; if (_hasWingPoints) { vectorA.sub(leadPoint, leadPointPrev); vectorB.sub(leadPointPrev, getWingPoint(i - 1)); vectorC.cross(vectorA, vectorB); vectorD.cross(vectorA, vectorC); vectorD.normalize(); if (previousVectorD != null && previousVectorD.angle(vectorD) > System.Math.PI / 2) { vectorD.scale(-1); } previousVectorD = wingVectors[i] = new Vector3f(vectorD); } } leadMidpoints[count] = TerminatorPoint; if (!_hasWingPoints) { if (count < 3) { wingVectors[1] = unitVectorX; } else { // auto-calculate wing vectors based upon lead atom positions only // seems to work like a charm! :-) Point3f next, current, prev; prev = leadMidpoints[0]; current = leadMidpoints[1]; Vector3f previousVectorC = null; for (int i = 1; i < count; ++i) { next = leadMidpoints[i + 1]; vectorA.sub(prev, current); vectorB.sub(next, current); vectorC.cross(vectorA, vectorB); vectorC.normalize(); if (previousVectorC != null && previousVectorC.angle(vectorC) > System.Math.PI / 2) { vectorC.scale(-1); } previousVectorC = wingVectors[i] = new Vector3f(vectorC); prev = current; current = next; } } } wingVectors[0] = wingVectors[1]; wingVectors[count] = wingVectors[count - 1]; /* * for (int i = 0; i < wingVectors.length; ++i) { * if (wingVectors[i] == null) { * System.out.println("que? wingVectors[" + i + "] == null?"); * System.out.println("hasWingPoints=" + hasWingPoints + * " wingVectors.length=" + wingVectors.length + * " count=" + count); * * } * else if (Float.isNaN(wingVectors[i].x)) { * System.out.println("wingVectors[" + i + "]=" + wingVectors[i]); * } * } */ }