当前位置:网站首页>Treatment of particle boundary collision
Treatment of particle boundary collision
2022-07-24 00:35:00 【beidou111】
Deal with collisions for individual particles :
First , To determine whether particles penetrate the boundary , If it penetrates , It's a collision . This is achieved by collision detection algorithm . This algorithm is very complex , Especially when multiple objects and complex surfaces are involved . Let's not discuss , Just discuss the simplest case .
Suppose we have detected a collision , And we know the normal direction of the wall N. Also know the current particle speed and position .
that
- Judge v ⋅ N < 0 ? v\cdot N < 0? v⋅N<0? The former means that the speed should continue to move in the direction of penetrating the boundary . If not , It means that the particles have moved in the direction of leaving the solid , It is likely that it has been handled at the last moment , But the particles that haven't left yet .
- According to the normal direction of the wall N, Disassemble the speed into normal and tangential . Then multiply the normal by the normal attenuation coefficient and reverse , Multiply the tangent by the tangent attenuation coefficient . However, it should be noted that the tangential attenuation coefficient is calculated according to Coulomb's law of friction . The calculated value is related to the ratio of normal velocity to tangential velocity .
- Recombine normal and tangential velocities . Then move the particles .
Reference resources :games103 Hua Min Wang

import taichi as ti
import random
x = random.randint(0, 9)
y = random.randint(-3, 3)
velocities = ti.Vector([x, y, 0])
print(velocities)
n_dir = ti.Vector([0, 1, 0]).normalized()
vn = velocities.dot(n_dir) * n_dir
vt = velocities - vn
vt_norm = vt.norm()
vn_norm = vn.norm()
print(f"vn_norm:{
vn_norm}; vt_norm:{
vt_norm}")
if(velocities.dot(n_dir) < 0 and vt_norm != 0):
mu_N = 1
mu_T = 1
vn_new = -mu_N * vn
a = ti.max((1 - mu_T * (1 + mu_N) * vn.norm() / vt_norm ), 0)
print(1 - mu_T * (1 + mu_N) * vn.norm() / vt_norm )
print(f"a={
a}")
vt_new = a * vt
v_new = vn_new + vt_new
print(v_new)
边栏推荐
- inode、软链接、硬链接
- 网络系统实验:ping不通的问题解决
- 《天幕红尘》笔记与思考(六)因缺而需
- Easy gene | target gene DNA methylation sequencing (target BS)
- Flutter | the easiest way to add header and footer to listview
- Multi data source configuration of mongodb
- Gbase 8C access authority query function (V)
- English语法_指示代词 - So
- Pytest interface automation test framework | summary
- Redis cluster hash sharding algorithm (slot location algorithm)
猜你喜欢

Classic examples of C language - adding two scores

PayPal subscription process and API request
![[video game training] non contact object size and shape measurement 2020 video game G](/img/b7/d70a702e52062e38176b589eb15415.jpg)
[video game training] non contact object size and shape measurement 2020 video game G

Network system experiment: solve the problem of Ping failure

XXL job realizes the code parsing of email sending warnings (line by line code interpretation)

English grammar_ Demonstrative pronoun -such / the same

Flutter | the easiest way to add header and footer to listview

First knowledge of C language functions

Table custom table encapsulation

MySQL client to server character set conversion
随机推荐
Classic examples of C language switch case statement conversion date format
English grammar_ Demonstrative pronoun -such / the same
Semaphore
Detailed overview of data standards -2022
sed 深入理解与使用
Problem note - unable to open include file: "direct.h": no such file or directory
《天幕红尘》笔记与思考(五)强势文化与弱势文化
The prediction of domestic AI protein structure reproduced a breakthrough and solved the 3D structure with a single sequence. Peng Jian's team: "the last piece of puzzle since alphafold2 has been comp
MySQL data query (select)
JS drag and drop element
Mobile terminal H5 - a lifeline timeline
English grammar_ Demonstrative pronoun - so
Pytest interface automated test framework | pytest generates simple test reports
Sed in-depth understanding and use
泛型机制和增强for循环
Codeforces Round #807 (Div. 2)(A-D)
GBase 8c访问权限查询函数(六)
Redis持久化机制RDB、AOF
Flutter | firstwhere error reporting
Redis cluster hash sharding algorithm (slot location algorithm)