RDKit
Open-source cheminformatics and machine learning.
Transform3D.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005-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_TRANSFORM3D_H__
12 #define __RD_TRANSFORM3D_H__
13 
14 #include "Transform.h"
15 
16 #include <Numerics/SquareMatrix.h>
17 
18 namespace RDGeom {
19 class Point3D;
20 const unsigned int DIM_3D = 4;
21 
23  public:
24  //! Constructor
25  /*!
26  Initialize to an identity matrix transformation.
27  This is a 4x4 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 
40  Transform3D() : RDNumeric::SquareMatrix<double>(DIM_3D, 0.0) {
41  unsigned int i, id;
42  for (i = 0; i < DIM_3D; i++) {
43  id = i * (DIM_3D + 1);
44  d_data[id] = 1.0;
45  }
46  }
47 
48  void setToIdentity();
49 
50  void TransformPoint(Point3D &pt) const;
51 
52  /*! \brief Set the translation vector
53  */
54  void SetTranslation(const Point3D &move);
55 
56  /*! \brief set the rotation matrix
57  *
58  * The rotation matrix is set to rotation by th specified angle
59  * about the specified axis
60  */
61  void SetRotation(double angle, AxisType axis);
62 
63  /*! \brief set the rotation matrix
64  *
65  * The rotation matrix is set to rotation by th specified angle
66  * about an arbitrary axis
67  */
68  void SetRotation(double angle, const Point3D &axis);
69  void SetRotation(double cosT, double sinT, const Point3D &axis);
70 
71  //! Set the rotation matrix from a quaternion
72  void SetRotationFromQuaternion(double quaternion[4]);
73 
74  //! Reflect the rotation
75  void Reflect();
76 
77  private:
78 };
79 }
80 
81 /*! \brief Combine two transforms and return the results as a new transform
82  *
83  * The order is important here, on two transforms t1 and t2
84  * t3 = t1*t2
85  * The resulting transform t3 has the folliwng effect
86  * t3(point) = t1(t2(point))
87  */
89  const RDGeom::Transform3D &t2);
90 
91 /*! \brief Transform a point:
92  *
93  */
95  const RDGeom::Point3D &pt);
96 
97 #endif
#define RDKIT_RDGEOMETRYLIB_EXPORT
Definition: export.h:502
AxisType
Definition: Transform.h:16
Transform3D()
Constructor.
Definition: Transform3D.h:40
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator*(const RDGeom::Point3D &p1, double v)
const unsigned int DIM_3D
Definition: Transform3D.h:20