RDKit
Open-source cheminformatics and machine learning.
Transform2D.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2006 Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #include <RDGeneral/export.h>
11 #ifndef __RD_TRANSFORM2D_H__
12 #define __RD_TRANSFORM2D_H__
13 
14 #include "Transform.h"
15 #include <Numerics/SquareMatrix.h>
16 
17 namespace RDGeom {
18 class Point2D;
19 const unsigned int DIM_2D = 3;
20 
22  public:
23  //! \brief Constructor
24  /*!
25  Initialize to an identity matrix transformation
26  This is a 3x3 matrix that includes the rotation and translation parts
27  see Foley's "Introduction to Computer Graphics" for the representation
28 
29  Operator *= and = are provided by the parent class square matrix.
30  Operator *= needs some explanation, since the order matters. This transform
31  gets set to
32  the combination other and the current state of this transform
33  If this_old and this_new are the states of this object before and after this
34  function
35  we have
36  this_new(point) = this_old(other(point))
37  */
38  Transform2D() : RDNumeric::SquareMatrix<double>(DIM_2D, 0.0) {
39  unsigned int i, id;
40  for (i = 0; i < DIM_2D; i++) {
41  id = i * (DIM_2D + 1);
42  d_data[id] = 1.0;
43  }
44  }
45 
46  void setToIdentity();
47 
48  void TransformPoint(Point2D &pt) const;
49 
50  void SetTranslation(const Point2D &pt);
51 
52  /*! \brief Set the tranform so that the specified points are aligned
53  *
54  * The resulting tranformation will align pt1 with ref1, and rotation
55  * pt2 such that the line betweem (pt1, pt2) will align with
56  * with the line (ref1, ref2)
57  */
58  void SetTransform(const Point2D &ref1, const Point2D &ref2,
59  const Point2D &pt1, const Point2D &pt2);
60 
61  /*! \brief Set the trans form to counterclock wise rotation by the specified
62  *value around point
63  *
64  * ARGUMENTS:
65  * - pt : point about which to rotate
66  * - angle : the angle byt which to rotate
67  */
68  void SetTransform(const Point2D &pt, double angle);
69 
70  private:
71 };
72 }
73 
74 /*! \brief Combine two transforms and return the results as a new transform
75  *
76  * The order is important here, on two transforms t1 and t2
77  * t3 = t1*t2
78  * The resulting transform t3 has the folliwng effect
79  * t3(point) = t1(t2(point))
80  */
82  const RDGeom::Transform2D &t2);
83 
84 #endif
#define RDKIT_RDGEOMETRYLIB_EXPORT
Definition: export.h:502
Transform2D()
Constructor.
Definition: Transform2D.h:38
const unsigned int DIM_2D
Definition: Transform2D.h:19
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator*(const RDGeom::Point3D &p1, double v)