RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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
17
18namespace RDGeom {
19class Point3D;
20const unsigned int DIM_3D = 4;
21
23 : public RDNumeric::SquareMatrix<double> {
24 public:
25 //! Constructor
26 /*!
27 Initialize to an identity matrix transformation.
28 This is a 4x4 matrix that includes the rotation and translation parts
29 see Foley's "Introduction to Computer Graphics" for the representation
30
31 Operator *= and = are provided by the parent class square matrix.
32 Operator *= needs some explanation, since the order matters. This transform
33 gets set to
34 the combination other and the current state of this transform
35 If this_old and this_new are the states of this object before and after this
36 function
37 we have
38 this_new(point) = this_old(other(point))
39 */
40
41 Transform3D() : RDNumeric::SquareMatrix<double>(DIM_3D, 0.0) {
42 unsigned int i, id;
43 for (i = 0; i < DIM_3D; i++) {
44 id = i * (DIM_3D + 1);
45 d_data[id] = 1.0;
46 }
47 }
48
50
51 void TransformPoint(Point3D &pt) const;
52
53 /*! \brief Set the translation vector
54 */
55 void SetTranslation(const Point3D &move);
56
57 /*! \brief set the rotation matrix
58 *
59 * The rotation matrix is set to rotation by the specified angle
60 * about the specified axis
61 */
62 void SetRotation(double angle, AxisType axis);
63
64 /*! \brief set the rotation matrix
65 *
66 * The rotation matrix is set to rotation by the specified angle
67 * about an arbitrary axis.
68 * Note: if the axis is not a unit vector scaling will also occur.
69 * This can be ensured by a call to Point3D#normalize() prior to calling
70 * this method
71 */
72 void SetRotation(double angle, const Point3D &axis);
73 void SetRotation(double cosT, double sinT, const Point3D &axis);
74
75 //! Set the rotation matrix from a quaternion
76 void SetRotationFromQuaternion(double quaternion[4]);
77
78 //! Reflect the rotation
79 void Reflect();
80
81 private:
82};
83} // namespace RDGeom
84
85/*! \brief Combine two transforms and return the results as a new transform
86 *
87 * The order is important here, on two transforms t1 and t2
88 * t3 = t1*t2
89 * The resulting transform t3 has the folliwng effect
90 * t3(point) = t1(t2(point))
91 */
93 const RDGeom::Transform3D &t1, const RDGeom::Transform3D &t2);
94
95/*! \brief Transform a point:
96 *
97 */
99 const RDGeom::Transform3D &t, const RDGeom::Point3D &pt);
100
101#endif
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Transform3D operator*(const RDGeom::Transform3D &t1, const RDGeom::Transform3D &t2)
Combine two transforms and return the results as a new transform.
void SetTranslation(const Point3D &move)
Set the translation vector.
Transform3D()
Constructor.
Definition Transform3D.h:41
void SetRotation(double angle, AxisType axis)
set the rotation matrix
void SetRotationFromQuaternion(double quaternion[4])
Set the rotation matrix from a quaternion.
void Reflect()
Reflect the rotation.
void TransformPoint(Point3D &pt) const
void SetRotation(double cosT, double sinT, const Point3D &axis)
void SetRotation(double angle, const Point3D &axis)
set the rotation matrix
#define RDKIT_RDGEOMETRYLIB_EXPORT
Definition export.h:393
const unsigned int DIM_3D
Definition Transform3D.h:20