/** * Handle cases with small angles of rotation * @param rotation * @param translation */ private void calculateTranslationalAxis(Matrix rotation, Atom translation) { // set axis parallel to translation rotationAxis = Calc.scale(translation, 1./Calc.amount(translation)); // position is undefined rotationPos = null; screwTranslation = translation; otherTranslation = new AtomImpl(); otherTranslation.setCoords(new double[] {0,0,0}); }
Atom centerOnAxis = Calc.scale(rotationAxis, Calc.scalarProduct(center, rotationAxis));
screwTranslation = Calc.scale(rotationAxis, dotProduct); otherTranslation = Calc.subtract(translation, screwTranslation);
/** * Projects a given point onto the axis of rotation * @param point * @return An atom which lies on the axis, or null if the RotationAxis is purely translational */ public Atom getProjectedPoint(Atom point) { if(rotationPos == null) { // translation only return null; } Atom localPoint = Calc.subtract(point, rotationPos); double dot = Calc.scalarProduct(localPoint, rotationAxis); Atom localProjected = Calc.scale(rotationAxis, dot); Atom projected = Calc.add(localProjected, rotationPos); return projected; }