Example #1
0
 /// <summary>  Translates the geometric 2DCenter of the given
 /// AtomContainer container to the specified Point2d p.
 /// 
 /// </summary>
 /// <param name="container"> AtomContainer which should be translated.
 /// </param>
 /// <param name="p">         New Location of the geometric 2D Center.
 /// </param>
 /// <seealso cref="get2DCenter">
 /// </seealso>
 /// <seealso cref="translate2DCentreOfMassTo">
 /// </seealso>
 public static void translate2DCenterTo(IAtomContainer container, Point2d p)
 {
     Point2d com = get2DCenter(container);
     Vector2d translation = new Vector2d(p.x - com.x, p.y - com.y);
     IAtom[] atoms = container.Atoms;
     for (int i = 0; i < atoms.Length; i++)
     {
         if (atoms[i].getPoint2d() != null)
         {
             atoms[i].getPoint2d().add(translation);
         }
     }
 }
Example #2
0
 /// <summary>  Translates a molecule from the origin to a new point denoted by a vector.
 /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
 /// 
 /// </summary>
 /// <param name="atomCon"> molecule to be translated
 /// </param>
 /// <param name="vector">  dimension that represents the translation vector
 /// </param>
 public static void translate2D(IAtomContainer atomCon, Vector2d vector)
 {
     IAtom[] atoms = atomCon.Atoms;
     for (int i = 0; i < atoms.Length; i++)
     {
         if (atoms[i].getPoint2d() != null)
         {
             atoms[i].getPoint2d().add(vector);
         }
         else
         {
             //logger.warn("Could not translate atom in 2D space");
         }
     }
 }
Example #3
0
 /// <summary>  Translates a molecule from the origin to a new point denoted by a vector, using an external set of coordinates.
 /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
 /// 
 /// </summary>
 /// <param name="atomCon"> molecule to be translated
 /// </param>
 /// <param name="vector">  dimension that represents the translation vector
 /// </param>
 /// <param name="renderingCoordinates"> The set of coordinates to use coming from RendererModel2D
 /// </param>
 //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
 public static void translate2D(IAtomContainer atomCon, Vector2d vector, System.Collections.Hashtable renderingCoordinates)
 {
     IAtom[] atoms = atomCon.Atoms;
     for (int i = 0; i < atoms.Length; i++)
     {
         //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
         if (renderingCoordinates[atoms[i]] == null && atoms[i].getPoint2d() != null)
         {
             renderingCoordinates[atoms[i]] = new Point2d(atoms[i].getPoint2d().x, atoms[i].getPoint2d().y);
         }
         //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
         if (((Point2d)renderingCoordinates[atoms[i]]) != null)
         {
             //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
             ((Point2d)renderingCoordinates[atoms[i]]).add(vector);
         }
         else
         {
             //logger.warn("Could not translate atom in 2D space");
         }
     }
 }
Example #4
0
        /// <summary>  Determines the normalized vector orthogonal on the vector p1->p2.
        /// 
        /// </summary>
        /// <param name="p1"> Description of the Parameter
        /// </param>
        /// <param name="p2"> Description of the Parameter
        /// </param>
        /// <returns>     Description of the Return Value
        /// </returns>
        public static Vector2d calculatePerpendicularUnitVector(Point2d p1, Point2d p2)
        {
            Vector2d v = new Vector2d();
            v.sub(p2, p1);
            v.normalize();

            // Return the perpendicular vector
            return new Vector2d((-1.0) * v.y, v.x);
        }
Example #5
0
		/// <summary> Constructs and initializes a Vector2f from the specified Vector2d.</summary>
		/// <param name="v1">the Vector2f containing the initialization x y data
		/// </param>
		public Vector2f(Vector2d v1):base(v1)
		{
		}
Example #6
0
		/// <summary> Returns the angle in radians between this vector and
		/// the vector parameter; the return value is constrained to the
		/// range [0,PI].
		/// </summary>
		/// <param name="v1"> the other vector
		/// </param>
		/// <returns> the angle in radians in the range [0,PI]
		/// </returns>
		public double angle(Vector2d v1)
		{
			// stabler than acos
			return System.Math.Abs(System.Math.Atan2(x * v1.y - y * v1.x, dot(v1)));
		}
Example #7
0
		/// <summary> Sets the value of this vector to the normalization of vector v1.</summary>
		/// <param name="v1">the un-normalized vector
		/// </param>
		public void  normalize(Vector2d v1)
		{
			set_Renamed(v1);
			normalize();
		}
Example #8
0
		/// <summary> Computes the dot product of the this vector and vector v1.</summary>
		/// <param name="v1">the other vector
		/// </param>
		public double dot(Vector2d v1)
		{
			return x * v1.x + y * v1.y;
		}