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