GAMES101-现代计算机图形学入门-闫令琪——Lecture 22 Animation Cont 学习笔记【完结】
Lecture 22 Animation Cont
一、Single particle simulation
First study motion of a single particle
- Later, generalize to a multitude of particles
To start, assume motion of particle determined by a velocity vector field that is a function of position and time: v(x, t)
假设把粒子放在某个速度场内,那么粒子应该会随着速度场而运动,那么就要模拟这个粒子速度随时间变化的过程。
Ordinary Differential Equation (ODE)
Computing position of particle over time requires solving a firstorder ordinary differential equation:
“First-order” refers to the first derivative being taken.
“Ordinary” means no “partial” derivatives, i.e. x is just a function of t.
We can solve the ODE, subject to a given initial particle position x0, by using forward numerical integration
这里用常微分方程去求速度。
(一)、Euler’s Method (a.k.a. Forward Euler, Explicit Euler)
- Simple iterative method
- Commonly used
- Very inaccurate
- Most often goes unstable
最简单的一种方法就是把时间分成小段,每一个小块计算时间△t。知道某个时刻t的位置和速度,计算下一时刻t+△t的位置和速度。
Euler’s Method - Errors
With numerical integration, errors accumulate Euler integration is particularly bad
Example:
如图,用不同大小的步长△t,得到的结果会不同,△t分的越小,得到的结果就会越准。
Instability of the Euler Method
对于这样一个环型速度场,无论取多小的步长△t,得到的轨迹都不可能沿着一个环走,因为速度的方向一直在改变,每一步总会有偏差,那么这个偏差是不断累积的,就会偏的越来越多最后飞出去。
Two key problems:
- Inaccuracies increase as time step Δt increases
- Instability is a common, serious problem that can cause simulation to diverge
因此欧拉方法的两个问题就是:误差和不稳定
Errors and Instability
Solving by numerical integration with finite differences leads to two problems:
Errors
- Errors at each time step accumulate. Accuracy decreases as simulation proceeds
- Accuracy may not be critical in graphics applications
Instability
- Errors can compound, causing the simulation to diverge even when the underlying system does not
- Lack of stability is a fundamental problem in simulation, and cannot be ignored
(二)、Combating Instability
Midpoint method / Modified Euler
- Average velocities at start and endpoint
Adaptive step size
- Compare one step and two half-steps, recursively, until error is acceptable
Implicit methods
- Use the velocity at the next time step (hard)
Position-based / Verlet integration
- Constrain positions and velocities of particles after time step
1、Midpoint Method
中点法
- Compute Euler step (a)
- Compute derivative at midpoint of Euler step (b)
- Update position using midpoint derivative ©
中点法:
①、由于一开始出发点有位置和速度,可以直接用欧拉方法模拟得到点a
②、取中点b,考虑中点所在的速度
③、利用中点所在的速度,回到出发点,再算一次欧拉方法,得到点c
这样算出来的值就比直接用欧拉方法算出来的效果好很多。
- Average velocity at start and end of step
- Better results
将式子整理写开可以发现,中点法比欧拉方法多了一个二次的项,相当于在模拟抛物线,因此更准确
2、Adaptive Step Size
自适应方法
Adaptive step size
- Technique for choosing step size based on error estimate
- Very practical technique
- But may need very small steps!
Repeat until error is below threshold:
- Compute xT an Euler step, size T
- Compute xT/2 two Euler steps, size T/2
- Compute error || xT – xT/2 ||
- If (error > threshold) reduce step size and try again
原始点在用欧拉方法计算经过△t后运动到了xT点,显然不是很准,那么这时候把时间减半变成△t/2,用△t/2通过欧拉方法算两遍,第一遍算到了原始点和xT的中点,第二次算到了xT/2这个点。然后比较xT和xT/2的位置,如果差的很远,那么就应该把时间再分的更小去计算。直到两个点的位置差不多,说明时间已经分的足够小了,这时候得到的结果是比较准确的。
3、Implicit Euler Method
隐式欧拉方法
- Informally called backward methods
- Use derivatives in the future, for the current step
下一时刻位置是用下一时刻的速度和加速度计算的。
- Solve nonlinear problem for xt+△tand x˙\dot{x}x˙t+△t
- Use root-finding algorithm, e.g. Newton’s method
- Offers much better stability
但是这个式子并不是很好解。假设下一时刻加速度知道,那么可以用各种优化方法来解。隐式欧拉方法可以提供很好的稳定性。
How to determine / quantize “stability”?
We use the local truncation error (every step) / total accumulated error (overall)
Absolute values do not matter, but the orders w.r.t. step
Implicit Euler has order 1, which means that
--Local truncation error: O(h²) and
--Global truncation error: O(h) (h is the step, i.e. ∆t)
Understanding of O(h)
--If we halve h, we can expect the error to halve as well
如何定义这个方法是不是稳定的以及多么稳定?
通常对数值方法会定义两个概念:局部截断误差(每一步会产生的误差)和整体误差(每一步的局部截断误差的累积)
研究这两个数没有太大意义,但是研究他们的阶(误差与△t的关系)有意义。
隐式欧拉方法是一阶的,也就是局部误差是O(h2),整体误差是O(h)。这里h指的是取的步长△t。
如何理解O(h)?如果把h(△t)减小一半,那么期望误差也会跟着减小1/2。
对于 O(h2)来讲,如果把h(△t)减小一半,那么误差会减小到1/4。
如果有O(h3),那么如果把h(△t)减小一半,那么误差会减小到1/8。
因此阶数越高误差越小。
4、Runge-Kutta Families
A family of advanced methods for solving ODEs
- Especially good at dealing with non-linearity
- It’s order-four version is the most widely used, a.k.a. RK4
龙格库塔方法特别适合解微分方程,尤其是对于非线性的。
RK4:
5、Position-Based / Verlet Integration
Idea:
- After modified Euler forward-step, constrain positions of particles to prevent divergent, unstable behavior
- Use constrained positions to calculate velocity
- Both of these ideas will dissipate energy, stabilize
Pros / cons
- Fast and simple
- Not physically based, dissipates energy (error)
不基于物理的方法,通过调整不同位置使得满足某种限制。但是由于不是基于物理的方法,因此不满足能量守恒。
二、Rigid Body Simulation
Simple case
- Similar to simulating a particle
- Just consider a bit more properties
对于刚体的模拟类似于对单个粒子的模拟,但是会更多的考虑刚体本身的物理量。
三、Fluid Simulation
A Simple Position-Based Method
Key idea
- Assuming water is composed of small rigid-body spheres
- Assuming the water cannot be compressed (i.e. const. density)
- So, as long as the density changes somewhere, it should be “corrected” via changing the positions of particles
- You need to know the gradient of the density anywhere w.r.t. each particle’s position
- Update? Just gradient descent!
整个水体是由很多不可压缩的刚体小球组成。通过模拟这些小球的运动位置,来模拟整个水体的运动,最后再渲染出来。
这里假设整个水是不可压缩的。也就是在任何一个时刻任何一个地方的密度相同。
通过任何一个时刻小球的分布都可以知道某个小球周围的密度。如果有任何一个地方的密度和之前平静的水在这个位置的密度不一样,那么就需要通过移动小球把这个地方的密度修正回来。通过不断的根据小球分布计算不同位置的密度,不断的修正,就可以将水模拟出来。这种方式是不基于物理的。
Eulerian vs. Lagrangian
Two different views to simulating large collections of matters
在物理中模拟大规模物质的两种方法:
质点法(拉格朗日方法):如刚刚对水体的模拟,认为水是由各个圆形的小水滴组成的,通过模拟各个小水滴的运动来模拟整个的水体运动。
网格法(欧拉方法):把空间划分成网格,计算不同网格中不同时间密度的变化来模拟。
Material Point Method (MPM)
Hybrid, combining Eulerian and Lagrangian views
- Lagrangian: consider particles carrying material properties
- Eulerian: use a grid to do numerical integration
- Interaction: particles transfer properties to the grid, grid performs update, then interpolate back to particles
结合拉格朗日方法和欧拉法。
首先认为不同的粒子具有某些材质属性(如上图这是一只会融化的兔子,粒子间有粘性、粒子有质量等),然后融化过程通过网格去计算,算出来之后再把信息写回每个粒子中去。
GAMES101-现代计算机图形学入门-闫令琪——Lecture 22 Animation Cont 学习笔记【完结】相关推荐
- GAMES101-现代计算机图形学入门-闫令琪——Lecture 05 Rasterization 1 (Triangles)
GAMES101-现代计算机图形学入门-闫令琪--Lecture 05 Rasterization 1 (Triangles) 目录 GAMES101-现代计算机图形学入门-闫令琪--Lecture ...
- GAMES101-现代计算机图形学入门-闫令琪——Lecture 19 Cameras and Lenses 学习笔记
Lecture 19 Cameras and Lenses 一.Camera 1.Pinhole Image Formation 最早的相机是从小孔成像开始的. 2.Important Parts ( ...
- 现代计算机图形学入门-闫令琪 17课基本材质
日出效果:尘埃分解光线画面.水柱之间有透明渐变和表面起伏反射.洞穴中间的聚光线发生的反射.飘起的头发发生的反射.布料材质反射的光线不同.蝴蝶的鳞片起伏反射.光晕的效果是中间灰两边亮.鱼片的表面的次反射 ...
- GAMES101-现代计算机图形学入门-闫令琪 - lecture15 光线追踪3 - 辐射度量学、渲染方程(Ray Tracing 3) - 课后笔记
光线追踪3 - 辐射度量学.渲染方程和全局光照 内容: 辐射度量学 光线传输(Light transport) 反射方程(The reflection equation) 渲染方程(The rende ...
- GAMES101-现代计算机图形学入门-闫令琪 - lecture13 光线追踪1(Ray Tracing 1 - Whitted-Style Ray Tracing) - 课后笔记
光线追踪1 (Ray Tracing 1 - Whitted-Style Ray Tracing) 课程一共分为四个大的板块,目前已经学习了光栅化和几何,可以实现图1和2的效果,下面要来学习第三个大的 ...
- GAMES101-现代计算机图形学入门-闫令琪 - lecture9 着色3(Shading 3) - 课后笔记
着色3(Shading 3) 重心坐标 纹理查询 纹理应用 插值 - 重心坐标 (Barycentric Coordinates) 为什么要插值? 能够获得三角形三个固定顶点的属性,但是不知道三角形内 ...
- GAMES101-现代计算机图形学入门-闫令琪 - lecture14 光线追踪2 - 加速结构(Ray Tracing 2 - Acceleration) - 课后笔记
光线追踪2 - 加速结构(Ray Tracing 2 - Acceleration) 对AABB结构优化来加速光线追踪的速度 均匀网格(Uniform grids) 空间划分(Spatial part ...
- 一篇学完:GAMES101:现代计算机图形学入门 学习笔记
文章首发于lengyueling.cn 欢迎访问交流! PDF版本已经附在lengyueling.cn文章末尾,需要自取. 导论 图形学应用场景 电子游戏: PBR:之狼 卡通渲染:无主之地 电影:黑 ...
- GAMES101现代计算机图形学入门-第一节-图形学导论
最近在为之后找工作面试做准备,所以把大二学习的计算机图形学又拿出来重新学起来了,也推荐大家一起看闫大神的课!!! 然后笔记是在lengyueling大佬的版本上进行的修改,总体还是大佬的模板. 希望大 ...
- GAMES101现代计算机图形学入门——几何表示之曲线与曲面
此为个人学习笔记,总结内容来源于网络各个平台,如有错误欢迎指摘 几何表示 曲线与曲面 本节附加资料: Making things with Maths (acko.net) 游戏开发技术杂谈2:理解插 ...
最新文章
- python 网络编程之Socket通信案例消息发送与接收
- js导出的xlsx无法打开_js-xlsx实现文件导出、下载(excel)
- 真强啊!建议每一位Java程序员都读读Dubbo心跳设计的源码...
- javafx之TableView的TaleCell
- 前端学习(3317):connect 2
- 【AI视野·今日CV 计算机视觉论文速览 第156期】Mon, 9 Sep 2019
- hdu 4536 dfs
- iOS App 签名的原理 App 重签名(二)
- 骑士CMS文件包含+getshell漏洞复现(python自动化验证扫描漏洞)
- (20200108)matlab弹出对话框形式打开和读取指定文件,不用提前输入文件名——uigetfile
- linux flash 存储寿命,关于 Flash 存储,你应该知道的一些事情
- 软件以人为本5 - 敏捷3 - 拯救每日立会2
- 图片太大怎么压缩变小?图片如何压缩?
- 推荐一个 推理屋 网站
- excel 批量生成条码
- 微信扫描二维码跳转手机默认浏览器打开下载app的链接是怎么实现的
- 嵌入式毕设分享 stm32人体健康状态检测系统(项目开源)
- c++小游戏(王者荣耀极简)
- 深入了解示波器(一):示波器分类
- 数字孪生技术辅助山洪灾害预警与应急联动
热门文章
- Sql server 2008
- 联想Thinkpad sl400 7HC入手感觉
- c# 非阻塞算法_c# – 了解非阻塞线程同步和Thread.MemoryBarrier
- SLIC 超像素分割(C++)
- 计算机网络是指将多台具有独立功能,计算机等级考试四级网络工程师2015年模拟试题及答案(三)...
- 数据可视化:推荐6个数据可视化工具软件平台
- TeXLive升级教程
- 安装这5个插件后,PyCharm好用到起飞
- 最完整的国内手机号段
- centos 的 tar 命令