1Computer Graphics 15-462Physics of a Mass Point& Basics of TexturesPoint mass simulationBasics of texture mapping in OpenGLPoint mass simulationBasics of texture mapping in OpenGL2Computer Graphics 15-462Roller coaster• Next programming assignment involves creating a 3D roller coaster animation• We must model the 3D curve describing the roller coaster, but how?• How to make the simulation obey the laws of gravity?3Computer Graphics 15-462Back to the physics of the roller-coaster:mass point moving on a splinevPsplinefrictionless model, with gravity• Velocity vector always pointsin the tangential directionof the curve4Computer Graphics 15-462Mass point on a spline (contd.)frictionless model, with gravity• Our assumption is : no friction among the point and the spline• Use the conservation of energy law to get the current velocity• Wkin+ Wpot= const = m * g * hmax• hmaxreached when |v|=0• Wkin= kinetic energy = 1/2 * m * |v|2• Wpot= potential energy = m * g * h• h = the current z-coordinate of the mass point• g = acceleration of gravity = 9.81 ms-2• m = mass of the mass pointchalkboard5Computer Graphics 15-462Mass point on a spline (contd.)frictionless model, with gravity• Given current h, we can always compute the corresponding |v|:)(2||maxhhgv −=6Computer Graphics 15-462Simulating mass point on a spline• Time step ∆∆∆∆t• We have: ∆∆∆∆s = |v| * ∆∆∆∆t and s = s + ∆∆∆∆s .• We want the new value of u, so that can compute new point location• Therefore:We know s, need to determine uHere we use the bisection routine to compute u=u(s).tt+∆∆∆∆tusvusv?7Computer Graphics 15-462Mass point simulationMassPoint(tmax) // tmax = final time/* assume initially, we have t=0 and point is located at u=0 */u = 0; s = 0;t = 0;While t < tmax{Assert u < 31; // if not, end of spline reachedDetermine current velocity |v| using physics;s = s + |v| * ∆∆∆∆t; // compute new arclengthu = Bisection(u,u + delta,s); // solve for tp = p(u); // p = new mass point locationDo some stuff with p, i.e. render point location, etc.t = t + ∆∆∆∆t; // proceed to next time step}• Assume we have a 32-piece spline, with a general parameterization of u∈∈∈∈[0,31]chalkboard8Computer Graphics 15-462Mass point simulationMassPoint(tmax) // tmax = final time/* assume initially, we have t=0 and point is located at u=0 */u = 0; s = 0;t = 0;While t < tmax{Assert u < 31; // if not, end of spline reachedDetermine current velocity |v| using physics;s = s + |v| * ∆∆∆∆t; // compute new arclengthu = Bisection(u,u + delta,s); // solve for tp = p(u); // p = new mass point locationDo some stuff with p, i.e. render point location, etc.t = t + ∆∆∆∆t; // proceed to next time step}• Assume we have a 32-piece spline, with a general parameterization of u∈∈∈∈[0,31]9Computer Graphics 15-462Arclength Parametrization• There are an infinite number of parameterizations of a given curve. Slow, fast, speed continuous or discontinuous, clockwise (CW) or CCW…• A special one: arc-length-parameterization: u=s is arc length. We care about these for animation.10Computer Graphics 15-462• Assume a general parameterization p=p(u)• p(u) = [x(u), y(u), z(u)]T• arclength parameter s=s(u) is the distance from p(0) to p(u) along the curve• Distance increases monotonically, hence s=s(u) is a monotonically increasing function• It follows from Pitagora’s law thatchalkboardArclength Parametrization11Computer Graphics 15-462)()]()(4)([3)(5122122/)1(1hOxfxfxfhdxxfkkkbank+++=+−−=++=udvvzvyvxus0222)(')(')(')(Arclength Parametrization Summary• Use bisection (next slide) to compute universe: u=u(s) •Arclength parameter s=s(u) is the distance from p(0) to p(u) along the curve•The integral for s(u) usually cannot be evaluated analytically•Has to evaluate the integral numerically•Simpson’s integration rule12Computer Graphics 15-462Computing inverse u=u(s)Bisection(umin,umax,s)/* umin = min value of uumax = max value of u; umin <= u <= umaxs = target value */Forever // but not really forever{u = (umin + umax) / 2; // u = candidate for solutionIf |s(u)-s| < epsilonReturn u;If s(u) > s // u too big, jump into left intervalumax = u;Else // t too small, jump into right intervalumin = u;}• Must have initial guess for the interval containing
or
We will never post anything without your permission.
Don't have an account? Sign up