AGX Dynamics  2.37.2.0
IMD/Jacobian.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 #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  Jacobian6DOFElementT() : m_spatial(0, 0, 0), m_rotational(0, 0, 0){}
37 
38  Vec3T& spatial();
39  Vec3T& rotational();
40 
41  const Vec3T& spatial() const;
42  const Vec3T& rotational() const;
43 
44 
45  typedef agx::Vec3T<typename T::RealT> NonSSEVec3T;
46 
47  void store(agx::Jacobian6DOFElementT<NonSSEVec3T>& target) const;
48 
49  void set(const T& spatial, const T& rotational);
50 
51  typename T::RealT mult(const T& v1, const T& v2) const;
52 
53  static typename T::RealT mult(const Jacobian6DOFElementT<T>& lhs, const Jacobian6DOFElementT<T>& rhs);
54 
55  void scale(const Vec3T& multiplier);
56 
57  void update(const T& dl, T& linVel, T& angVel) const;
58 
59  private:
60  Vec3T m_spatial;
61  Vec3T m_rotational;
62  };
63 
64  typedef Jacobian6DOFElementT<Vec3d> Jacobian6DOFElement64;
65  typedef Jacobian6DOFElementT<Vec3f> Jacobian6DOFElement32;
66  typedef Jacobian6DOFElementT<Vec3> Jacobian6DOFElement;
67 
68 
69  typedef agxData::Array<Jacobian6DOFElement32> Jacobian6DOFElement32Array;
70  typedef agxData::Array<Jacobian6DOFElement64> Jacobian6DOFElement64Array;
71  typedef agxData::Array<Jacobian6DOFElement> Jacobian6DOFElementArray;
72 
73 
74 #if 0
75  template <typename T>
76  struct JacobianMetaT
77  {
78  typedef T Vec3T;
79 
80  Vec3T localPoint1;
81  Vec3T localPoint2;
82 
83  Vec3T normal;
84  Vec3T uTangent;
85  Vec3T vTangent;
86 
87  Vec3T normalNeg;
88  Vec3T uTangentNeg;
89  Vec3T vTangentNeg;
90 
91  JacobianMetaT();
92  JacobianMetaT(const agx::JacobianMeta& G);
93  };
94 #endif
95 
96  /* Implementation */
97 
98 
99  //-----------------------------------------------------------------------------------------------------
100 
101  template <typename T>
102  AGX_FORCE_INLINE typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::spatial()
103  {
104  return m_spatial;
105  }
106 
107  template <typename T>
108  AGX_FORCE_INLINE typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::rotational()
109  {
110  return m_rotational;
111  }
112 
113  template <typename T>
114  AGX_FORCE_INLINE const typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::spatial() const
115  {
116  return m_spatial;
117  }
118 
119  template <typename T>
120  AGX_FORCE_INLINE const typename Jacobian6DOFElementT<T>::Vec3T& Jacobian6DOFElementT<T>::rotational() const
121  {
122  return m_rotational;
123  }
124 
125 
126  template <typename T>
127  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::set(const T& spatial, const T& rotational)
128  {
129  m_spatial = spatial;
130  m_rotational = rotational;
131  }
132 
133  template <typename T>
134  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::store(agx::Jacobian6DOFElementT<NonSSEVec3T>& target) const
135  {
136  m_spatial.store(target.spatial());
137  m_rotational.store(target.rotational());
138  }
139 
140  template <typename T>
141  AGX_FORCE_INLINE typename T::RealT Jacobian6DOFElementT<T>::mult(const T& v1, const T& v2) const
142  {
143  return T::innerProduct(m_spatial, m_rotational, v1, v2);
144  }
145 
146  template <typename T>
147  AGX_FORCE_INLINE typename T::RealT Jacobian6DOFElementT<T>::mult(const Jacobian6DOFElementT<T>& lhs, const Jacobian6DOFElementT<T>& rhs)
148  {
149  return T::innerProduct(lhs.spatial(), lhs.rotational(), rhs.spatial(), rhs.rotational());
150  }
151 
152  template <typename T>
153  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::scale(const Vec3T& multiplier)
154  {
155  m_spatial = m_spatial.scale(multiplier);
156  m_rotational = m_rotational.scale(multiplier);
157  }
158 
159  template <typename T>
160  AGX_FORCE_INLINE void Jacobian6DOFElementT<T>::update(const T& dl, T& linVel, T& angVel) const
161  {
162  linVel = T::madd(linVel, m_spatial, dl);
163  angVel = T::madd(angVel, m_rotational, dl);
164  }
165 
166  //-----------------------------------------------------------------------------------------------------
167 
168 
169 #if 0
170  template <typename T>
171  AGX_FORCE_INLINE JacobianMetaT<T>::JacobianMetaT()
172  {
173  }
174 
175  template <typename T>
176  AGX_FORCE_INLINE JacobianMetaT<T>::JacobianMetaT(const agx::JacobianMetaT<T>& gmeta) :
177  localPoint1(gmeta.localPoint1),
178  localPoint2(gmeta.localPoint2),
179  normal(gmeta.normal),
180  uTangent(gmeta.uTangent),
181  vTangent(gmeta.vTangent)
182  {
183  normalNeg = normal.negate();
184  uTangentNeg = uTangent.negate();
185  vTangentNeg = vTangent.negate();
186  }
187 #endif
188 
189 }
191 
192 
193 #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:59
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:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97