Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 551/651 Advanced Graphics Arc Length. Assignment 1 Due Week from Thursday Building a Cubic Bézier curve OpenGL/Glut Insert up to 100 points Render.

Similar presentations


Presentation on theme: "CS 551/651 Advanced Graphics Arc Length. Assignment 1 Due Week from Thursday Building a Cubic Bézier curve OpenGL/Glut Insert up to 100 points Render."— Presentation transcript:

1 CS 551/651 Advanced Graphics Arc Length

2 Assignment 1 Due Week from Thursday Building a Cubic Bézier curve OpenGL/Glut Insert up to 100 points Render Bézier curve using recursive subdivision Left mouse button to add, middle to move, and right to remove FLTK is extra credit

3 Papers for Next Tuesday Presenters Needed Tour Into the Picture William T. Reeves, Particle systems - a technique for modelling a class of fuzzy objects. In SIGGRAPH '83, Computer graphics 17, 3, July 1983. " Animation of plant development," Przemyslaw Prusinkiewicz, Mark S.Hammel, and Eric Mjolsness. Siggraph 1993. Animation of plant development

4 Arc Length Arc length is the distance along the curve To ensure constant speed of curve evaluation, perform arc length parameterization of curve –Compute a mapping offline of arc length values to parameter values –Analytically compute arc length

5 Arc Length Given parameters u 1 and u 2, find LENGTH(u 1, u 2 ) Given an arc with length s and a parameter u 1, find u 2 s.t. LENGTH (u 1, u 2 ) is s Can we compute s = G(u) = distance from start of curve to point at u? If so, G -1 is used to build arc length parameterized curve: P(G -1 (s))

6 Analytic Computation Cubic curve example:

7 Forward Differencing Sample curve a many parameter values Create piecewise linear representation of curve from parameter evaluations Compute linear distance between samples Store distances in table Limitations/Shortcomings?

8 Adaptive Approach Adaptively subdivide First step, compare: –length (start, middle) + length (middle, end) –length (start, end) If error is too large, subdivide Use link list to store data

9 Numerical Computation Numerical methods exist to approximate integral of curve given sample points/derivatives Instead of using sum of linear segments, use numerical method to compute sum of curved segments

10 Gaussian Quadrature Commonly used to integrate function between –1 and +1 Function to be integrated is evaluated at fixed points within [-1, 1] and multiplied by a precalculated weight More sample points leads to better accuracy

11 Adaptive Gaussian Integration Gaussian quadrature uses sampling to preseve accuracy –How many samples are necessary for given curve? Adaptive gaussian integration monitors errors to subsample when necessary Start trying few samples and add more as necessary Recursive like spline subdivision

12 Adaptive Gaussian Integration Build a table that maps parameter values to arc length values To solve arc length at u, find u i and u i+1 that bound u Use gaussian quadrature to compute intermediate arc length between that at u i and u i+1

13 Finding u given s Must compute u s.t. length (u 1, u) = s Solve: s – length(u 1, u) = 0 –Find the zeros (roots) of the function Newton-Raphson does this for us: f = s – length(u 1, p n-1 ) f’= dp/du evaluated at p n-1

14 Newton-Raphson Be aware that Newton-Raphson could set p n to a value not defined by curve f’(p n-1 ) could be 0 (cannot divide by 0)

15 Speed Control Given arc-length parameterized curve Let s(t) define amount the curve has traveled given t –For simplicity, normalize total distance to 1 –Monotonic (can’t go backwards) and continuous To ease in/out, make s(t) = ease (t) that looks like: t s(t)

16 Speed Control Easing in/out: -pi/2 shifts curve rightward +1 shifts curve upward Divide by 2 scales from 0 to 1

17 Speed Control Transcendental functions are expensive –Table lookups are one possibility\ –Roll your own User specifies acceleration period, deceleration period, and max velocity t vel(t) t1t1 t2t2 v0v0

18 Speed Control Distance traveled is area under curve User selects two of three unknowns and distance traveled constraint determines third Integrate velocity function to find s(t) t t1t1 t2t2 v0v0

19 SLERPing Quaternions are points on the unit sphere in four dimensions –Unit sphere in three dimensions plus a fourth dimension representing the rotation about the normal at a point on the sphere Interpolating quats –Linearly interpolate each of four components Doesn’t quite work right

20 SLERPing Linear interpolation doesn’t produce constant velocity interpolation of quats Instead, interpolate along the arc on sphere between two quats

21 SLERPing Which way do we go? –Long way or short way around sphere q = [s,v] = [-s,-v] = -q Compute angle between q 1 and q 2 –Four dimensional dot product cos(  q 1 qq 2 = s 1 *s 2 + v 1 q v 2 –If positive, this is shortest, –Else, interpolate between q 1 and -q 2

22 SLERPing SLERP: Unit quaternion is not guaranteed What about continuity of interpolation?

23 Continuity of SLERP Interpolate between points –[p 0, …, pn-1, p n, p n+1, …] Bezier interpolation would compute intermediate points for each p n –To define tangent at p n –Define b n to be point before p n –Define a n to be point after p n

24 Continuity of SLERP a n = (p n – p n+1 + p n * ½) + (½ * p n+1 ) p n + p n – a n = b n p n-1 pnpn p n+1 anan p n + p n – p n+1

25 Continuity of SLERP To compute midway (average) points between quats, SLERP halfway Instead of adding vectors, concatenate rotations anan b n+1 q n+1 qnqn P 1 = slerp(q n, q n, 1/3) P 2 = slerp(a n, b n+1, 1/3) P 3 = slerp (b n+1, q n+1, 1/3) P 12 = slerp (p 1, p 2, 1/3) P 23 = slerp (p 2, p 3, 1/3) P = slerp (p 12, p 23, 1/3)


Download ppt "CS 551/651 Advanced Graphics Arc Length. Assignment 1 Due Week from Thursday Building a Cubic Bézier curve OpenGL/Glut Insert up to 100 points Render."

Similar presentations


Ads by Google