AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
OrientedFrictionModels.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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#pragma once
18
19#include <agx/FrictionModel.h>
20#include <agx/Attachment.h>
21#include <agx/BitState.h>
22
23namespace agx
24{
29 template<typename T>
31 {
32 public:
33 using Model = T;
34
35 public:
43 const agx::Vec3& primaryDirection,
45
50
55 void setReferenceFrame( const agx::Frame* refFrame );
56
61
66 void setPrimaryDirection( const agx::Vec3& primaryDirection );
67
68 public:
73 virtual void calculateTangentPlane( const agxCollide::Geometry* geometry1,
74 const agxCollide::Geometry* geometry2,
75 const agx::Vec3& point,
76 const agx::Vec3& normal,
77 const agx::Real depth,
78 agx::Vec3& ret_u,
79 agx::Vec3& ret_v ) const override;
80
81 protected:
83
84 private:
85 agx::FrameConstObserver m_refFrame;
86 agx::Vec3 m_primaryDirection;
87 };
88
89#ifdef SWIG
90 %template(OrientedBoxFrictionModelImpl) OrientedFrictionModelImpl<agx::BoxFrictionModel>;
91 %template(OrientedScaleBoxFrictionModelImpl) OrientedFrictionModelImpl<agx::ScaleBoxFrictionModel>;
92 %template(OrientedIterativeProjectedConeFrictionModelImpl) OrientedFrictionModelImpl<agx::IterativeProjectedConeFriction>;
93#endif
94
122
150
178
191 {
192 public:
202 const agx::Frame* refFrame,
203 const agx::Vec3& primaryDirection,
205 agx::Bool scaleWithDepth = false );
206
211 void setNormalForceMagnitude( agx::Real normalForceMagnitude );
212
217
227
232
233 public:
238 const agxCollide::Geometry* geometry2,
239 const agx::Vec3& point,
240 const agx::Vec3& normal,
241 const agx::Real depth,
242 const agx::Real dt,
243 const size_t numPoints ) const override;
244
246
247 protected:
249
251
252 private:
253 enum Flag : agx::UInt16
254 {
255 SCALE_WITH_DEPTH = 1 << 0
256 };
257 using Flags = agx::BitState<Flag, agx::UInt16>;
258
259 private:
260 agx::Real m_normalForceMagnitude;
261 Flags m_flags;
262 };
263
264 template<typename T>
266 const agx::Vec3& primaryDirection,
268 : T( solveType ), m_refFrame( refFrame ), m_primaryDirection( primaryDirection )
269 {
270 }
271
272 template<typename T>
276
277 template<typename T>
279 {
280 return m_refFrame;
281 }
282
283 template<typename T>
285 {
286 m_refFrame = refFrame;
287 }
288
289 template<typename T>
291 {
292 return m_primaryDirection;
293 }
294
295 template<typename T>
297 {
298 m_primaryDirection = primaryDirection;
299 }
300
301 template<typename T>
303 const agxCollide::Geometry* /*geometry2*/,
304 const agx::Vec3& /*point*/,
305 const agx::Vec3& normal,
306 const agx::Real /*depth*/,
307 agx::Vec3& ret_u,
308 agx::Vec3& ret_v ) const
309 {
310 // If the frame is null we treat the primary direction as given in world frame.
311 ret_u = m_refFrame != nullptr ?
312 m_refFrame->transformVectorToWorld( m_primaryDirection ) :
313 m_primaryDirection;
314 ret_u -= ( normal * ret_u ) * normal;
315 if ( ret_u.normalize() < agx::RealEpsilon ) {
316 agx::Attachment::createAttachmentBase( normal, ret_u, ret_v );
317 return;
318 }
319
320 ret_v = normal.cross( ret_u );
321 }
322}
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
static void createAttachmentBase(const agx::Vec3d &N, agx::Vec3d &U, agx::Vec3d &V)
Given vector N, create orthonormal base.
Oriented box friction model that uses the same normal force magnitude for all contact points associat...
void setEnableScaleWithDepth(agx::Bool enable)
Enable/disable scale of the given normal force with the contact point depth resulting in a maximum fr...
virtual agx::Real calculateNormalForce(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2, const agx::Vec3 &point, const agx::Vec3 &normal, const agx::Real depth, const agx::Real dt, const size_t numPoints) const override
void setNormalForceMagnitude(agx::Real normalForceMagnitude)
Assign normal force magnitude.
ConstantNormalForceOrientedBoxFrictionModel(agx::Real normalForceMagnitude, const agx::Frame *refFrame, const agx::Vec3 &primaryDirection, agx::FrictionModel::SolveType solveType=agx::FrictionModel::SPLIT, agx::Bool scaleWithDepth=false)
Construct given normal force magnitude, reference frame and primary direction.
The object defining a frame of reference and providing transformations operations.
Definition agx/Frame.h:68
@ SPLIT
First Normal equation is calculated in the DIRECT solver, then in a second pass the normal and the fr...
Box friction model with oriented friction box.
OrientedBoxFrictionModel(const agx::Frame *refFrame, const agx::Vec3 &primaryDirection, agx::FrictionModel::SolveType solveType=agx::FrictionModel::SPLIT)
Construct given frame of reference and primary friction direction.
Oriented friction box base implementation containing a frame of reference and the primary direction g...
OrientedFrictionModelImpl(const agx::Frame *refFrame, const agx::Vec3 &primaryDirection, agx::FrictionModel::SolveType solveType)
Construct given frame of reference and primary friction direction.
void setPrimaryDirection(const agx::Vec3 &primaryDirection)
Assign primary friction direction given in reference frame.
const agx::Frame * getReferenceFrame() const
void setReferenceFrame(const agx::Frame *refFrame)
Assign frame of reference.
virtual void calculateTangentPlane(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2, const agx::Vec3 &point, const agx::Vec3 &normal, const agx::Real depth, agx::Vec3 &ret_u, agx::Vec3 &ret_v) const override
Calculates primary and secondary friction directions in world coordinates given contact point.
const agx::Vec3 & getPrimaryDirection() const
Iterative projected cone friction model with oriented friction box.
OrientedIterativeProjectedConeFrictionModel(const agx::Frame *refFrame, const agx::Vec3 &primaryDirection, agx::FrictionModel::SolveType solveType=agx::FrictionModel::SPLIT)
Construct given frame of reference and primary friction direction.
Scale box friction model with oriented friction box.
OrientedScaleBoxFrictionModel(const agx::Frame *refFrame, const agx::Vec3 &primaryDirection, agx::FrictionModel::SolveType solveType=agx::FrictionModel::SPLIT)
Construct given frame of reference and primary friction direction.
Real normalize()
Normalize the vector so that it has length unity.
const Vec3T cross(const Vec3T &rhs) const
Cross product method.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint16_t UInt16
Definition Integer.h:31
bool Bool
Definition Integer.h:40
AGXCORE_EXPORT const Real RealEpsilon
double Real
Definition Real.h:42