AGXDynamics
2.35.0.2
Vec2.h
Go to the documentation of this file.
1
/*
2
Copyright 2007-2022. 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
#ifndef AGX_VEC2_H
18
#define AGX_VEC2_H
19
20
#include <
agx/Vec2Template.h
>
21
#include <
agxData/Type.h
>
22
23
namespace
agx
24
{
25
35
typedef
Vec2T<Real>
Vec2
;
36
typedef
Vec2T<Real32>
Vec2f
;
37
typedef
Vec2T<Real64>
Vec2d
;
38
39
40
typedef
Vec2T<Int>
Vec2i
;
41
typedef
Vec2T<Int8>
Vec2i8
;
42
typedef
Vec2T<Int16>
Vec2i16
;
43
typedef
Vec2T<Int32>
Vec2i32
;
44
typedef
Vec2T<Int64>
Vec2i64
;
45
46
47
typedef
Vec2T<UInt>
Vec2u
;
48
typedef
Vec2T<UInt8>
Vec2u8
;
49
typedef
Vec2T<UInt16>
Vec2u16
;
50
typedef
Vec2T<UInt32>
Vec2u32
;
51
typedef
Vec2T<UInt64>
Vec2u64
;
52
53
54
#ifndef SWIG
55
const
Vec2
X_AXIS_2D
( 1.0, 0.0 );
56
const
Vec2
Y_AXIS_2D
( 0.0, 1.0 );
57
#endif
58
59
// Hash function
60
template
<
typename
T>
61
struct
HashFn
<
Vec2T
<T> >
62
{
63
AGX_FORCE_INLINE
agx::UInt32
operator()
(
const
Vec2T<T>
&
id
)
const
64
{
65
const
agx::UInt32
p1 = 73856093UL;
66
const
agx::UInt32
p2 = 19349663UL;
67
68
return
(p1 * (
agx::UInt32
)
id
[0]) ^ (p2 * (
agx::UInt32
)
id
[1]);
69
}
70
};
71
72
AGX_FORCE_INLINE
Vec2i
calculateCellId
(
Real
x,
Real
y,
Real
invCellSize)
73
{
74
agx::Vec2i
cell;
75
cell[0] = (
Vec2i::Type
)(x * invCellSize);
76
cell[1] = (
Vec2i::Type
)(y * invCellSize);
77
78
if
(x <
Real
(0.0)) cell[0]--;
79
if
(y <
Real
(0.0)) cell[1]--;
80
81
return
cell;
82
}
83
84
AGX_FORCE_INLINE
Vec2i
calculateCellId
(
const
Vec2
& position,
Real
invCellSize)
85
{
86
return
calculateCellId
(position[0], position[1], invCellSize);
87
}
88
89
}
// end of namespace agx
90
91
92
AGX_TYPE_BINDING
(
agx::Vec2f
,
"Vec2"
)
93
AGX_TYPE_BINDING
(
agx
::
Vec2d
, "
Vec2
")
94
95
AGX_TYPE_BINDING
(
agx
::
Vec2i8
, "
Vec2i
")
96
AGX_TYPE_BINDING
(
agx
::
Vec2i16
, "
Vec2i
")
97
AGX_TYPE_BINDING
(
agx
::
Vec2i32
, "
Vec2i
")
98
AGX_TYPE_BINDING
(
agx
::
Vec2i64
, "
Vec2i
")
99
100
AGX_TYPE_BINDING
(
agx
::
Vec2u8
, "
Vec2u
")
101
AGX_TYPE_BINDING
(
agx
::
Vec2u16
, "
Vec2u
")
102
AGX_TYPE_BINDING
(
agx
::
Vec2u32
, "
Vec2u
")
103
AGX_TYPE_BINDING
(
agx
::
Vec2u64
, "
Vec2u
")
104
105
106
#endif
agx::Vec2u64
Vec2T< UInt64 > Vec2u64
Definition:
Vec2.h:51
agx::Vec2i8
Vec2T< Int8 > Vec2i8
Definition:
Vec2.h:41
agx::Vec2u32
Vec2T< UInt32 > Vec2u32
Definition:
Vec2.h:50
agx::Real
double Real
Definition:
Real.h:42
agx::Vec2u
Vec2T< UInt > Vec2u
Definition:
Vec2.h:47
agx::X_AXIS_2D
const Vec2 X_AXIS_2D(1.0, 0.0)
agx::HashFn< Vec2T< T > >::operator()
agx::UInt32 operator()(const Vec2T< T > &id) const
Definition:
Vec2.h:63
agx::Vec2i64
Vec2T< Int64 > Vec2i64
Definition:
Vec2.h:44
agx::Vec2f
Vec2T< Real32 > Vec2f
Definition:
Vec2.h:36
agx::HashFn
Definition:
hash.h:37
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition:
AddedMassInteraction.h:22
agx::Vec2T::Type
T Type
Definition:
Vec2Template.h:33
Vec2Template.h
Type.h
agx::Vec2i16
Vec2T< Int16 > Vec2i16
Definition:
Vec2.h:42
agx::calculateCellId
Vec2i calculateCellId(Real x, Real y, Real invCellSize)
Definition:
Vec2.h:72
agx::Vec2u8
Vec2T< UInt8 > Vec2u8
Definition:
Vec2.h:48
agx::Vec2T
Definition:
Vec2Template.h:30
agx::Vec2i
Vec2T< Int > Vec2i
Definition:
Vec2.h:40
agx::Vec2d
Vec2T< Real64 > Vec2d
Definition:
Vec2.h:37
agx::Y_AXIS_2D
const Vec2 Y_AXIS_2D(0.0, 1.0)
AGX_TYPE_BINDING
#define AGX_TYPE_BINDING(_Type, _Name)
Definition:
Type.h:179
agx::Vec2i32
Vec2T< Int32 > Vec2i32
Definition:
Vec2.h:43
agx::UInt32
uint32_t UInt32
Definition:
Integer.h:40
agx::Vec2
Vec2T< Real > Vec2
The object holding 2 dimensional vectors and providing basic arithmetic.
Definition:
Vec2.h:35
agx::Vec2u16
Vec2T< UInt16 > Vec2u16
Definition:
Vec2.h:49
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition:
macros.h:58
include
agx
Vec2.h
Generated on Mon Jan 30 2023 15:44:21 for AGXDynamics by
1.8.17