Stan Melax Graphics Software Engineer, Intel 3D Interaction Happens - - PowerPoint PPT Presentation

β–Ά
stan melax graphics software engineer intel 3d
SMART_READER_LITE
LIVE PREVIEW

Stan Melax Graphics Software Engineer, Intel 3D Interaction Happens - - PowerPoint PPT Presentation

Interaction With 3D Geometry Stan Melax Graphics Software Engineer, Intel 3D Interaction Happens with Geometric Objects Rigid Body Skinned Characters Soft Body { { { Mesh geometry; Mesh geometry; Mesh geometry; Vec3 position; Vec3


slide-1
SLIDE 1

Interaction With 3D Geometry

Stan Melax Graphics Software Engineer, Intel

slide-2
SLIDE 2

3D Interaction Happens with Geometric Objects

Rigid Body

Skinned Characters

Soft Body

{ Mesh geometry; Vec3 position; Quat orientation; }; { Mesh geometry; Vec3 position[]; Quat orientation[]; }; { Mesh geometry; Springs connectivity; };

slide-3
SLIDE 3

Agenda – Interacting with 3D Geometry

Practical topics among:

  • Core Geometry Concepts
  • Convex Polyhedra
  • Spatial and Mass Properties
  • Soft Geometry and Springs

With examples and implementation issues.

slide-4
SLIDE 4

Warning: Some Math Ahead

u v b a u v u v

𝑣 βˆ™ 𝑀 > 0

u v

𝑣 βˆ™ 𝑀 < 0

u v

𝑣 Γ— 𝑀

u v 𝑀 Γ— 𝑣

Vector Arithmetic Dot Product Cross Product

𝑁𝑀 =

𝑛00 𝑛01 𝑛02 𝑛10 𝑛11 𝑛12 𝑛20 𝑛21 𝑛22 𝑀𝑦 𝑀𝑧 𝑀𝑨

Matrix Stuff

π‘£π‘€π‘ˆ = 𝑣𝑦𝑀𝑦 𝑣𝑦𝑀𝑧 𝑣𝑦𝑀𝑨 𝑣𝑧𝑀𝑦 𝑣𝑧𝑀𝑧 𝑣𝑧𝑀𝑨 𝑣𝑨𝑀𝑦 𝑣𝑨𝑀𝑧 𝑣𝑨𝑀𝑨

𝑒𝑔 𝑒𝑀 = πœ–π‘”

𝑦

πœ–π‘€π‘¦ πœ–π‘”

𝑦

πœ–π‘€π‘§ πœ–π‘”

𝑦

πœ–π‘€π‘¨ πœ–π‘”

𝑧

πœ–π‘€π‘¦ πœ–π‘”

𝑧

πœ–π‘€π‘§ πœ–π‘”

𝑧

πœ–π‘€π‘¨ πœ–π‘”

𝑨

πœ–π‘€π‘¦ πœ–π‘”

𝑨

πœ–π‘€π‘§ πœ–π‘”

𝑨

πœ–π‘€π‘¨

slide-5
SLIDE 5

What’s an β€œouter product”?

𝑣 βˆ™ 𝑀 = π‘£π‘ˆπ‘€ = 𝑣𝑦 𝑣𝑧

𝑣𝑨

𝑀𝑦 𝑀𝑧 𝑀𝑨 = 𝑣𝑦𝑀𝑦 + 𝑣𝑧𝑀𝑧 + 𝑣𝑨𝑀𝑨

𝑣⨂𝑀 = π‘£π‘€π‘ˆ = 𝑣𝑦 𝑣𝑧 𝑣𝑨 𝑀𝑦 𝑀𝑧 𝑀𝑨 = 𝑣𝑦𝑀𝑦 𝑣𝑦𝑀𝑧 𝑣𝑦𝑀𝑨 𝑣𝑧𝑀𝑦 𝑣𝑧𝑀𝑧 𝑣𝑧𝑀𝑨 𝑣𝑨𝑀𝑦 𝑣𝑨𝑀𝑧 𝑣𝑨𝑀𝑨

Familiar dot or inner product: Outer product:

slide-6
SLIDE 6

Outer Product - Geometric View

Outer product 𝒗 βŠ— 𝒗 of a unit vector 𝒗 projects any vector along that direction.

u v u v

𝑣 = 1

𝑣 βˆ™ 𝑀

u v

𝑣(𝑣 βˆ™ 𝑀) 𝑣 𝑣 βˆ™ 𝑀 = 𝑣 βŠ— 𝑣 𝑀 𝑣 𝑣 βˆ™ 𝑀 β‰  𝑣 βˆ™ 𝑣 𝑀

Distance of v along u (scalar) Projection of v along u (vector)

slide-7
SLIDE 7

Outer Product for Plane Projection

𝑱 βˆ’ 𝒗 βŠ— 𝒗 projects any vector onto plane with normal 𝒗.

u v

(𝑣 βŠ— 𝑣)𝑀

𝑀 βˆ’ 𝑣 𝑣 βˆ™ 𝑀

u v u v

𝑀 βˆ’ 𝑣 𝑣 βˆ™ 𝑀 = 𝐽𝑀 βˆ’ 𝑣 βŠ— 𝑣 𝑀 = (𝐽 βˆ’ 𝑣 βŠ— 𝑣 )𝑀

𝑣 𝑣 βˆ™ 𝑀

  • r

βˆ’π‘£ 𝑣 βˆ™ 𝑀 βˆ’π‘£ 𝑣 βˆ™ 𝑀

Remove portion of v that runs along u

slide-8
SLIDE 8

Numerical Precision Issues

3 β€œcollinear” points

slide-9
SLIDE 9

Triangles and Planes

  • Specify Front and Back

Could use: 𝐡𝑦 + 𝐢𝑧 + 𝐷𝑨 == 𝐸 Prefer convention: 𝐡𝑦 + 𝐢𝑧 + 𝐷𝑨 + 𝐸 == 0 Given a point [xyz] its distance above plane is: π‘žπ‘¦ 𝑦 + π‘žπ‘§ 𝑧 + π‘žπ‘¨ 𝑨 + π‘žπ‘₯

  • <0 below
  • =0 on plane
  • >0 above

π‘žπ‘¦ π‘žπ‘§ π‘žπ‘¨ Plane π‘ž = π‘žπ‘¦ π‘žπ‘§ π‘žπ‘¨ π‘žπ‘₯ 0 0 0 π‘žπ‘₯ Triangle (𝑏 𝑐 𝑑) CCW winding

a b c

slide-10
SLIDE 10

Intersection of 3 planes

𝑄 = π‘ž0𝑦 π‘ž0𝑧 π‘ž0𝑨 π‘ž1𝑦 π‘ž1𝑧 π‘ž1𝑨 π‘ž2𝑦 π‘ž2𝑧 π‘ž2𝑨 , 𝑐 = π‘ž0π‘₯ π‘ž1π‘₯ π‘ž2π‘₯ , 𝑀 = 𝑀𝑦 𝑀𝑧 𝑀𝑨 p0 p1 p2 p0 p1 p2 v

𝑄𝑀 = βˆ’π‘ 𝑀 = βˆ’π‘„βˆ’1𝑐

π‘ž0𝑦 𝑀𝑦 + π‘ž0𝑧 𝑀𝑧 + π‘ž0𝑨 𝑀𝑨 + π‘ž0π‘₯ == 0 π‘ž1𝑦 𝑀𝑦 + π‘ž1𝑧 𝑀𝑧 + π‘ž1𝑨 𝑀𝑨 + π‘ž1π‘₯ == 0 π‘ž2𝑦 𝑀𝑦 + π‘ž2𝑧 𝑀𝑧 + π‘ž2𝑨 𝑀𝑨 + π‘ž2π‘₯ == 0

slide-11
SLIDE 11

What if we have 4 planes?

As house grows bottom up, how will the 4 roof planes come together at the top of this house?

Floor Only Walls Roof Planes Roof Planes

  • verhead view

Example:

slide-12
SLIDE 12

Determining How 4 Planes Meet

? π‘ž0𝑦 π‘ž0𝑧 π‘ž1𝑦 π‘ž1𝑧 π‘ž0𝑨 π‘ž0π‘₯ π‘ž1𝑨 π‘ž1π‘₯ π‘ž2𝑦 π‘ž2𝑧 π‘ž3𝑦 π‘ž3𝑧 π‘ž2𝑨 π‘ž2π‘₯ π‘ž3𝑨 π‘ž3π‘₯ 𝑦 𝑧 𝑨 1 = p0 p1 p2 p3

Note: these are top down views

  • f a convex region

If 4 planes meet at a point xyz then we’ve found a solution to: Only possible if matrix singular.

slide-13
SLIDE 13

Determining How 4 Planes Meet

? d==0 d<0 d>0 d = π‘ž0 π‘ž1 π‘ž2 π‘ž3 = π‘ž0𝑦 π‘ž1𝑦 π‘ž0𝑧 π‘ž1𝑧 π‘ž2𝑦 π‘ž3𝑦 π‘ž2𝑧 π‘ž3𝑧 π‘ž0𝑨 π‘ž1𝑨 π‘ž0π‘₯ π‘ž1π‘₯ π‘ž2𝑨 π‘ž3𝑨 π‘ž2π‘₯ π‘ž3π‘₯ p0 p1 p2 p3

Notes: these are top down views of a convex region. Planes well β€œbehaved” all point same way. Planes in CCW order. Det of any 3x3 subblock from first 3 xyz rows is >0.

slide-14
SLIDE 14

Intersect Line Plane

p v1 v0

time

distance above plane

1

π‘žπ‘¦π‘§π‘¨ βˆ™ 𝑀𝑒 + π‘žπ‘₯

π’†πŸ

t=? 𝑒 = βˆ’π‘’0 𝑒1 βˆ’ 𝑒0

π‘žπ‘¦π‘§π‘¨ = π‘žπ‘¦ π‘žπ‘§ π‘žπ‘¨

π‘—π‘›π‘žπ‘π‘‘π‘’ = 𝑀0 + 𝑀1 βˆ’ 𝑀0 𝑒

𝑒𝑗𝑑𝑒 = π‘žπ‘₯ 𝑒1 = π‘žπ‘¦π‘§π‘¨ βˆ™ 𝑀1 +π‘žπ‘₯ π‘žπ‘¦π‘§π‘¨ 𝑒0 = π‘žπ‘¦π‘§π‘¨ βˆ™ 𝑀0 +π‘žπ‘₯

π’†πŸ

= βˆ’ π‘žπ‘¦π‘§π‘¨ βˆ™ 𝑀0 + π‘žπ‘₯ (π‘žπ‘¦π‘§π‘¨ βˆ™ 𝑀1 + π‘žπ‘₯) βˆ’ (π‘žπ‘¦π‘§π‘¨ βˆ™ 𝑀0 + π‘žπ‘₯)

slide-15
SLIDE 15

Simple Ray Triangle Intersection Test

  • Intersect ray with plane and

get a point p.

  • For each edge va to vb
  • Cross product with p-va
  • Dot result with tri normal n
  • <0 means outside
  • Backside hit if dot(n,ray)>0

p

slide-16
SLIDE 16

Ray Mesh Intersection

  • Check Against Every Polygon
  • (spatial structures can rule out many

quickly)

  • Detecting a β€œhit” - might not be closest
  • Numerical Robustness – don’t slip

between two adjacent triangles.

  • Mesh β€œintact” – t-intersections, holes

caused by missing triangles.

Multiple impact points – take closest. Numeric precision can result in plane intersection point landing just

  • utside each time, thus missing

both neighbors.

slide-17
SLIDE 17

Solid Geometry

  • β€œWater-Tight” borderless manifold mesh:
  • Every edge has 1 adjacency edge going
  • ther way
  • Consistent winding. Polygon normals all

face to exterior.

  • The mesh is the boundary representation
  • the infinitely thin surface that separates

solid matter from empty space.

slide-18
SLIDE 18

Inside/Outside Test of a point

  • Cast a long ray from point
  • point is inside if it first hits

the backside of a polygon.

  • point is outside the object if

it first hits a front side or nothing at all. ray p

slide-19
SLIDE 19

Convex Polyhedra

slide-20
SLIDE 20

Convex Mesh

  • Neighboring face normals tilt away.
  • Volume bounded by a number of planes.
  • Every vertex lies at or below every face.

Many algorithms much easier when using convex shapes instead of general meshes. 𝐿 π‘‘π‘π‘œπ‘€π‘“π‘¦ ↔ βˆ€π‘, 𝑐 ∈ 𝐿 β†’ 𝑏𝑐 βŠ† 𝐿

𝒃 𝒄 𝑳

Math textbook:

slide-21
SLIDE 21

Convex In/Out test

A point is inside a convex volume if it lies under every plane boundary. No testing with vertices or edges. p q w

slide-22
SLIDE 22

Convex Ray Intersection

  • Crop Ray with all front facing planes: π‘œ βˆ™ 𝑀1 βˆ’ 𝑀0 < 0
  • Impact at v0 if under all backside planes

v1 v0 v0 v0 v0

slide-23
SLIDE 23

Convex Line-Segment Intersection

  • Trim v0 for Front facing planes π‘œ βˆ™ 𝑀1 βˆ’ 𝑀0 < 0
  • Trim v1 for Back facing planes π‘œ βˆ™ 𝑀1 βˆ’ 𝑀0 > 0

v0 v1 v0 v1 v0 v1

slide-24
SLIDE 24

Convex-Convex Contact

  • Separating Axis Theorem –

Two non touching convex polyhedra are separated by a plane.

  • The contact between two touching

convex polyhedra will be either

  • A point
  • A line segment
  • A convex polygon

Physics engines like convex objects

slide-25
SLIDE 25

Convex Hull from points

Convex Hull - smallest convex polyhedron that contains all the points.

  • Convex hull of a mesh will contain the mesh.
  • Often a sufficient proxy for interaction and

collision

Techniques

  • Expanding outward: QuickHull [Eddy ’77]
  • Reducing inward: Gift Wrapping [Chand ’70]
slide-26
SLIDE 26

Compute 3D Convex Hull

  • Start with 2 back to back
  • triangles. (or a tetrahedron)
  • Find a vertex outside current

volume (above faces).

  • Find edge loop silhouette (around

all faces below point)

  • Replace with new fan of polys
  • Remove Folds (if any)
  • Rinse and Repeat
slide-27
SLIDE 27

Hull Numerical Robustness

Generated skinny triangle with bad normal. Flip edge to fix Grow Hull

slide-28
SLIDE 28

Hull Tri-Tet Implementation

  • Simple Triangle-mesh based approach
  • When point d above any [abc] add tetrahedron

[abcd] (triangles [acb][dab][dbc][dca]) to mesh.

  • Prune any back-to-back tris such as [abc] and [bac]

a c b

d

a c b d a c b d

slide-29
SLIDE 29

Hull Tri-Tet Numeric Robustness

b a c d e

  • 5 points {a,b,c,d,e} are coplanar-ish at one end of the point cloud
  • But next point e tests above triangle [abc] but below [adb].
  • Silhouette is {abc} for which we extrude a new tetrahedron up to e
  • This produces triangles [eca],[ebc] (blue) facing the right way and

[eab] (red) facing the wrong way – based on known interior point.

  • This provides the hindsight to see that [adb] should also be extruded

b c e b c e a a d d b c e a d

slide-30
SLIDE 30

Simplified Convex Hull

  • Off-the-shelf solutions typically

generate the complete hull.

  • All hull vertices may not be needed

and may be inefficient for usage.

  • Instead use greedy incremental

algorithm picking next vertex that increases hull size the most.

  • Stop when vertex count or error

threshold reached Full Hull Simplified

slide-31
SLIDE 31

Minimize Number of Planes vs Points

Minimize Planes:

  • Compute full hull
  • Dual points

π‘žπ‘¦ π‘žπ‘₯ π‘žπ‘§ π‘žπ‘₯ π‘žπ‘¨ π‘žπ‘₯

  • Compute simplified hull
  • Take Dual

12 Vertices 20 Planes 20 Vertices 12 Planes

slide-32
SLIDE 32

Convex Decomposition

Manual Creation of Collision Proxy Automatic Mesh Decomposition [Ratcliff], [Mamou] Use skinned mesh bone weights to create collision hulls

3DS Max Screenshot

slide-33
SLIDE 33

Example: Convex Bones For Collisions

Ragdolls on Stairs Hand catching coins

slide-34
SLIDE 34

Constructive Solid Geometry Boolean Operations

slide-35
SLIDE 35

Solid Geometry Boolean Operations

slide-36
SLIDE 36

Applications for Booleans

Art tools (already have CSG)

  • Modeling and level design

Game Usages (less fidelity required):

  • Destruction
  • Geomod (tunneling)

A convex based approach may suffice.

slide-37
SLIDE 37

Convex Cropping and Intersection

  • Like general mesh cropping,

but only 1 open loop that is itself a convex polygon.

  • Intersecting two convexes

can be done by cropping one with all the planes of the other

  • Non-convex operands can be

implemented as a union

slide-38
SLIDE 38

Convex Cropping Robustness

  • Floating point issues can occur even in this most

basic of mesh operations.

  • One solution is to utilize plane equations to

determine face/plane connectivity.

Correct Slice Bad Slice Pre Slice

slide-39
SLIDE 39

Robustness with Quantum Planes

Let all planes p of CSG Boolean operands satisfy:

𝑁 = 𝑑0π‘ž0𝑦 𝑑0π‘ž0𝑧 𝑑0π‘ž0𝑨 𝑑1π‘ž1𝑦 𝑑1π‘ž1𝑧 𝑑1π‘ž1𝑨 𝑑2π‘ž2𝑦 𝑑2π‘ž2𝑧 𝑑2π‘ž2𝑨 𝑀 = βˆ’π‘βˆ’1 𝑑0π‘ž0π‘₯ 𝑑1π‘ž1π‘₯ 𝑑2π‘ž2π‘₯

βˆ€π‘žβˆƒπ‘‘ ∢ π‘‘π‘ž = 𝑑 π‘žπ‘¦ 𝑑 π‘žπ‘§ 𝑑 π‘žπ‘¨ 𝑑 π‘žπ‘₯ , 𝑑 π‘ž{𝑦,𝑧,𝑨,π‘₯} ∈ β„€, π‘‘π‘ž{𝑦,𝑧,𝑨} ≀ 𝑙

βˆƒπ‘, 𝑐: 𝑀{𝑦,𝑧,𝑨}= 𝑏 𝑐 , 𝑏, 𝑐 ∈ β„€ , 𝑐 ≀ det 𝑁 ≀ 6𝑙3

∴ βˆƒπœβˆ€π‘£, 𝑀: 𝑣 βˆ’ 𝑀 < 𝜁 ↔ 𝑣 = 𝑀

Recall how vertices are the intersection of 3 or more planes Generated points have Finite denominator A fixed epsilon can now be used to indicate if two points are the same.

slide-40
SLIDE 40

Destruction – geometry modification

Texturing break

slide-41
SLIDE 41

Objects in Motion Spatial Properties

slide-42
SLIDE 42

Spatial and Mass Properties

  • With a solid mesh we can correctly

derive properties that affect motion:

  • Volume
  • Center of mass
  • Covariance (and 3x3 Inertia Tensor)
slide-43
SLIDE 43

Triangle Center and Area

center = 𝑏 + 𝑐 + 𝑑 3

a b c

abs area = (𝑐 βˆ’ 𝑏) Γ— (𝑑 βˆ’ 𝑐) 2 a b

c

a b

c

area = 𝑐 βˆ’ 𝑏 Γ— 𝑑 βˆ’ 𝑐 βˆ™ π‘œ 2

n

Given a pre set normal n, result is signed. So area could be negative. i.e. Center of mass. There are other ways to define β€œcenter”.

slide-44
SLIDE 44

Cross Product - Edge Choice Irrelevant

a b

c

𝑑 βˆ’ 𝑐 Γ— 𝑏 βˆ’ 𝑑 a b

c

𝑏 βˆ’ 𝑑 Γ— 𝑐 βˆ’ 𝑏 a b

c

𝑐 βˆ’ 𝑏 Γ— 𝑑 βˆ’ 𝑐

All the same

= =

slide-45
SLIDE 45

Area of Polygon (2D)

? Triangle Summation:

  • Pick a reference point p. Normal n known.
  • For each edge (a,b) sum area of triangle

(p,a,b): 1

2 𝑏 βˆ’ π‘ž Γ— 𝑐 βˆ’ 𝑏 βˆ™ π‘œ

  • Signed Area - upside down triangles cancel
  • ut extra area if p outside.

p p

  • =

p

slide-46
SLIDE 46

Solid’s Area Weighted Normals Cancel

Sum of cross products for each tetrahedron face is zero.

u v w

𝑣 Γ— π‘₯ + π‘₯ Γ— 𝑀 + 𝑀 Γ— 𝑣 + 𝑀 βˆ’ 𝑣 Γ— π‘₯ βˆ’ 𝑣 = 0

w-u

slide-47
SLIDE 47

Polygon Normal

  • Pick reference point p (origin)
  • For each edge (ab) in polygon,

sum cross product:

p p

+ =

p

𝑏 βˆ’ π‘ž Γ— (𝑐 βˆ’ 𝑏)

𝐹𝑒𝑕𝑓 (𝑏,𝑐)

?

For a trapezoid explanation search for β€œNewell Normal”

slide-48
SLIDE 48

Tetrahedron Volume and Center

center

  • f mass = 𝑏 + 𝑐 + 𝑑 + 𝑒

4

a c b d

volume = (𝑑 βˆ’ 𝑏) Γ— 𝑐 βˆ’ 𝑏 βˆ™ (𝑒 βˆ’ 𝑏) 6

a c b d

= 𝑑 βˆ’ 𝑏 𝑐 βˆ’ 𝑏 𝑒 βˆ’ 𝑏 Γ· 6

Triple product in determinant form

slide-49
SLIDE 49

Tetrahedron Integration

a c b d Edges: u,v,w a=[0 0 0] (origin)

𝑔 𝛽 + 𝛾 + 𝛿 𝑒𝛿 𝑒𝛾 𝑒𝛽

π‘₯(1βˆ’ 𝛽 𝑣 βˆ’ 𝛾 𝑀) 𝑀(1 βˆ’ 𝛽 𝑣) 𝑣

u v w

Letting f(X)=1, we get our volume:

1 𝑒𝛿 𝑒𝛾 𝑒𝛽

π‘₯(1βˆ’ 𝛽 𝑣 βˆ’ 𝛾 𝑀) 𝑀(1 βˆ’ 𝛽 𝑣) 𝑣

= 𝑣𝑀π‘₯ 6 𝛽 + 𝛾 + 𝛿 𝑣𝑀π‘₯ 6 𝑒𝛿 𝑒𝛾 𝑒𝛽

π‘₯(1βˆ’ 𝛽 𝑣 βˆ’ 𝛾 𝑀) 𝑀(1 βˆ’ 𝛽 𝑣) 𝑣

= 𝑣 + 𝑀 + π‘₯ 4

General Form: Letting f(X)=X/vol for center of mass (relative to vertex a):

slide-50
SLIDE 50

Tetrahedral Summation (3D)

π‘€π‘π‘šπ‘£π‘›π‘“ = 𝑣 𝑀 π‘₯ /6

(𝑣,𝑀,π‘₯)βˆˆπ‘›π‘“π‘‘β„Ž

π‘‘π‘“π‘œπ‘’π‘“π‘  𝑝𝑔 𝑛𝑏𝑑𝑑 = 𝑣 + 𝑀 + π‘₯ 4 𝑣 𝑀 π‘₯ 6 /π‘€π‘π‘š(π‘›π‘“π‘‘β„Ž)

(𝑣,𝑀,π‘₯)βˆˆπ‘›π‘“π‘‘β„Ž

  • rigin
slide-51
SLIDE 51

Center of Mass Affects Gameplay

Catapult geometry:

slide-52
SLIDE 52

Inertia Calculation

2D:

π‘›π‘π‘›π‘“π‘œπ‘’ 𝑝𝑔 π‘—π‘œπ‘“π‘ π‘’π‘—π‘ = 𝑠2 = 𝑦2 + 𝑧2 = 𝑦2 + 𝑧2

Variance in x Variance in y

3D: 3x3 Inertia Tensor Related to covariance

𝑧𝑧 + 𝑨𝑨 βˆ’π‘¦π‘§ βˆ’π‘¦π‘¨ βˆ’π‘¦π‘§ 𝑦𝑦 + 𝑨𝑨 βˆ’π‘§π‘¨ βˆ’π‘¦π‘¨ βˆ’π‘§π‘¨ 𝑦𝑦 + 𝑧𝑧 Fixed Axis

slide-53
SLIDE 53

Covariance (origin = center of mass)

  • If object was a collection of point masses v

π‘€π‘€π‘ˆ = 𝑀𝑦2 𝑀𝑦𝑀𝑧 𝑀𝑦𝑀𝑨 𝑀𝑧𝑀𝑦 𝑀𝑧2 𝑀𝑧𝑀𝑨 𝑀𝑨𝑀𝑦 𝑀𝑨𝑀𝑧 𝑀𝑨2

  • Single Tetrahedron (0,u,v,w)…

𝑏𝑣 + 𝑐𝑀 + 𝑑π‘₯ ⨂(𝑏𝑣 + 𝑐𝑀 + 𝑑π‘₯) 𝑒𝑑 𝑒𝑐 𝑒𝑏

1βˆ’π‘βˆ’π‘ 1βˆ’π‘

βˆ— π‘€π‘π‘š_π‘π‘’π‘˜

1

slide-54
SLIDE 54

Tetrahedron (0,u,v,w) Covariance

u,v,w are vectors from center of mass to triangle on mesh

slide-55
SLIDE 55

Inertia Tetrahedral Summation

𝑑𝑗,π‘˜ = 2π‘£π‘—π‘£π‘˜ + 2π‘€π‘—π‘€π‘˜ + 2π‘₯𝑗π‘₯

π‘˜ + π‘£π‘—π‘€π‘˜ + 𝑀𝑗π‘₯ π‘˜ + π‘₯π‘—π‘£π‘˜ + 𝑣𝑗π‘₯ π‘˜ + π‘€π‘—π‘£π‘˜ + π‘₯π‘—π‘€π‘˜

120

𝑣,𝑀,π‘₯ βˆˆπ‘›π‘“π‘‘β„Žβˆ’π‘‘π‘π‘›

𝑣 𝑀 π‘₯ 6

π‘—π‘œπ‘“π‘ π‘’π‘—π‘: π‘ˆ = π½π‘’π‘“π‘œπ‘’π‘—π‘’π‘§ (𝑑0,0 + 𝑑1,1 + 𝑑2,2) βˆ’ 𝐷

Center Of Mass π‘—π‘œπ‘’π‘“π‘ π‘’π‘—π‘: π‘ˆ = 𝑧𝑧 + 𝑨𝑨 βˆ’π‘¦π‘§ βˆ’π‘¦π‘¨ βˆ’π‘¦π‘§ 𝑦𝑦 + 𝑨𝑨 βˆ’π‘§π‘¨ βˆ’π‘¦π‘¨ βˆ’π‘§π‘¨ 𝑦𝑦 + 𝑧𝑧

Sum for each triangle uvw, Covariance matrix C:

slide-56
SLIDE 56

Inertia Tensor and Object Motion

πœ• = π‘Ÿ π‘ˆβˆ’1 π‘Ÿβˆ’1 β„Ž πœ• β†’ π‘‘π‘žπ‘—π‘œ β„Ž β†’ π‘›π‘π‘›π‘“π‘œπ‘£π‘› π‘Ÿ β†’ π‘π‘ π‘—π‘“π‘œπ‘’π‘π‘’π‘—π‘π‘œ π‘ˆ β†’ π½π‘œπ‘“π‘ π‘’π‘—π‘

slide-57
SLIDE 57

Time Integration

Updating state to the next time step.

  • Position: π‘žπ‘’+𝑒𝑒 = π‘žπ‘’ + π‘€π‘“π‘šπ‘π‘‘π‘—π‘’π‘§ βˆ— 𝑒𝑒
  • Orientation:

π‘Ÿπ‘’+𝑒𝑒 = 𝑑 βˆ— π‘Ÿπ‘’ 𝑑 = πœ• πœ• sin ( πœ• 𝑒𝑒 2 ), cos ( πœ• 𝑒𝑒 2 ) π‘Ÿπ‘’+𝑒𝑒 = π‘Ÿπ‘’ + πœ• 2 π‘Ÿπ‘’ 𝑒𝑒 π‘Ÿπ‘’+𝑒𝑒 = π‘Ÿπ‘’ + π‘’π‘Ÿ 𝑒𝑒 𝑒𝑒 Build a Quat for Multiplication Add Derivative

lim

( πœ• 𝑒𝑒)β†’0 𝑑 β†’ πœ•

2 𝑒𝑒, 1

𝑑 βˆ— π‘Ÿπ‘’ = 0001 βˆ— π‘Ÿπ‘’ + πœ• 2 𝑒𝑒, 0 βˆ— π‘Ÿπ‘’ 𝑑 βˆ— π‘Ÿπ‘’ = π‘Ÿπ‘’ + πœ• 2 , 0 βˆ— π‘Ÿπ‘’ 𝑒𝑒

Proof it’s the same:

slide-58
SLIDE 58

Time Integration without Numerical Drift

π‘Ÿπ‘’+𝑒𝑒 = π‘Ÿπ‘’ + πœ•(π‘Ÿπ‘’) 2 βˆ— π‘Ÿπ‘’ βˆ— 𝑒𝑒

𝑙1 = πœ•(π‘Ÿπ‘’) 2 βˆ— π‘Ÿπ‘’ 𝑙2 = πœ•(π‘Ÿπ‘’ + 𝑙1 βˆ— 𝑒𝑒/2) 2 βˆ— (π‘Ÿπ‘’ + 𝑙1 βˆ— 𝑒𝑒 2 ) 𝑙3 = πœ•(π‘Ÿπ‘’ + 𝑙2 βˆ— 𝑒𝑒/2) 2 βˆ— (π‘Ÿπ‘’ + 𝑙2 βˆ— 𝑒𝑒 2 ) 𝑙4 = πœ•(π‘Ÿπ‘’ + 𝑙3 βˆ— 𝑒𝑒) 2 βˆ— (π‘Ÿπ‘’ + 𝑙3 βˆ— 𝑒𝑒) π‘Ÿπ‘’+𝑒𝑒 = π‘Ÿπ‘’ + 𝑙1 βˆ— 𝑒𝑒 6 + 𝑙2 βˆ— 𝑒𝑒 3 + 𝑙3 βˆ— 𝑒𝑒 3 + 𝑙4 βˆ— 𝑒𝑒 6

Forward Euler Runge Kutta

slide-59
SLIDE 59

Time Integration Euler vs RK4

Forward Euler:

  • Spin drifts

toward principle axis

  • Energy gained

Runge Kutta

  • Spin orbits as

expected

  • Energy stays

constant

slide-60
SLIDE 60

Soft Body Objects

slide-61
SLIDE 61

Soft Body Meshes

  • Every vertex has its own

position and velocity

  • Vertices are connected via

springs or constraints.

slide-62
SLIDE 62

Object Construction

Cloth Cube Lattice Table

  • Connection topology can differ from visual mesh
  • Stiffness can vary to simulate different objects and materials
slide-63
SLIDE 63

Time Integration – Simulating Soft Body

Kinematic

  • Connections as constraints
  • Iterative position projection
  • Easy to Implement
  • Numerically Robust (will

never explode)

  • Most common system used
  • May not converge under

stress (compression or stretch)

Dynamic

  • Connections as springs
  • Forward Euler can only handle

weak β€œspringy” forces

  • Implicit Integration required

for stiff springs

  • Damped behavior
  • Converges to force-correct

state

  • Harder to Implement
slide-64
SLIDE 64

Kinematic Solver

Realistic Behavior Easy To Implement Algorithm: repeat a few times for each constraint move endpoints toward rest-length

slide-65
SLIDE 65

Implicit Integration Spring Network

  • Forward Euler

𝑀𝑒+𝑒𝑒 = 𝑀𝑒 + π‘›βˆ’1𝑔𝑝𝑠𝑑𝑓𝑒 𝑒𝑒

  • Implicit Euler

𝑀𝑒+𝑒𝑒 = 𝑀𝑒 + π‘›βˆ’1𝑔𝑝𝑠𝑑𝑓𝑒+𝑒𝑒 𝑒𝑒

𝑔𝑝𝑠𝑑𝑓𝑒+𝑒𝑒 = 𝑔

𝑒+𝑒𝑒 = 𝑔 𝑒 + πœ–π‘”

πœ–π‘ž Ξ”π‘ž + πœ–π‘” πœ–π‘€ Δ𝑀 , π‘žπ‘π‘‘π‘—π‘’π‘—π‘π‘œ π‘ž π‘€π‘“π‘šπ‘π‘‘π‘—π‘’π‘§ 𝑀

slide-66
SLIDE 66

Derivatives of Force

𝑒𝑔 𝑒𝑀 = πœ–π‘”

𝑦

πœ–π‘€π‘¦ πœ–π‘”

𝑦

πœ–π‘€π‘§ πœ–π‘”

𝑦

πœ–π‘€π‘¨ πœ–π‘”

𝑧

πœ–π‘€π‘¦ πœ–π‘”

𝑧

πœ–π‘€π‘§ πœ–π‘”

𝑧

πœ–π‘€π‘¨ πœ–π‘”

𝑨

πœ–π‘€π‘¦ πœ–π‘”

𝑨

πœ–π‘€π‘§ πœ–π‘”

𝑨

πœ–π‘€π‘¨ Jacobian

𝑔 = βˆ’π‘™ π‘ž βˆ’ 𝑠 π‘ž π‘ž

p p r f f

Δ𝑔

start end

  • =

=

Ξ”π‘ž

=

Force at spring endpoint Compressed Spring: Stretched Spring: How force changes as endpoint moves along spring direction:

Δ𝑔 Ξ”π‘ž = βˆ’π‘™

slide-67
SLIDE 67

Derivatives of Force – Endpoint moves orthogonal

p p f f

Ξ”π‘ž Δ𝑔

  • =

= f f

Ξ”π‘ž Δ𝑔

  • =

=

Stretched: Compressed:

π‘žπ‘‘π‘’π‘π‘ π‘’ π‘žπ‘“π‘œπ‘’ Δ𝑔

=

Ξ”π‘ž

=

How force changes as endpoint moves lateral to spring dir:

Δ𝑔 Ξ”π‘ž = βˆ’π‘™ (1 βˆ’ 𝑠 π‘ž )

  • r
slide-68
SLIDE 68

Derivatives of Force – 3x3 Jacobian

πœ–π‘” πœ–π‘ž = βˆ’π‘™ π‘ž βŠ— π‘ž π‘ž βˆ™ π‘ž + 𝐽 βˆ’ π‘ž βŠ— π‘ž π‘ž βˆ™ π‘ž 1 βˆ’ 𝑠 π‘ž

Avoid compression singularity by clamping r/||p|| .

General change in Force for a given change in position:

𝐡 Δ𝑀 = 𝑐 , 𝐡 = 𝐽 βˆ’ πœ–π‘” πœ–π‘€ 𝑒𝑒 βˆ’ πœ–π‘” πœ–π‘ž 𝑒𝑒2, 𝑐 = 𝑔 𝑒𝑒 + πœ–π‘” πœ–π‘ž 𝑀 𝑒𝑒2

Solve for Δ𝑀 in linear system:

(note: slightly oversimplified)

slide-69
SLIDE 69

Implicit Integration

Force Based Stiff Springs Realistic Behavior Responsive Convergence (Jitter Free)

slide-70
SLIDE 70

Summary

Moving beyond triangles, dot and cross product:

  • Objects as 3D Solids
  • Convex parts
  • Spatial props
  • β€œ2nd Year” Maths
  • Object Motion
  • Stiff systems

πœˆπ‘›π‘›π›½π‘ π›Ώ Variety of topics:

Interacting with 3D Geometry

Volume Integration Time Integration

slide-71
SLIDE 71

Q&A

Stan Melax stan@melax.com

slide-72
SLIDE 72

Hand Tracking – if someone asks….

Tracking model Depth data Fit model