HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
homogeneous.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_HOMOGENEOUS_H
8 #define PXR_BASE_GF_HOMOGENEOUS_H
9 
10 /// \file gf/homogeneous.h
11 /// \ingroup group_gf_LinearAlgebra
12 /// Utility functions for GfVec4f and GfVec4d as homogeneous vectors
13 
14 #include "pxr/pxr.h"
15 #include "pxr/base/gf/vec3d.h"
16 #include "pxr/base/gf/vec3f.h"
17 #include "pxr/base/gf/vec4d.h"
18 #include "pxr/base/gf/vec4f.h"
19 #include "pxr/base/gf/api.h"
20 
22 
23 /// Returns a vector which is \p v homogenized. If the fourth element of \p v
24 /// is 0, it is set to 1.
25 /// \ingroup group_gf_LinearAlgebra
26 GF_API
28 
29 /// Homogenizes \p a and \p b and then performs the cross product on the first
30 /// three elements of each. Returns the cross product as a homogenized
31 /// vector.
32 /// \ingroup group_gf_LinearAlgebra
33 GF_API
35 
36 GF_API
38 
39 /// Homogenizes \p a and \p b and then performs the cross product on the first
40 /// three elements of each. Returns the cross product as a homogenized
41 /// vector.
42 /// \ingroup group_gf_LinearAlgebra
43 GF_API
45 
46 /// Projects homogeneous \p v into Euclidean space and returns the result as a
47 /// Vec3f.
48 inline GfVec3f GfProject(const GfVec4f &v) {
49  float inv = (v[3] != 0.0f) ? 1.0f/v[3] : 1.0f;
50  return GfVec3f(inv * v[0], inv * v[1], inv * v[2]);
51 }
52 
53 /// Projects homogeneous \p v into Euclidean space and returns the result as a
54 /// Vec3d.
55 inline GfVec3d GfProject(const GfVec4d &v) {
56  double inv = (v[3] != 0.0) ? 1.0/v[3] : 1.0;
57  return GfVec3d(inv * v[0], inv * v[1], inv * v[2]);
58 }
59 
61 
62 #endif /* PXR_BASE_GF_HOMOGENEOUS_H */
GfVec3f GfProject(const GfVec4f &v)
Definition: homogeneous.h:48
PXR_NAMESPACE_OPEN_SCOPE GF_API GfVec4f GfGetHomogenized(const GfVec4f &v)
const GLdouble * v
Definition: glcorearb.h:837
Definition: vec3f.h:45
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
Definition: vec4d.h:45
GLfloat f
Definition: glcorearb.h:1926
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GF_API GfVec4f GfHomogeneousCross(const GfVec4f &a, const GfVec4f &b)
Definition: vec4f.h:45
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
Definition: vec3d.h:45
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define GF_API
Definition: api.h:23