notes_COSqueues

Time to hit wall distancevelocity 1 s rx vx wall

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: v ⋅ Δv) (Δr ⋅ Δr − σ 2 ) i time = t if Δv ⋅ Δr ≥ 0 if d < 0 σ = σi + σ j € time = t + Δt (vxj , vyj) € Δv = (Δvx, Δvy) = (vxi − vx j , vyi − vy j ) Δr = (Δrx, Δry) = (rxi − rx j , ryi − ry j ) sj j 47 € € € € € Δv€Δv = (Δvx )2 + (Δvy)2 ⋅ Δr ⋅ Δr = (Δrx )2 + (Δry)2 Δv ⋅ Δr = (Δvx )(Δrx ) + (Δvy)(Δry) Important note: This is high-school physics, so we won’t be testing you on it! 48 Particle-particle collision resolution Particle data type skeleton Collision resolution. When two particles collide, how does velocity change? vxiiʹȃ + =Jx / mi + Jx / mi vxi vx vyi = vyiiʹȃ + =Jy / mi + Jy / mi ʹȃ = vx jʹȃ − =Jx vxm − Jx / m j vx j / jj ʹȃ = vx jʹȃ − =Jy vx j − Jy / m j vy vy /m vxiʹȃ vyiʹȃ j public class Particle { private double rx, ry; private double vx, vy; private final double radius; private final double mass; private int count; = j Newton's second law (momentum form) // // // // // position velocity radius mass number of collisions public Particle(...) { } j public void move(double dt) { } public void draw() {} € € Jx = public double timeToHit(Particle that) { } public double timeToHitVerticalWall() {} public double timeToHitHorizontalWall() { } 2 mi m j (Δv ⋅ Δr ) J Δrx J Δry , Jy = ,J= σ σ σ ( mi + m j ) public void bounceOff(Particle that) public void bounceOffVerticalWall() public void bounceOffHorizontalWall() impulse due to normal force (conservation of energy, conservation of momentum) {} {} {} predict collision with particle or wall resolve collision with particle or wall } € Important note: This is high-school physics, so we won’t be testing you on it! 49 Particle-particle collision and resolution implementation public double timeToHit(Particle that) { if (this == that) return INFINITY; double dx = that.rx - this.rx, dy = that.ry - this.ry; double dvx = that.vx - this.vx; dvy = that.vy - this.vy; double dvdr = dx*dvx + dy*dvy; if( dvdr > 0) return INFINITY; d...
View Full Document

This document was uploaded on 02/20/2014 for the course COS 226 at Princeton.

Ask a homework question - tutors are online