RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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"
16
17namespace RDGeom {
18class Point2D;
19const 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 for (unsigned int i = 0; i < DIM_2D; i++) {
41 unsigned int id = i * (DIM_2D + 1);
42 d_data[id] = 1.0;
43 }
44 }
45
47
48 void TransformPoint(Point2D &pt) const;
49
50 void SetTranslation(const Point2D &pt);
51
52 /*! \brief Set the transform so that the specified points are aligned
53 *
54 * The resulting transformation 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 by which to rotate, in radians
67 */
68 void SetTransform(const Point2D &pt, double angle);
69
70 private:
71};
72} // namespace RDGeom
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 &t1, const RDGeom::Transform2D &t2);
83
84#endif
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.
void TransformPoint(Point2D &pt) const
void SetTranslation(const Point2D &pt)
void SetTransform(const Point2D &ref1, const Point2D &ref2, const Point2D &pt1, const Point2D &pt2)
Set the transform so that the specified points are aligned.
Transform2D()
Constructor.
Definition Transform2D.h:39
void SetTransform(const Point2D &pt, double angle)
Set the trans form to counterclock wise rotation by the specified value around point.
#define RDKIT_RDGEOMETRYLIB_EXPORT
Definition export.h:409
const unsigned int DIM_2D
Definition Transform2D.h:19