AGX Dynamics 2.41.3.0
Loading...
Searching...
No Matches
agx/Vec3.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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
24namespace agx
25{
26
37
38
41
42
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
103AGX_TYPE_BINDING(agx::Vec3d, "Vec3")
104
105AGX_TYPE_BINDING(agx::Vec3i8 , "Vec3i")
106AGX_TYPE_BINDING(agx::Vec3i16, "Vec3i")
107AGX_TYPE_BINDING(agx::Vec3i32, "Vec3i")
108AGX_TYPE_BINDING(agx::Vec3i64, "Vec3i")
109
110AGX_TYPE_BINDING(agx::Vec3u8 , "Vec3u")
111AGX_TYPE_BINDING(agx::Vec3u16, "Vec3u")
112AGX_TYPE_BINDING(agx::Vec3u32, "Vec3u")
113AGX_TYPE_BINDING(agx::Vec3u64, "Vec3u")
114
115#endif
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
A class holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3Template.h:46
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Vec3T< UInt16 > Vec3u16
Definition: agx/Vec3.h:49
UInt32 hash(const T &key)
Definition: HashFunction.h:65
const Vec3 Y_AXIS(0.0, 1.0, 0.0)
Vec3T< Int16 > Vec3i16
Definition: agx/Vec3.h:48
Vec3T< UInt32 > Vec3u32
Definition: agx/Vec3.h:51
uint32_t UInt32
Definition: Integer.h:32
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: agx/Vec3.h:36
Vec3T< Real64 > Vec3d
Definition: agx/Vec3.h:40
Vec3T< UInt64 > Vec3u64
Definition: agx/Vec3.h:53
Vec3T< Int32 > Vec3i32
Definition: agx/Vec3.h:50
Vec3T< Int64 > Vec3i64
Definition: agx/Vec3.h:52
const Vec3 Z_AXIS(0.0, 0.0, 1.0)
Vec3T< Int > Vec3i
Definition: agx/Vec3.h:43
double Real
Definition: Real.h:42
Vec2i calculateCellId(Real x, Real y, Real invCellSize)
Definition: Vec2.h:72
const Vec3 X_AXIS(1.0, 0.0, 0.0)
Vec3T< Real32 > Vec3f
Definition: agx/Vec3.h:39
Vec3T< Int8 > Vec3i8
Definition: agx/Vec3.h:46
Vec3T< UInt8 > Vec3u8
Definition: agx/Vec3.h:47
Vec3T< UInt > Vec3u
Definition: agx/Vec3.h:44
agx::UInt32 operator()(const Vec3T< T > &id) const
Definition: agx/Vec3.h:74