AGX Dynamics  2.38.0.2
Vec3.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 
18 #ifndef AGX_VEC3_H
19 #define AGX_VEC3_H
20 
21 #include <agx/Vec3Template.h>
22 #include <agxData/Type.h>
23 
24 namespace agx
25 {
26 
36  typedef Vec3T<Real> Vec3;
37 
38 
41 
42 
43  typedef Vec3T<Int> Vec3i;
44  typedef Vec3T<UInt> Vec3u;
45 
54 
55 #ifndef SWIG
56  const Vec3 X_AXIS( 1.0, 0.0, 0.0 );
57  const Vec3 Y_AXIS( 0.0, 1.0, 0.0 );
58  const Vec3 Z_AXIS( 0.0, 0.0, 1.0 );
59 #endif
60 
61  // Hash function
63  {
64  const agx::UInt32 p1 = 73856093UL;
65  const agx::UInt32 p2 = 19349663UL;
66  const agx::UInt32 p3 = 83492791UL;
67 
68  return (p1 * x) ^ (p2 * y) ^ (p3 * z);
69  }
70 
71  template <typename T>
72  struct HashFn< Vec3T<T> >
73  {
75  {
76  return agx::hash((agx::UInt32)id[0], (agx::UInt32)id[1], (agx::UInt32)id[2]);
77  }
78  };
79 
81  {
82  agx::Vec3i cell;
83  cell[0] = (Vec3i::Type)(x * invCellSize);
84  cell[1] = (Vec3i::Type)(y * invCellSize);
85  cell[2] = (Vec3i::Type)(z * invCellSize);
86 
87  if (x < Real(0.0)) cell[0]--;
88  if (y < Real(0.0)) cell[1]--;
89  if (z < Real(0.0)) cell[2]--;
90 
91  return cell;
92  }
93 
95  {
96  return calculateCellId(position[0], position[1], position[2], invCellSize);
97  }
98 
99 } // end of namespace agx
100 
101 
104 
109 
114 
115 #endif
agx::Real
double Real
Definition: Real.h:42
agx::Vec3u8
Vec3T< UInt8 > Vec3u8
Definition: Vec3.h:47
agx::Vec3u
Vec3T< UInt > Vec3u
Definition: Vec3.h:44
agx::Vec3d
Vec3T< Real64 > Vec3d
Definition: Vec3.h:40
agx::Vec3u16
Vec3T< UInt16 > Vec3u16
Definition: Vec3.h:49
agx::Vec3i8
Vec3T< Int8 > Vec3i8
Definition: Vec3.h:46
agx::Vec3i
Vec3T< Int > Vec3i
Definition: Vec3.h:43
agx::HashFn
Definition: hash.h:37
agx::Z_AXIS
const Vec3 Z_AXIS(0.0, 0.0, 1.0)
agx::HashFn< Vec3T< T > >::operator()
agx::UInt32 operator()(const Vec3T< T > &id) const
Definition: Vec3.h:74
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agx::Vec3T< Int >::Type
Int Type
Definition: Vec3Template.h:48
Type.h
agx::calculateCellId
Vec2i calculateCellId(Real x, Real y, Real invCellSize)
Definition: Vec2.h:72
agx::Vec3
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
agx::Vec3i64
Vec3T< Int64 > Vec3i64
Definition: Vec3.h:52
agx::hash
AGXCORE_EXPORT UInt32 hash(const T &key)
Definition: HashFunction.h:65
agx::Vec3u32
Vec3T< UInt32 > Vec3u32
Definition: Vec3.h:51
agx::X_AXIS
const Vec3 X_AXIS(1.0, 0.0, 0.0)
agx::Y_AXIS
const Vec3 Y_AXIS(0.0, 1.0, 0.0)
Vec3Template.h
AGX_TYPE_BINDING
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
agx::Vec3u64
Vec3T< UInt64 > Vec3u64
Definition: Vec3.h:53
agx::Vec3T< Real >
agx::Vec3i16
Vec3T< Int16 > Vec3i16
Definition: Vec3.h:48
agx::Vec3f
Vec3T< Real32 > Vec3f
Definition: Vec3.h:39
agx::UInt32
uint32_t UInt32
Definition: Integer.h:32
agx::Vec3i32
Vec3T< Int32 > Vec3i32
Definition: Vec3.h:50
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58