PeriDyno 1.0.0
Loading...
Searching...
No Matches
SharedFuncsForRigidBody.h
Go to the documentation of this file.
1#pragma once
2#include "Array/ArrayList.h"
3
4#include "STL/Pair.h"
5
7
9
10#include "Topology/DiscreteElements.h"
11
12#include "Algorithm/Reduction.h"
13
14#include "Collision/Attribute.h"
15
16
17namespace dyno
18{
20 DArrayList<Transform3f>& instanceTransform,
21 const DArray<Vec3f>& translate,
22 const DArray<Mat3f>& rotation,
23 const DArray<Pair<uint, uint>>& binding,
24 const DArray<int>& bindingtag);
25
27 DArray<Attribute> attribute,
28 DArray<Vec3f> velocity,
29 DArray<Vec3f> angular_velocity,
30 DArray<Vec3f> impulse,
31 float linearDamping,
32 float angularDamping,
33 float dt
34 );
35
37 DArray<Attribute> attribute,
38 DArray<Vec3f> pos,
39 DArray<Quat1f> rotQuat,
40 DArray<Mat3f> rotMat,
41 DArray<Mat3f> inertia,
42 DArray<Vec3f> velocity,
43 DArray<Vec3f> angular_velocity,
44 DArray<Mat3f> inertia_init,
45 float dt
46 );
47
49 DArray<Vec3f> pos,
50 DArray<Quat1f> rotQuat,
51 DArray<Mat3f> rotMat,
52 DArray<Mat3f> inertia,
53 DArray<Mat3f> inertia_init,
54 DArray<Vec3f> impulse_constrain
55 );
56
59 DArray<int> contactCnt
60 );
61
62
66 DArray<Vec3f> pos,
67 DArray<Mat3f> inertia,
68 DArray<float> mass,
69 DArray<Mat3f> rotMat,
71 );
72
76 DArray<Vec3f> pos,
77 DArray<Mat3f> inertia,
78 DArray<float> mass,
79 DArray<Mat3f> rotMat,
81 );
82
83
85 DArray<float> eta,
87 DArray<Vec3f> velocity,
88 DArray<Vec3f> angular_velocity,
90 );
91
93 DArray<float> eta,
95 DArray<Vec3f> velocity,
96 DArray<Vec3f> angular_velocity,
97 DArray<Vec3f> pos,
98 DArray<Quat1f> rotation_q,
99 DArray<TConstraintPair<float>> constraints,
100 DArray<float> errors,
101 float slop,
102 float beta,
103 uint substepping,
104 float dt
105 );
106
108 DArray<float> eta,
110 DArray<Vec3f> velocity,
111 DArray<Vec3f> angular_velocity,
112 DArray<Vec3f> pos,
113 DArray<Quat1f> rotation_q,
114 DArray <TConstraintPair<float>> constraints,
115 DArray<float> ERP,
116 float slop,
117 float dt
118 );
119
121 DArray<float> eta,
123 DArray<Vec3f> velocity,
124 DArray<Vec3f> angular_velocity,
125 DArray<Vec3f> pos,
126 DArray<Quat1f> rotation_q,
127 DArray <TConstraintPair<float>> constraints,
128 float slop,
129 float zeta,
130 float hertz,
131 float substepping,
132 float dt
133 );
134
136 DArray<float> eta,
138 DArray<Vec3f> pos,
139 DArray<Quat1f> rotation_q,
140 DArray <TConstraintPair<float>> constraints,
141 float slop,
142 float beta
143 );
144
146 DArray<TContactPair<float>> contactsInLocalFrame,
147 DArray<TContactPair<float>> contactsInGlobalFrame,
148 DArray<Vec3f> pos,
149 DArray<Mat3f> rotMat
150 );
151
153 DArray<TConstraintPair<float>> constraints,
154 DArray<TContactPair<float>> contactsInLocalFrame,
155 DArray<Vec3f> pos,
156 DArray<Mat3f> rotMat,
157 bool hasFriction
158 );
159
161 DArray<TConstraintPair<float>> constraints,
162 DArray<TContactPair<float>> contactsInLocalFrame,
163 DArray<Vec3f> pos,
164 DArray<Mat3f> rotMat
165 );
166
168 DArray<TConstraintPair<float>> constraints,
170 DArray<Vec3f> pos,
171 DArray<Mat3f> rotMat,
172 int begin_index
173 );
174
176 DArray<TConstraintPair<float>> constraints,
178 DArray<Vec3f> pos,
179 DArray<Mat3f> rotMat,
180 DArray<Quat1f> rotQuat,
181 int begin_index
182 );
183
185 DArray<TConstraintPair<float>> constraints,
187 DArray<Vec3f> pos,
188 DArray<Mat3f> rotMat,
189 DArray<Quat1f> rotation_q,
190 int begin_index
191 );
192
194 DArray<TConstraintPair<float>>& constraints,
195 DArray<FixedJoint<float>>& joints,
196 DArray<Mat3f>& rotMat,
197 DArray<Quat1f>& rotQuat,
198 int begin_index
199 );
200
202 DArray<TConstraintPair<float>> constraints,
204 DArray<Vec3f> pos,
205 int begin_index
206 );
207
209 DArray<TConstraintPair<float>> constraints,
212 DArray<Vec3f> pos,
213 DArray<Mat3f> inertia,
214 DArray<float> mass,
215 DArray<float> K_1,
216 DArray<Mat2f> K_2,
217 DArray<Mat3f> K_3
218 );
219
221 DArray<TConstraintPair<float>> constraints,
224 DArray<Vec3f> pos,
225 DArray<Mat3f> inertia,
226 DArray<float> mass,
227 DArray<float> K_1,
228 DArray<Mat2f> K_2,
229 DArray<Mat3f> K_3,
230 DArray<float> CFM
231 );
232
233
235 DArray<float> lambda,
236 DArray<Vec3f> impulse,
239 DArray<float> eta,
240 DArray<TConstraintPair<float>> constraints,
241 DArray<int> nbq,
242 DArray<float> K_1,
243 DArray<Mat2f> K_2,
244 DArray<Mat3f> K_3,
245 DArray<float> mass,
246 DArray<float> fricCoeffs,
247 float mu,
248 float g,
249 float dt
250 );
251
253 DArray<float> lambda,
254 DArray<Vec3f> impulse,
257 DArray<float> eta,
258 DArray<TConstraintPair<float>> constraints,
259 DArray<int> nbq,
260 DArray<float> K_1,
261 DArray<Mat2f> K_2,
262 DArray<Mat3f> K_3,
263 DArray<float> mass,
264 DArray<float> CFM,
265 float mu,
266 float g,
267 float dt
268 );
269
271 DArray<float> lambda,
272 DArray<Vec3f> impulse,
275 DArray<float> eta,
276 DArray<TConstraintPair<float>> constraints,
277 DArray<int> nbq,
279 DArray<float> mass,
280 float mu,
281 float g,
282 float dt
283 );
284
286 DArray<float> lambda,
287 DArray<Vec3f> impulse,
290 DArray<float> eta,
291 DArray<TConstraintPair<float>> constraints,
292 DArray<int> nbq,
293 DArray<float> K_1,
294 DArray<Mat2f> K_2,
295 DArray<Mat3f> K_3,
296 DArray<float> mass,
297 DArray<float> mu,
298 float g,
299 float dt,
300 float zeta,
301 float hertz
302 );
303
305 DArray<float> lambda,
306 DArray<Vec3f> impulse,
309 DArray<float> eta,
310 DArray<TConstraintPair<float>> constraints,
311 DArray<int> nbq,
312 DArray<float> K_1,
313 DArray<Mat2f> K_2,
314 DArray<Mat3f> K_3
315 );
316
318 DArray<Vec3f> impulse_ext,
319 float g,
320 float dt
321 );
322
323
326 DArray<Vec3f> mImpulse,
327 DArray<TConstraintPair<float>> constraints,
328 DArray<float> eta
329 );
330
335 );
336
340 DArray<float> eta
341 );
342
344 const std::vector<float>& vec,
345 const std::string& filename
346 );
347
348
350 DArray<float> eta,
352 DArray<Vec3f> velocity,
353 DArray<Vec3f> angular_velocity,
354 DArray <TConstraintPair<float>> constraints
355 );
356
358 DArray<float> errors
359 );
360
361
362
364 DArray<Vec3f> &J,
365 DArray<Vec3f> &B,
366 DArray<float> &A,
367 DArray<TConstraintPair<float>> &constraints,
368 float k
369 );
370
372 DArray<float> &Matrix,
373 int n,
374 const std::string& filename
375 );
376
378 DArray<float>& vec,
379 const std::string& filename
380 );
381
383 DArray<float> &ans,
384 DArray<float> &subtranhend,
385 DArray<float> &minuend,
386 DArray<TConstraintPair<float>> &constraints
387 );
388
390 DArray<float>& ans,
391 DArray<float>& v1,
392 DArray<float>& v2,
393 DArray<TConstraintPair<float>>& constraints
394 );
395
397 DArray<float> &ans,
398 DArray<float> &initialVec,
399 float scale,
400 DArray<TConstraintPair<float>>& constraints
401 );
402
405 DArray<TConstraintPair<float>> constraints
406 );
407
410 DArray<TConstraintPair<float>> constraints,
411 int contact_size,
412 float mu
413 );
414
416 DArray<Vec3f> &J,
417 DArray<Vec3f> &B,
418 DArray<float> &lambda,
419 DArray<float> &ans,
420 DArray<TConstraintPair<float>> &constraints,
421 int bodyNum
422 );
423
425 DArray<float> &a,
427 );
428
430 DArray<float>& v1,
431 DArray<float>& v2,
432 DArray<float>& ans,
433 DArray<TConstraintPair<float>>& constraints
434 );
435
437 DArray<float> lambda,
438 DArray<TConstraintPair<float>> constraints,
439 DArray<Vec3f> impulse,
441 );
442
444 DArray<float> &residual,
445 DArray<float> &ans,
446 DArray<float> &k_1,
447 DArray<Mat2f> &k_2,
448 DArray<Mat3f> &k_3,
449 DArray<TConstraintPair<float>> &constraints
450 );
451
455 DArray<TConstraintPair<float>> constraints,
456 DArray<float> CFM,
457 DArray<float> ERP,
458 float hertz,
459 float zeta,
460 float dt
461 );
462
464 DArray<Vec3f>& J,
465 DArray<Vec3f>& B,
466 DArray<Vec3f>& impulse,
467 DArray<float>& lambda,
468 DArray<float>& ans,
469 DArray<float>& CFM,
470 DArray<TConstraintPair<float>>& constraints
471 );
472}
double Real
Definition Typedef.inl:23
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
void JacobiIterationForSoft(DArray< float > lambda, DArray< Vec3f > impulse, DArray< Vec3f > J, DArray< Vec3f > B, DArray< float > eta, DArray< TConstraintPair< float > > constraints, DArray< int > nbq, DArray< float > K_1, DArray< Mat2f > K_2, DArray< Mat3f > K_3, DArray< float > mass, DArray< float > mu, float g, float dt, float zeta, float hertz)
void calculateKWithCFM(DArray< TConstraintPair< float > > constraints, DArray< Vec3f > J, DArray< Vec3f > B, DArray< Vec3f > pos, DArray< Mat3f > inertia, DArray< float > mass, DArray< float > K_1, DArray< Mat2f > K_2, DArray< Mat3f > K_3, DArray< float > CFM)
void JacobiIterationForCFM(DArray< float > lambda, DArray< Vec3f > impulse, DArray< Vec3f > J, DArray< Vec3f > B, DArray< float > eta, DArray< TConstraintPair< float > > constraints, DArray< int > nbq, DArray< float > K_1, DArray< Mat2f > K_2, DArray< Mat3f > K_3, DArray< float > mass, DArray< float > CFM, float mu, float g, float dt)
void calculateImpulseByLambda(DArray< float > lambda, DArray< TConstraintPair< float > > constraints, DArray< Vec3f > impulse, DArray< Vec3f > B)
Real checkOutError(DArray< Vec3f > J, DArray< Vec3f > mImpulse, DArray< TConstraintPair< float > > constraints, DArray< float > eta)
float vectorNorm(DArray< float > &a, DArray< float > &b)
void vectorSub(DArray< float > &ans, DArray< float > &subtranhend, DArray< float > &minuend, DArray< TConstraintPair< float > > &constraints)
double checkOutErrors(DArray< float > errors)
Array< T, DeviceType::GPU > DArray
Definition Array.inl:89
void calculateEtaVectorForNJS(DArray< float > eta, DArray< Vec3f > J, DArray< Vec3f > pos, DArray< Quat1f > rotation_q, DArray< TConstraintPair< float > > constraints, float slop, float beta)
void vectorMultiplyVector(DArray< float > &v1, DArray< float > &v2, DArray< float > &ans, DArray< TConstraintPair< float > > &constraints)
void setUpContactsInLocalFrame(DArray< TContactPair< float > > contactsInLocalFrame, DArray< TContactPair< float > > contactsInGlobalFrame, DArray< Vec3f > pos, DArray< Mat3f > rotMat)
void calculateEtaVectorForPJSoft(DArray< float > eta, DArray< Vec3f > J, DArray< Vec3f > velocity, DArray< Vec3f > angular_velocity, DArray< Vec3f > pos, DArray< Quat1f > rotation_q, DArray< TConstraintPair< float > > constraints, float slop, float zeta, float hertz, float substepping, float dt)
void setUpContactConstraints(DArray< TConstraintPair< float > > constraints, DArray< TContactPair< float > > contactsInLocalFrame, DArray< Vec3f > pos, DArray< Mat3f > rotMat)
void vectorClampFriction(DArray< float > v, DArray< TConstraintPair< float > > constraints, int contact_size, float mu)
void updateVelocity(DArray< Attribute > attribute, DArray< Vec3f > velocity, DArray< Vec3f > angular_velocity, DArray< Vec3f > impulse, float linearDamping, float angularDamping, float dt)
void vectorMultiplyScale(DArray< float > &ans, DArray< float > &initialVec, float scale, DArray< TConstraintPair< float > > &constraints)
void setUpPointJointConstraints(DArray< TConstraintPair< float > > constraints, DArray< PointJoint< float > > joints, DArray< Vec3f > pos, int begin_index)
void setUpFixedJointConstraints(DArray< TConstraintPair< float > > &constraints, DArray< FixedJoint< float > > &joints, DArray< Mat3f > &rotMat, DArray< Quat1f > &rotQuat, int begin_index)
void calculateDiagnals(DArray< float > d, DArray< Vec3f > J, DArray< Vec3f > B)
void calculateEtaVectorForRelaxation(DArray< float > eta, DArray< Vec3f > J, DArray< Vec3f > velocity, DArray< Vec3f > angular_velocity, DArray< TConstraintPair< float > > constraints)
bool saveMatrixToFile(DArray< float > &Matrix, int n, const std::string &filename)
void JacobiIterationStrict(DArray< float > lambda, DArray< Vec3f > impulse, DArray< Vec3f > J, DArray< Vec3f > B, DArray< float > eta, DArray< TConstraintPair< float > > constraints, DArray< int > nbq, DArray< float > d, DArray< float > mass, float mu, float g, float dt)
void vectorAdd(DArray< float > &ans, DArray< float > &v1, DArray< float > &v2, DArray< TConstraintPair< float > > &constraints)
void calculateK(DArray< TConstraintPair< float > > constraints, DArray< Vec3f > J, DArray< Vec3f > B, DArray< Vec3f > pos, DArray< Mat3f > inertia, DArray< float > mass, DArray< float > K_1, DArray< Mat2f > K_2, DArray< Mat3f > K_3)
void calculateJacobianMatrixForNJS(DArray< Vec3f > J, DArray< Vec3f > B, DArray< Vec3f > pos, DArray< Mat3f > inertia, DArray< float > mass, DArray< Mat3f > rotMat, DArray< TConstraintPair< float > > constraints)
void calculateMatrixA(DArray< Vec3f > &J, DArray< Vec3f > &B, DArray< float > &A, DArray< TConstraintPair< float > > &constraints, float k)
void calculateJacobianMatrix(DArray< Vec3f > J, DArray< Vec3f > B, DArray< Vec3f > pos, DArray< Mat3f > inertia, DArray< float > mass, DArray< Mat3f > rotMat, DArray< TConstraintPair< float > > constraints)
void setUpContactAndFrictionConstraints(DArray< TConstraintPair< float > > constraints, DArray< TContactPair< float > > contactsInLocalFrame, DArray< Vec3f > pos, DArray< Mat3f > rotMat, bool hasFriction)
void updatePositionAndRotation(DArray< Vec3f > pos, DArray< Quat1f > rotQuat, DArray< Mat3f > rotMat, DArray< Mat3f > inertia, DArray< Mat3f > inertia_init, DArray< Vec3f > impulse_constrain)
void calculateLinearSystemLHS(DArray< Vec3f > &J, DArray< Vec3f > &B, DArray< Vec3f > &impulse, DArray< float > &lambda, DArray< float > &ans, DArray< float > &CFM, DArray< TConstraintPair< float > > &constraints)
void preconditionedResidual(DArray< float > &residual, DArray< float > &ans, DArray< float > &k_1, DArray< Mat2f > &k_2, DArray< Mat3f > &k_3, DArray< TConstraintPair< float > > &constraints)
void vectorClampSupport(DArray< float > v, DArray< TConstraintPair< float > > constraints)
void calculateEtaVectorForPJSBaumgarte(DArray< float > eta, DArray< Vec3f > J, DArray< Vec3f > velocity, DArray< Vec3f > angular_velocity, DArray< Vec3f > pos, DArray< Quat1f > rotation_q, DArray< TConstraintPair< float > > constraints, DArray< float > errors, float slop, float beta, uint substepping, float dt)
void JacobiIteration(DArray< float > lambda, DArray< Vec3f > impulse, DArray< Vec3f > J, DArray< Vec3f > B, DArray< float > eta, DArray< TConstraintPair< float > > constraints, DArray< int > nbq, DArray< float > K_1, DArray< Mat2f > K_2, DArray< Mat3f > K_3, DArray< float > mass, DArray< float > fricCoeffs, float mu, float g, float dt)
void ApplyTransform(DArrayList< Transform3f > &instanceTransform, const DArray< Vec3f > &translate, const DArray< Mat3f > &rotation, const DArray< Pair< uint, uint > > &binding, const DArray< int > &bindingtag)
ArrayList< ElementType, DeviceType::GPU > DArrayList
Definition ArrayList.inl:83
void matrixMultiplyVec(DArray< Vec3f > &J, DArray< Vec3f > &B, DArray< float > &lambda, DArray< float > &ans, DArray< TConstraintPair< float > > &constraints, int bodyNum)
void setUpSliderJointConstraints(DArray< TConstraintPair< float > > constraints, DArray< SliderJoint< float > > joints, DArray< Vec3f > pos, DArray< Mat3f > rotMat, DArray< Quat1f > rotQuat, int begin_index)
void preConditionJ(DArray< Vec3f > J, DArray< float > d, DArray< float > eta)
void setUpBallAndSocketJointConstraints(DArray< TConstraintPair< float > > constraints, DArray< BallAndSocketJoint< float > > joints, DArray< Vec3f > pos, DArray< Mat3f > rotMat, int begin_index)
void JacobiIterationForNJS(DArray< float > lambda, DArray< Vec3f > impulse, DArray< Vec3f > J, DArray< Vec3f > B, DArray< float > eta, DArray< TConstraintPair< float > > constraints, DArray< int > nbq, DArray< float > K_1, DArray< Mat2f > K_2, DArray< Mat3f > K_3)
void calculateEtaVectorWithERP(DArray< float > eta, DArray< Vec3f > J, DArray< Vec3f > velocity, DArray< Vec3f > angular_velocity, DArray< Vec3f > pos, DArray< Quat1f > rotation_q, DArray< TConstraintPair< float > > constraints, DArray< float > ERP, float slop, float dt)
void updateGesture(DArray< Attribute > attribute, DArray< Vec3f > pos, DArray< Quat1f > rotQuat, DArray< Mat3f > rotMat, DArray< Mat3f > inertia, DArray< Vec3f > velocity, DArray< Vec3f > angular_velocity, DArray< Mat3f > inertia_init, float dt)
unsigned int uint
Definition VkProgram.h:14
void calculateEtaVectorForPJS(DArray< float > eta, DArray< Vec3f > J, DArray< Vec3f > velocity, DArray< Vec3f > angular_velocity, DArray< TConstraintPair< float > > constraints)
bool saveVectorToFile(const std::vector< float > &vec, const std::string &filename)
void setUpHingeJointConstraints(DArray< TConstraintPair< float > > constraints, DArray< HingeJoint< float > > joints, DArray< Vec3f > pos, DArray< Mat3f > rotMat, DArray< Quat1f > rotation_q, int begin_index)
void setUpGravity(DArray< Vec3f > impulse_ext, float g, float dt)
void calculateContactPoints(DArray< TContactPair< float > > contacts, DArray< int > contactCnt)
void buildCFMAndERP(DArray< Vec3f > J, DArray< Vec3f > B, DArray< TConstraintPair< float > > constraints, DArray< float > CFM, DArray< float > ERP, float hertz, float zeta, float dt)