001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.nbio.structure.geometry; 022 023import javax.vecmath.Matrix4d; 024import javax.vecmath.Point3d; 025 026/** 027 * SuperPositions is a Class that provides static helper methods and an easy 028 * access to the whole family of {@link SuperPosition} algorithms. 029 * <p> 030 * It defines a static SuperPosition object and uses it for calculation. 031 * 032 * @author Aleix Lafita 033 * @since 5.0.0 034 * 035 */ 036public class SuperPositions { 037 038 private static SuperPositionAbstract superposer = new SuperPositionQuat( 039 false); 040 041 /** Prevent instantiation */ 042 private SuperPositions(){} 043 044 /** 045 * Use the {@link SuperPosition#superpose(Point3d[], Point3d[])} method of 046 * the default static SuperPosition algorithm contained in this Class. 047 */ 048 public static Matrix4d superpose(Point3d[] fixed, Point3d[] moved) { 049 superposer.setCentered(false); 050 return superposer.superpose(fixed, moved); 051 } 052 053 /** 054 * Use the {@link SuperPosition#superpose(Point3d[], Point3d[])} method of 055 * the default static SuperPosition algorithm contained in this Class, 056 * assuming that the point arrays are centered at the origin. 057 */ 058 public static Matrix4d superposeAtOrigin(Point3d[] fixed, Point3d[] moved) { 059 superposer.setCentered(true); 060 return superposer.superpose(fixed, moved); 061 } 062 063 /** 064 * Use the {@link SuperPosition#superposeAndTransform(Point3d[], Point3d[])} 065 * method of the default static SuperPosition algorithm contained in this 066 * Class. 067 */ 068 public static Matrix4d superposeAndTransform(Point3d[] fixed, 069 Point3d[] moved) { 070 superposer.setCentered(false); 071 return superposer.superposeAndTransform(fixed, moved); 072 } 073 074 /** 075 * Use the {@link SuperPosition#superposeAndTransform(Point3d[], Point3d[])} 076 * method of the default static SuperPosition algorithm contained in this 077 * Class, assuming that the point arrays are centered at the origin. 078 */ 079 public static Matrix4d superposeAndTransformAtOrigin(Point3d[] fixed, 080 Point3d[] moved) { 081 superposer.setCentered(true); 082 return superposer.superposeAndTransform(fixed, moved); 083 } 084 085 /** 086 * Use the {@link SuperPosition#getRmsd(Point3d[], Point3d[])} method of the 087 * default static SuperPosition algorithm contained in this Class. 088 */ 089 public static double getRmsd(Point3d[] fixed, Point3d[] moved) { 090 superposer.setCentered(false); 091 return superposer.getRmsd(fixed, moved); 092 } 093 094 /** 095 * Use the {@link SuperPosition#getRmsd(Point3d[], Point3d[])} method of the 096 * default static SuperPosition algorithm contained in this Class, assuming 097 * that the point arrays are centered at the origin. 098 */ 099 public static double getRmsdAtOrigin(Point3d[] fixed, Point3d[] moved) { 100 superposer.setCentered(true); 101 return superposer.getRmsd(fixed, moved); 102 } 103 104 public static void setDefaultSuperPosition(SuperPositionAbstract defaultAlgorithm) { 105 superposer = defaultAlgorithm; 106 } 107}