AGXDynamics  2.31.1.0
IMD/Jacobian.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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_SIMD_JACOBIAN_H
18 #define AGX_SIMD_JACOBIAN_H
19 
20 #include <agxSIMD/Vec3.h>
21 #include <agx/Jacobian.h>
22 // #include <agx/BodyContactJacobian.h>
23 #include <agxData/StackArray.h>
24 
26 namespace agxSIMD
27 {
28 
29  template <typename T>
30  class Jacobian6DOFElementT
31  {
32  public:
33  typedef T Vec3T;
34 
35  public:
36  Vec3T& spatial();
37  Vec3T& rotational();
38 
39  const Vec3T& spatial() const;
40  const Vec3T& rotational() const;
41 
42 
43  typedef agx::Vec3T<typename T::RealT> NonSSEVec3T;
44 
45  void store(agx::Jacobian6DOFElementT<NonSSEVec3T>& target) const;
46 
47  void set(const T& spatial, const T& rotational);
48 
49  typename T::RealT mult(const T& v1, const T& v2) const;
50 
51  static typename T::RealT mult(const Jacobian6DOFElementT<T>& lhs, const Jacobian6DOFElementT<T>& rhs);
52 
53  void scale(const Vec3T& multiplier);
54 
55  void update(const T& dl, T& linVel, T& angVel) const;
56 
57  private:
58  Vec3T m_spatial;
59  Vec3T m_rotational;
60  };
61 
62  typedef Jacobian6DOFElementT<Vec3d> Jacobian6DOFElement64;
63  typedef Jacobian6DOFElementT<Vec3f> Jacobian6DOFElement32;
64  typedef Jacobian6DOFElementT<Vec3> Jacobian6DOFElement;
65 
66 
67  typedef agxData::Array<Jacobian6DOFElement32> Jacobian6DOFElement32Array;
68  typedef agxData::Array<Jacobian6DOFElement64> Jacobian6DOFElement64Array;
69  typedef agxData::Array<Jacobian6DOFElement> Jacobian6DOFElementArray;
70 
71 
72 #if 0
73  template <typename T>
74  struct JacobianMetaT
75  {
76  typedef T Vec3T;
77 
78  Vec3T localPoint1;
79  Vec3T localPoint2;
80 
81  Vec3T normal;
82  Vec3T uTangent;
83  Vec3T vTangent;
84 
85  Vec3T normalNeg;
86  Vec3T uTangentNeg;
87  Vec3T vTangentNeg;
88 
89  JacobianMetaT();
90  JacobianMetaT(const agx::JacobianMeta& G);
91  };
92 #endif
93 
94  /* Implementation */
95 
96 
97  //-----------------------------------------------------------------------------------------------------
98 
99  template <typename T>
100  AGX_FORCE_INLINE typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::spatial()
101  {
102  return m_spatial;
103  }
104 
105  template <typename T>
106  AGX_FORCE_INLINE typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::rotational()
107  {
108  return m_rotational;
109  }
110 
111  template <typename T>
112  AGX_FORCE_INLINE const typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::spatial() const
113  {
114  return m_spatial;
115  }
116 
117  template <typename T>
118  AGX_FORCE_INLINE const typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::rotational() const
119  {
120  return m_rotational;
121  }
122 
123 
124  template <typename T>
125  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::set(const T& spatial, const T& rotational)
126  {
127  m_spatial = spatial;
128  m_rotational = rotational;
129  }
130 
131  template <typename T>
132  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::store(agx::Jacobian6DOFElementT<NonSSEVec3T>& target) const
133  {
134  m_spatial.store(target.spatial());
135  m_rotational.store(target.rotational());
136  }
137 
138  template <typename T>
139  AGX_FORCE_INLINE typename T::RealT Jacobian6DOFElementT<T>::mult(const T& v1, const T& v2) const
140  {
141  return T::innerProduct(m_spatial, m_rotational, v1, v2);
142  }
143 
144  template <typename T>
145  AGX_FORCE_INLINE typename T::RealT Jacobian6DOFElementT<T>::mult(const Jacobian6DOFElementT<T>& lhs, const Jacobian6DOFElementT<T>& rhs)
146  {
147  return T::innerProduct(lhs.spatial(), lhs.rotational(), rhs.spatial(), rhs.rotational());
148  }
149 
150  template <typename T>
151  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::scale(const Vec3T& multiplier)
152  {
153  m_spatial = m_spatial.scale(multiplier);
154  m_rotational = m_rotational.scale(multiplier);
155  }
156 
157  template <typename T>
158  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::update(const T& dl, T& linVel, T& angVel) const
159  {
160  linVel = T::madd(linVel, m_spatial, dl);
161  angVel = T::madd(angVel, m_rotational, dl);
162  }
163 
164  //-----------------------------------------------------------------------------------------------------
165 
166 
167 #if 0
168  template <typename T>
169  AGX_FORCE_INLINE JacobianMetaT<T>::JacobianMetaT()
170  {
171  }
172 
173  template <typename T>
174  AGX_FORCE_INLINE JacobianMetaT<T>::JacobianMetaT(const agx::JacobianMetaT<T>& gmeta) :
175  localPoint1(gmeta.localPoint1),
176  localPoint2(gmeta.localPoint2),
177  normal(gmeta.normal),
178  uTangent(gmeta.uTangent),
179  vTangent(gmeta.vTangent)
180  {
181  normalNeg = normal.negate();
182  uTangentNeg = uTangent.negate();
183  vTangentNeg = vTangent.negate();
184  }
185 #endif
186 
187 }
189 
190 
191 #endif /* AGX_SIMD_JACOBIAN_H */
Real mult(const Jacobian6DOFElementT< T > &G1, const Jacobian6DOFElementT< T > &G2)
Definition: Jacobian.h:386
Jacobian6DOFElementT< Vec3 > Jacobian6DOFElement
Definition: Jacobian.h:273
Jacobian6DOFElementT< Vec3f > Jacobian6DOFElement32
Definition: Jacobian.h:272
#define AGX_FORCE_INLINE
Definition: Object.h:63
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
A class holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3Template.h:45
Jacobian6DOFElementT< Vec3d > Jacobian6DOFElement64
Definition: Jacobian.h:271
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:102
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:101