首页 > 其他分享 >7-hard_constraints

7-hard_constraints

时间:2024-03-13 14:55:05浏览次数:31  
标签:qquad hard collision objects Delta velocity dot constraints

Initially we’ll look at the most common hard constraint—collisions and contact between objects.All the engines we’re building in this book treat hard constraints different from force generators. At the end of the book,we’ll look briefly at alternative approaches that unify them all into one again.

SIMPLE COLLISION RESOLUTION

THE CLOSING VELOCITY

The laws governing the motion of colliding bodies depend on their closing velocity. The closing velocity is the total speed at which the two objects are moving together.This can be simplified to give

\[v_{c} = -(\dot{p}_{a} - \dot{p}_{b}) \cdot \widehat{p_{a} - p_{b}} \qquad \qquad [7.1] \]

where \(v_{c}\) is the closing velocity (a scalar quantity), $p_{a} $ and $p_{b} $ are the positions of objects a and b.Rather than a closing velocity, we have a separating velocity. The closing velocity is the velocity of one object relative to another, in the direction between the two objects.In this case two objects that are closing in on each other will have a negative relative velocity, and objects that are separating will have a positive velocity. Mathematically this is simply a matter of changing the sign of equation 7.1 to give

\[v_{s} = (\dot{p}_{a} - \dot{p}_{b}) \cdot \widehat{p_{a} - p_{b}} \qquad \qquad [7.2] \]

where \(v_{s}\) is the separating velocity.

THE COEFFICIENT OF RESTITUTION

In particular the spring model assumes that momentum is conserved during the collision:

\[m_{a}\dot{p_{a}} + m_{b}\dot{p_{b}} = m_{a}\dot{p_{a}'} + m_{b}\dot{p_{b}'} \qquad \qquad [7.3] \]

Equation 7.3 tells us about the total velocity before and after the collision, but it doesn’t tell us about the individual velocities of each object. The individual velocities are linked together using the closing velocity, according to the equation

\[v_{s}' = -cv_{s} \]

where \(v_{s}'\) is the separating velocity after the collision, \(v_{s}\) is the separating velocity before the collision, and c is a constant called the coefficient of restitution .Using the two equations, we can get values for \(\dot{p_{a}}'\) and \(\dot{p_{b}}'\).

THE COLLISION DIRECTION AND THE CONTACT NORMAL

\[\widehat{n} = (\widehat{p_{a} - p_{b}}) \]

With the correct contact normal, equation 7.2 becomes

\[v_{s} = (\dot{p}_{a} - \dot{p}_{b}) \cdot \widehat{n} \qquad \qquad [7.4] \]

impulses

Rather than a force, this is called an impulse: an instantaneous change in velocity.In the same way that we have

\[f = m \ddot{p} \]

for forces,we have

\[g = m \dot{p} \qquad \qquad \qquad [7.5] \]

for impulses, \(g\) Impulses are often written with the letter \(p\); I will use g to avoid confusion with the position of the object p.

There is a major difference, however, between force and impulse. An object has no acceleration unless it is being acted on by a force: we can work out the total acceleration by combining all the forces using D’Alembert’s principle. On the other hand, an object will continue to have a velocity even if no impulses (or forces) are acting on it. The impulse therefore changes the velocity; it is not completely responsible for the velocity. We can combine impulses using D’Alembert’s principle, but the result will be the total change in velocity, not the total velocity.

COLLISION PROCESSING

COLLISION DETECTION

The collision points will normally be found using a collision detector. So far in the physics engine, we’ve assumed we are dealing with particles, which lets us avoid taking geometry into account at all. we’ll implement a range of useful collision detection routines for full 3D objects in chapter 12.
Some collision detection algorithms can take into account the way objects are moving and try to predict likely collisions in the future. Most simply look through the set of objects and check to see whether any two objects are interpenetrating.

RESOLVING INTERPENETRATION

We expect the collision detector to tell us how far the objects have interpenetrated.

class ParticleContact
{
    // ... Other ParticleContact code as before ...
    /**
    * Holds the depth of penetration at the contact.
    */
    real penetration;
};

To resolve the interpenetration we check the interpenetration depth. If it is already zero or less, then we need take no action; otherwise, we canmove the two objects apart just far enough so that the penetration depth becomes zero.

The total motion of each object is equal to the depth of interpenetration:

\[\Delta p_{a} + \Delta p_{b} = d \]

where \(\Delta p_{a}\) is the scalar distance that object awill bemoved (we’ll return to the direction later). The two distances are related to each other according to the ratio of their masses:

\[m_{a}\Delta p_{a} = m_{b}\Delta p_{b} \]

which combined gives us
\(\Delta p_{a} = \frac{m_{b}}{m_{a} + m_{b}}d\) and \(\Delta p_{b} = \frac{m_{a}}{m_{a} + m_{b}}d\) Combining these with the direction from the contact normal, we get a total change in the vector position of

\[\Delta \mathbf{p}_{a} = \frac{m_{b}}{m_{a} + m_{b}}d \mathbf{n} \]

and

\[\Delta \mathbf{p}_{b} = \frac{m_{b}}{m_{a} + m_{b}}d \mathbf{n} \]

But objects resting (a particle resting on a table, for example)may appear to vibrate and may even leap into the air occasionally.

RESTING CONTACTS

THE CONTACT RESOLVER ALGORITHM

We have three bits of code for performing this update

  • The collision resolution (主要是速度的处理)function that applies impulses to objects to simulate their bouncing apart.
  • The interpenetration resolution function that moves objects apart so that they aren’t partially embedded in one another.
  • The resting contact code that sits inside the collision resolution function and keeps an eye out for contacts that might be resting rather than colliding.

The contact resolver we will use follows this algorithm:

  • Calculate the separating velocity of each contact, keeping track of the contact with the lowest (i.e., most negative) value.
  • If the lowest separating velocity is greater than or equal to zero, then we’re done: exit the algorithm.
  • Process the collision response algorithm for the contact with the lowest separating velocity.
  • If we have more iterations, then return to step 1.

标签:qquad,hard,collision,objects,Delta,velocity,dot,constraints
From: https://www.cnblogs.com/ultramanX/p/18070651

相关文章

  • sharding-jdbc原理
    分片流程一、sql解析从3.0.x版本开始,ShardingSphere统一将SQL解析器换成了基于antlr4实现,目的是为了更方便、更完整的支持SQL,例如对于复杂的表达式、递归、子查询等语句,因为后期ShardingSphere的定位已不仅仅是数据分片功能。抽象语法树根据不同数据库方言所提供的字......
  • 如何理解计算机类论文、机器学习论文、人工智能AI论文中的“soft”和“hard”呢?
    如何理解计算机类论文、机器学习论文、人工智能AI论文中的“soft”和“hard”呢?最近在看论文中总看到带有“soft”和“hard”的专业术语(terminology),一般二者都是作为对比进行出现的,那么问题就是在英文的计算机类论文的表达中这个“soft”和“hard”的区别点是什么?其实这个答案......
  • CF1264D2 Beautiful Bracket Sequence (hard version) 题解
    括号深度的本质,其实就是删除若干个字符以后使得左边一半全是(,右边一半全是),最终(的个数的最大值。那么就一定存在一个位置使得在这个位置以及之前的字符中(的个数等于这个字符后)的个数。考虑枚举这个位置,记它左边的(的个数为\(a\)、?的个数为\(x\),右边的)的个数......
  • AWR1243+DCA1000——硬件触发(Hardware Trigger)
    1引言对于二维滑轨的雷达扫描系统来说,当滑轨系统运动运动速度较慢时,可以忽略其启动和停止时的加速度,而假定导轨在整个导程中是匀速运行的,这时设定雷达信号的帧发射周期即可实现在整个二维扫描平面的均匀采样,此时雷达板发射雷达信号是软件触发的。但值得注意的是,这仍然是一个开......
  • T432580 星云 hard ver.
    原题链接题解一道搜索+模拟搜索每一位可以放哪个值(\([0,9]\)),然后累加搜索下一位注意细节code#include<bits/stdc++.h>usingnamespacestd;#definelllonglongllf[10][105]={0};lln,k;llss(llnow,llleft){if(f[now][left])returnf[now][left];if......
  • Sharding-JDBC源码解析与vivo的定制开发
    作者:vivoIT平台团队-XiongHuanxinSharding-JDBC是在JDBC层提供服务的数据库中间件,在分库分表场景具有广泛应用。本文对Sharding-JDBC的解析、路由、改写、执行、归并五大核心引擎进行了源码解析,并结合业务实践经验,总结了使用Sharding-JDBC的一些痛点问题并分享了对应的定......
  • ulimit.conf中soft和hard区别及常用配置
    在Linux中,ulimit命令用于限制用户对shell资源的访问,包括进程数、文件打开数等。这些限制可以分为软限制(softlimit)和硬限制(hardlimit)。软限制(softlimit)是当前系统生效的设置值,可以理解为一种警告的设定。当资源使用超过这个限制时,系统并不会立即阻止,而是会发出警告信息,提示用户......
  • Maximum And Queries (hard version)
    首先来介绍一下SOSDP看这篇文章解释一下,最开始的初始化for(inti=0;i<(1<<N);i++)f[i]=w[i];就是0/1背包的的初始化,可以模拟一下想一下为啥然后是DP的过程中,注意f[st^(1<<i)]是肯定不会在这一层被更新的(因为(st^(1<<i))&(1<<i)肯定为\(0\)),所以倒序循环还是正序循环是无所谓的......
  • Codeforces 1446D2 Frequency Problem (Hard Version)
    考虑求出全局的众数\(A\)。那么有一个结论,就是答案区间的众数中绝对有\(A\)。考虑反证法,如果没有\(A\),\(A\)在序列中出现的个数一定\(\ge\)区间内众数的出现个数,所以可以一直往外扩展直到\(A\)出现的个数与区间内非\(A\)众数的个数持平,这样肯定更优。于是可以考虑钦......
  • CF1209G2 Into Blocks (hard version) 题解
    Description给你\(n\),\(q\),\(n\)表示序列长度,\(q\)表示操作次数。我们需要达成这么一个目标状态:如果存在\(x\)这个元素,那么必须满足所有\(x\)元素都必须在序列中连续。然后你可以进行这么一种操作,将所有的\(x\)元素的变为任意你指定的\(y\)元素,并且花费\(cnt[x......