RDKit: Transform2D.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
30 gets set to
31 the combination other and the current state of this transform
32 If this_old and this_new are the states of this object before and after this
33 function
34 we have
35 this_new(point) = this_old(other(point))
36 */
37 Transform2D() : RDNumeric::SquareMatrix<double>(DIM_2D, 0.0) {
38 unsigned int i, id;
39 for (i = 0; i < DIM_2D; i++) {
40 id = i * (DIM_2D + 1);
41 d_data[id] = 1.0;
42 }
43 }
44
45 void setToIdentity();
46
47 void TransformPoint(Point2D &pt) const;
48
49 void SetTranslation(const Point2D &pt);
50
51 /*! \brief Set the tranform so that the specified points are aligned
52 *
53 * The resulting tranformation will align pt1 with ref1, and rotation
54 * pt2 such that the line betweem (pt1, pt2) will align with
55 * with the line (ref1, ref2)
56 */
57 void SetTransform(const Point2D &ref1, const Point2D &ref2,
58 const Point2D &pt1, const Point2D &pt2);
59
60 /*! \brief Set the trans form to counterclock wise rotation by the specified
61 *value around point
62 *
63 * ARGUMENTS:
64 * - pt : point about which to rotate
65 * - angle : the angle byt which to rotate
66 */
67 void SetTransform(const Point2D &pt, double angle);
68
69 private:
70 };
71 }
72
73 /*! \brief Combine two transforms and return the results as a new transform
74 *
75 * The order is important here, on two transforms t1 and t2
76 * t3 = t1*t2
77 * The resulting transform t3 has the folliwng effect
78 * t3(point) = t1(t2(point))
79 */
80 RDGeom::Transform2D operator*(const RDGeom::Transform2D &t1,
81 const RDGeom::Transform2D &t2);
82
83 #endif
RDNumeric::Matrix< double >::d_data
DATA_SPTR d_data
Definition: Matrix.h:235
SquareMatrix.h
RDNumeric
Definition: AlignPoints.h:17
RDGeom::Transform2D::SetTransform
void SetTransform(const Point2D &ref1, const Point2D &ref2, const Point2D &pt1, const Point2D &pt2)
Set the tranform so that the specified points are aligned.
RDGeom::Transform2D
Definition: Transform2D.h:20
RDGeom::Transform2D::Transform2D
Transform2D()
Constructor.
Definition: Transform2D.h:37
RDGeom::Point2D
Definition: point.h:254
RDNumeric::SquareMatrix< double >::SquareMatrix
SquareMatrix()
brief Square matrix of size N
Definition: SquareMatrix.h:20
Transform.h
RDNumeric::SquareMatrix
Definition: SquareMatrix.h:17
RDGeom::DIM_2D
const unsigned int DIM_2D
Definition: Transform2D.h:18
RDGeom::Transform2D::setToIdentity
void setToIdentity()
RDGeom
Definition: TorsionAngleM6.h:19
RDGeom::Transform2D::SetTranslation
void SetTranslation(const Point2D &pt)
RDGeom::Transform2D::TransformPoint
void TransformPoint(Point2D &pt) const
operator*
RDGeom::Transform2D operator*(const RDGeom::Transform2D &t1, const RDGeom::Transform2D &t2)
Combine two transforms and return the results as a new transform.