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