All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
transform.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef GF_TRANSFORM_H
25 #define GF_TRANSFORM_H
26 
29 
30 #include "pxr/pxr.h"
31 #include "pxr/base/gf/rotation.h"
32 #include "pxr/base/gf/vec3d.h"
33 #include "pxr/base/gf/api.h"
34 
35 #include <iosfwd>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 class GfMatrix4d;
40 
69 class GfTransform {
70 
71  public:
72 
76  SetIdentity();
77  }
78 
81  GfTransform(const GfVec3d &scale,
82  const GfRotation &pivotOrientation,
83  const GfRotation &rotation,
84  const GfVec3d &pivotPosition,
85  const GfVec3d &translation) {
86  Set(scale, pivotOrientation, rotation, pivotPosition, translation);
87  }
88 
91  GfTransform(const GfVec3d &translation,
92  const GfRotation &rotation,
93  const GfVec3d &scale,
94  const GfVec3d &pivotPosition,
95  const GfRotation &pivotOrientation) {
96  Set(translation, rotation, scale, pivotPosition, pivotOrientation);
97  }
98 
102  SetIdentity();
103  SetMatrix(m);
104  }
105 
108  GF_API
109  GfTransform & Set(const GfVec3d &scale,
110  const GfRotation &pivotOrientation,
111  const GfRotation &rotation,
112  const GfVec3d &pivotPosition,
113  const GfVec3d &translation);
114 
117  GfTransform & Set(const GfVec3d &translation,
118  const GfRotation &rotation,
119  const GfVec3d &scale,
120  const GfVec3d &pivotPosition,
121  const GfRotation &pivotOrientation) {
122  return Set(scale, pivotOrientation, rotation,
123  pivotPosition, translation);
124  }
125 
129  GF_API
130  GfTransform & SetMatrix(const GfMatrix4d &m);
131 
133  GF_API
135 
137  void SetScale(const GfVec3d &scale) {
138  _scale = scale;
139  }
140 
142  void SetPivotOrientation(const GfRotation &pivotOrient) {
143  _pivotOrientation = pivotOrient;
144  }
145 
147  void SetScaleOrientation(const GfRotation &pivotOrient) {
148  SetPivotOrientation(pivotOrient);
149  }
150 
152  void SetRotation(const GfRotation &rotation) {
153  _rotation = rotation;
154  }
155 
157  void SetPivotPosition(const GfVec3d &pivPos) {
158  _pivotPosition = pivPos;
159  }
160 
162  void SetCenter(const GfVec3d &pivPos) {
163  SetPivotPosition(pivPos);
164  }
165 
167  void SetTranslation(const GfVec3d &translation) {
168  _translation = translation;
169  }
170 
172  const GfVec3d & GetScale() const {
173  return _scale;
174  }
175 
177  const GfRotation & GetPivotOrientation() const {
178  return _pivotOrientation;
179  }
180 
182  const GfRotation & GetScaleOrientation() const {
183  return GetPivotOrientation();
184  }
185 
187  const GfRotation & GetRotation() const {
188  return _rotation;
189  }
190 
192  const GfVec3d & GetPivotPosition() const {
193  return _pivotPosition;
194  }
195 
197  const GfVec3d & GetCenter() const {
198  return GetPivotPosition();
199  }
200 
202  const GfVec3d & GetTranslation() const {
203  return _translation;
204  }
205 
207  GF_API
208  GfMatrix4d GetMatrix() const;
209 
212  GF_API
213  bool operator ==(const GfTransform &xf) const;
214 
217  bool operator !=(const GfTransform &xf) const {
218  return ! (*this == xf);
219  }
220 
222  GF_API
223  GfTransform & operator *=(const GfTransform &xf);
224 
226  friend GfTransform operator *(const GfTransform &xf1,
227  const GfTransform &xf2) {
228  GfTransform xf = xf1;
229  return xf *= xf2;
230  }
231 
232  private:
234  GfVec3d _translation;
236  GfRotation _rotation;
238  GfVec3d _scale;
240  GfRotation _pivotOrientation;
242  GfVec3d _pivotPosition;
243 };
244 
248 GF_API std::ostream& operator<<(std::ostream&, const GfTransform&);
249 
250 PXR_NAMESPACE_CLOSE_SCOPE
251 
252 #endif // GF_TRANSFORM_H
const GfRotation & GetPivotOrientation() const
Returns the pivot orientation component.
Definition: transform.h:177
GfTransform(const GfMatrix4d &m)
This constructor initializes the transformation with a matrix.
Definition: transform.h:101
GF_API GfTransform & Set(const GfVec3d &scale, const GfRotation &pivotOrientation, const GfRotation &rotation, const GfVec3d &pivotPosition, const GfVec3d &translation)
Sets the transformation from all component values.
GfTransform(const GfVec3d &translation, const GfRotation &rotation, const GfVec3d &scale, const GfVec3d &pivotPosition, const GfRotation &pivotOrientation)
This constructor initializes the transformation from all component values.
Definition: transform.h:91
const GfRotation & GetRotation() const
Returns the rotation component.
Definition: transform.h:187
void SetRotation(const GfRotation &rotation)
Sets the rotation component, leaving all others untouched.
Definition: transform.h:152
GF_API bool operator==(const GfTransform &xf) const
Component-wise transform equality test.
const GfVec3d & GetCenter() const
Returns the pivot position component.
Definition: transform.h:197
GfTransform(const GfVec3d &scale, const GfRotation &pivotOrientation, const GfRotation &rotation, const GfVec3d &pivotPosition, const GfVec3d &translation)
This constructor initializes the transformation from all component values.
Definition: transform.h:81
bool operator!=(const GfTransform &xf) const
Component-wise transform inequality test.
Definition: transform.h:217
const GfVec3d & GetPivotPosition() const
Returns the pivot position component.
Definition: transform.h:192
const GfVec3d & GetScale() const
Returns the scale component.
Definition: transform.h:172
const GfVec3d & GetTranslation() const
Returns the translation component.
Definition: transform.h:202
void SetPivotOrientation(const GfRotation &pivotOrient)
Sets the pivot orientation component, leaving all others untouched.
Definition: transform.h:142
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
GF_API GfTransform & SetMatrix(const GfMatrix4d &m)
Sets the transform components to implement the transformation represented by matrix m ...
const GfRotation & GetScaleOrientation() const
Returns the scale orientation component.
Definition: transform.h:182
GF_API GfTransform & operator*=(const GfTransform &xf)
Post-multiplies transform xf into this transform.
friend GfTransform operator*(const GfTransform &xf1, const GfTransform &xf2)
Returns the product of transforms xf1 and xf2.
Definition: transform.h:226
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
void SetCenter(const GfVec3d &pivPos)
Sets the pivot position component, leaving all others untouched.
Definition: transform.h:162
GfTransform()
The default constructor sets the component values to the identity transformation. ...
Definition: transform.h:75
GF_API GfTransform & SetIdentity()
Sets the transformation to the identity transformation.
Basic type: Compound linear transformation.
Definition: transform.h:69
Basic type for a vector of 3 double components.
Definition: vec3d.h:63
void SetScaleOrientation(const GfRotation &pivotOrient)
Sets the pivot orientation component, leaving all others untouched.
Definition: transform.h:147
void SetPivotPosition(const GfVec3d &pivPos)
Sets the pivot position component, leaving all others untouched.
Definition: transform.h:157
Basic type: 3-space rotation specification.
Definition: rotation.h:55
void SetScale(const GfVec3d &scale)
Sets the scale component, leaving all others untouched.
Definition: transform.h:137
GF_API GfMatrix4d GetMatrix() const
Returns a GfMatrix4d that implements the cumulative transformation.
GfTransform & Set(const GfVec3d &translation, const GfRotation &rotation, const GfVec3d &scale, const GfVec3d &pivotPosition, const GfRotation &pivotOrientation)
Sets the transformation from all component values.
Definition: transform.h:117
void SetTranslation(const GfVec3d &translation)
Sets the translation component, leaving all others untouched.
Definition: transform.h:167