Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SbDPRotation.h
1 #ifndef COIN_SBDPROTATION_H
2 #define COIN_SBDPROTATION_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <cstdio>
37 #include <Inventor/SbVec4d.h>
38 
39 class SbDPMatrix;
40 class SbVec3d;
41 
42 class COIN_DLL_API SbDPRotation {
43 public:
44  SbDPRotation(void);
45  SbDPRotation(const SbVec3d & axis, const double radians);
46  SbDPRotation(const double q[4]);
47  SbDPRotation(const double q0, const double q1, const double q2, const double q3);
48  SbDPRotation(const SbDPMatrix & m);
49  SbDPRotation(const SbVec3d & rotateFrom, const SbVec3d & rotateTo);
50  const double * getValue(void) const;
51  void getValue(double & q0, double & q1, double & q2, double & q3) const;
52  SbDPRotation & setValue(const double q0, const double q1,
53  const double q2, const double q3);
54  void getValue(SbVec3d & axis, double & radians) const;
55  void getValue(SbDPMatrix & matrix) const;
56  SbDPRotation & invert(void);
57  SbDPRotation inverse(void) const;
58  SbDPRotation & setValue(const double q[4]);
59  SbDPRotation & setValue(const SbDPMatrix & m);
60  SbDPRotation & setValue(const SbVec3d & axis, const double radians);
61  SbDPRotation & setValue(const SbVec3d & rotateFrom, const SbVec3d & rotateTo);
62  SbBool equals(const SbDPRotation & r, double tolerance) const;
63  void multVec(const SbVec3d & src, SbVec3d & dst) const;
64 
65  void scaleAngle(const double scaleFactor);
66  static SbDPRotation slerp(const SbDPRotation & rot0, const SbDPRotation & rot1,
67  double t);
68  static SbDPRotation identity(void);
69 
70  void print(FILE * fp) const;
71 
72  SbDPRotation & operator*=(const SbDPRotation & q);
73  SbDPRotation & operator*=(const double s);
74  friend COIN_DLL_API int operator==(const SbDPRotation & q1, const SbDPRotation & q2);
75  friend COIN_DLL_API int operator!=(const SbDPRotation & q1, const SbDPRotation & q2);
76  friend COIN_DLL_API SbDPRotation operator *(const SbDPRotation & q1, const SbDPRotation & q2);
77 private:
78  SbVec4d quat;
79 };
80 
82 
83 
84 COIN_DLL_API int operator ==(const SbDPRotation & q1, const SbDPRotation & q2);
85 COIN_DLL_API int operator !=(const SbDPRotation & q1, const SbDPRotation & q2);
86 COIN_DLL_API SbDPRotation operator *(const SbDPRotation & q1, const SbDPRotation & q2);
87 
88 #endif // !COIN_SBDPROTATION_H
The SbVec3d class is a 3 dimensional vector with double precision floating point coordinates.
Definition: SbVec3d.h:50
int operator==(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.h:102
int operator!=(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.h:106
The SbDPRotation class represents a rotation in 3D space using double precision data.
Definition: SbDPRotation.h:42
The SbVec4d class is a 4 dimensional vector with double precision floating point coordinates.
Definition: SbVec4d.h:49
SbVec2s operator*(const SbVec2s &v, int d)
The SbDPMatrix class is a 4x4 dimensional representation of a double-precision matrix.
Definition: SbDPMatrix.h:47