11#ifndef PXR_BASE_GF_VEC3D_H
12#define PXR_BASE_GF_VEC3D_H
19#include "pxr/base/gf/api.h"
21#include "pxr/base/gf/traits.h"
30PXR_NAMESPACE_OPEN_SCOPE
50 static const size_t dimension = 3;
58 : _data{ value, value, value }
63 constexpr GfVec3d(
double s0,
double s1,
double s2)
71 : _data{ p[0], p[1], p[2] }
122 return Set(a[0], a[1], a[2]);
126 double const *
data()
const {
return _data; }
127 double *
data() {
return _data; }
128 double const *GetArray()
const {
return data(); }
131 double const &
operator[](
size_t i)
const {
return _data[i]; }
132 double &
operator[](
size_t i) {
return _data[i]; }
141 return _data[0] == other[0] &&
142 _data[1] == other[1] &&
143 _data[2] == other[2];
145 bool operator!=(
GfVec3d const &other)
const {
146 return !(*
this == other);
162 return GfVec3d(-_data[0], -_data[1], -_data[2]);
167 _data[0] += other[0];
168 _data[1] += other[1];
169 _data[2] += other[2];
178 _data[0] -= other[0];
179 _data[1] -= other[1];
180 _data[2] -= other[2];
194 GfVec3d operator*(
double s)
const {
207 return *
this *= (1.0 / s);
209 GfVec3d operator/(
double s)
const {
210 return *
this * (1.0 / s);
215 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2];
223 return v * (*
this * v);
237 return *
this * *
this;
257 *
this /= (length > eps) ? length : eps;
263 normalized.Normalize(eps);
279 const bool normalize,
300PXR_NAMESPACE_CLOSE_SCOPE
306PXR_NAMESPACE_OPEN_SCOPE
379 return v.GetNormalized(eps);
408 return delta.
GetLengthSq() <= tolerance * tolerance;
417GfBuildOrthonormalFrame(
GfVec3d const &v0,
427 v1[1] * v2[2] - v1[2] * v2[1],
428 v1[2] * v2[0] - v1[0] * v2[2],
429 v1[0] * v2[1] - v1[1] * v2[0]);
446PXR_NAMESPACE_CLOSE_SCOPE
Low-level utilities for informing users of various internal and external diagnostic conditions.
Basic type for a vector of 3 double components.
GfVec3d operator-() const
Create a vec with negated elements.
GfVec3d & Set(double const *a)
Set all elements with a pointer to data.
GF_API bool operator==(class GfVec3h const &other) const
Equality comparison.
constexpr GfVec3d(double value)
Initialize all elements to a single value.
static GfVec3d ZAxis()
Create a unit vector along the Z-axis.
double GetLengthSq() const
Squared length.
GfVec3d & operator+=(GfVec3d const &other)
Addition.
GF_API void BuildOrthonormalFrame(GfVec3d *v1, GfVec3d *v2, double eps=GF_MIN_VECTOR_LENGTH) const
Sets v1 and v2 to unit vectors such that v1, v2 and *this are mutually orthogonal.