All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
transform.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_BASE_GF_TRANSFORM_H
8#define PXR_BASE_GF_TRANSFORM_H
9
12
13#include "pxr/pxr.h"
15#include "pxr/base/gf/vec3d.h"
16#include "pxr/base/gf/api.h"
17
18#include <iosfwd>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class GfMatrix4d;
23
53
54 public:
55
60 }
61
64 GfTransform(const GfVec3d &scale,
65 const GfRotation &pivotOrientation,
66 const GfRotation &rotation,
67 const GfVec3d &pivotPosition,
68 const GfVec3d &translation) {
69 Set(scale, pivotOrientation, rotation, pivotPosition, translation);
70 }
71
74 GfTransform(const GfVec3d &translation,
75 const GfRotation &rotation,
76 const GfVec3d &scale,
77 const GfVec3d &pivotPosition,
78 const GfRotation &pivotOrientation) {
79 Set(translation, rotation, scale, pivotPosition, pivotOrientation);
80 }
81
86 SetMatrix(m);
87 }
88
91 GF_API
92 GfTransform & Set(const GfVec3d &scale,
93 const GfRotation &pivotOrientation,
94 const GfRotation &rotation,
95 const GfVec3d &pivotPosition,
96 const GfVec3d &translation);
97
100 GfTransform & Set(const GfVec3d &translation,
101 const GfRotation &rotation,
102 const GfVec3d &scale,
103 const GfVec3d &pivotPosition,
104 const GfRotation &pivotOrientation) {
105 return Set(scale, pivotOrientation, rotation,
106 pivotPosition, translation);
107 }
108
112 GF_API
114
116 GF_API
118
120 void SetScale(const GfVec3d &scale) {
121 _scale = scale;
122 }
123
125 void SetPivotOrientation(const GfRotation &pivotOrient) {
126 _pivotOrientation = pivotOrient;
127 }
128
130 void SetScaleOrientation(const GfRotation &pivotOrient) {
131 SetPivotOrientation(pivotOrient);
132 }
133
135 void SetRotation(const GfRotation &rotation) {
136 _rotation = rotation;
137 }
138
140 void SetPivotPosition(const GfVec3d &pivPos) {
141 _pivotPosition = pivPos;
142 }
143
145 void SetCenter(const GfVec3d &pivPos) {
146 SetPivotPosition(pivPos);
147 }
148
150 void SetTranslation(const GfVec3d &translation) {
151 _translation = translation;
152 }
153
155 const GfVec3d & GetScale() const {
156 return _scale;
157 }
158
161 return _pivotOrientation;
162 }
163
166 return GetPivotOrientation();
167 }
168
170 const GfRotation & GetRotation() const {
171 return _rotation;
172 }
173
175 const GfVec3d & GetPivotPosition() const {
176 return _pivotPosition;
177 }
178
180 const GfVec3d & GetCenter() const {
181 return GetPivotPosition();
182 }
183
185 const GfVec3d & GetTranslation() const {
186 return _translation;
187 }
188
190 GF_API
192
195 GF_API
196 bool operator ==(const GfTransform &xf) const;
197
200 bool operator !=(const GfTransform &xf) const {
201 return ! (*this == xf);
202 }
203
205 GF_API
207
210 const GfTransform &xf2) {
211 GfTransform xf = xf1;
212 return xf *= xf2;
213 }
214
215 private:
217 GfVec3d _translation;
219 GfRotation _rotation;
221 GfVec3d _scale;
223 GfRotation _pivotOrientation;
225 GfVec3d _pivotPosition;
226};
227
231GF_API std::ostream& operator<<(std::ostream&, const GfTransform&);
232
233PXR_NAMESPACE_CLOSE_SCOPE
234
235#endif // PXR_BASE_GF_TRANSFORM_H
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type: 3-space rotation specification.
Definition: rotation.h:37
Basic type: Compound linear transformation.
Definition: transform.h:52
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:74
GF_API GfTransform & SetMatrix(const GfMatrix4d &m)
Sets the transform components to implement the transformation represented by matrix m ,...
void SetTranslation(const GfVec3d &translation)
Sets the translation component, leaving all others untouched.
Definition: transform.h:150
const GfRotation & GetPivotOrientation() const
Returns the pivot orientation component.
Definition: transform.h:160
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:64
GF_API GfTransform & operator*=(const GfTransform &xf)
Post-multiplies transform xf into this transform.
GF_API GfTransform & SetIdentity()
Sets the transformation to the identity 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:100
void SetScale(const GfVec3d &scale)
Sets the scale component, leaving all others untouched.
Definition: transform.h:120
void SetCenter(const GfVec3d &pivPos)
Sets the pivot position component, leaving all others untouched.
Definition: transform.h:145
GF_API bool operator==(const GfTransform &xf) const
Component-wise transform equality test.
friend GfTransform operator*(const GfTransform &xf1, const GfTransform &xf2)
Returns the product of transforms xf1 and xf2.
Definition: transform.h:209
const GfVec3d & GetCenter() const
Returns the pivot position component.
Definition: transform.h:180
const GfRotation & GetRotation() const
Returns the rotation component.
Definition: transform.h:170
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.
const GfRotation & GetScaleOrientation() const
Returns the scale orientation component.
Definition: transform.h:165
void SetScaleOrientation(const GfRotation &pivotOrient)
Sets the pivot orientation component, leaving all others untouched.
Definition: transform.h:130
void SetRotation(const GfRotation &rotation)
Sets the rotation component, leaving all others untouched.
Definition: transform.h:135
GfTransform(const GfMatrix4d &m)
This constructor initializes the transformation with a matrix.
Definition: transform.h:84
bool operator!=(const GfTransform &xf) const
Component-wise transform inequality test.
Definition: transform.h:200
const GfVec3d & GetPivotPosition() const
Returns the pivot position component.
Definition: transform.h:175
const GfVec3d & GetTranslation() const
Returns the translation component.
Definition: transform.h:185
GfTransform()
The default constructor sets the component values to the identity transformation.
Definition: transform.h:58
GF_API GfMatrix4d GetMatrix() const
Returns a GfMatrix4d that implements the cumulative transformation.
const GfVec3d & GetScale() const
Returns the scale component.
Definition: transform.h:155
void SetPivotPosition(const GfVec3d &pivPos)
Sets the pivot position component, leaving all others untouched.
Definition: transform.h:140
void SetPivotOrientation(const GfRotation &pivotOrient)
Sets the pivot orientation component, leaving all others untouched.
Definition: transform.h:125
Basic type for a vector of 3 double components.
Definition: vec3d.h:46
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].