CS 551/651 Advanced Graphics Arc Length. Assignment 1 Due Week from Thursday Building a Cubic...
-
Upload
phillip-mcdowell -
Category
Documents
-
view
214 -
download
0
Transcript of CS 551/651 Advanced Graphics Arc Length. Assignment 1 Due Week from Thursday Building a Cubic...
![Page 1: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/1.jpg)
CS 551/651Advanced Graphics
Arc Length
![Page 2: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/2.jpg)
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
![Page 3: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/3.jpg)
Papers for Next TuesdayPresenters 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.
![Page 4: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/4.jpg)
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
![Page 5: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/5.jpg)
Arc Length
• Given parameters u1 and u2, find LENGTH(u1, u2)
• Given an arc with length s and a parameter u1, find u2 s.t. LENGTH (u1, u2) 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))
![Page 6: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/6.jpg)
Analytic Computation
2
1
22
1
/)2,1(
)(u
u
u
u
dududPdudu
dPsuulength
uPx
2
1
22
2
23
23
23/
)(
u
u
ducbuaus
cbuaududP
dcubuauuP
Cubic curve example:
![Page 7: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/7.jpg)
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?
![Page 8: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/8.jpg)
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
![Page 9: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/9.jpg)
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
![Page 10: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/10.jpg)
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 leadsto better accuracy
i
ii ufwuf )()(1
1
![Page 11: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/11.jpg)
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
![Page 12: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/12.jpg)
Adaptive Gaussian Integration• Build a table that maps parameter
values to arc length values
• To solve arc length at u, find ui and ui+1
that bound u
• Use gaussian quadrature to compute intermediate arc length between that at ui and ui+1
![Page 13: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/13.jpg)
Finding u given s
• Must compute u s.t. length (u1, u) = s• Solve: s – length(u1, u) = 0
– Find the zeros (roots) of the function
• Newton-Raphson does this for us:
• f = s – length(u1, pn-1) f’= dp/du evaluated at pn-1
)(
)(
1
11
n
nnn pf
pfpp
![Page 14: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/14.jpg)
Newton-Raphson
• Be aware that Newton-Raphson could set pn to a value not defined by curve
• f’(pn-1) could be 0 (cannot divide by 0)
![Page 15: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/15.jpg)
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)
![Page 16: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/16.jpg)
Speed Control
• Easing in/out: 2
12
sin)()(
tteasets
• -pi/2 shifts curve rightward• +1 shifts curve upward• Divide by 2 scales from 0 to 1
![Page 17: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/17.jpg)
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)
t1 t2
v0
![Page 18: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/18.jpg)
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)
tt1 t2
v0
)0.1(2
1)(
2
10.1 2012010 tvttvtv
21101
0
11
2
0
)(2
0.02
tttttvt
vd
ttt
tvd
![Page 19: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/19.jpg)
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
![Page 20: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/20.jpg)
SLERPing
• Linear interpolation doesn’t produce constant velocity interpolation of quats
• Instead, interpolate along the arc on sphere between two quats
![Page 21: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/21.jpg)
SLERPing
• Which way do we go?– Long way or short way around sphere
• q = [s,v] = [-s,-v] = -q• Compute angle between q1 and q2
– Four dimensional dot product• cos(q1q2 = s1*s2 + v1 v2
– If positive, this is shortest,– Else, interpolate between q1 and -q2
![Page 22: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/22.jpg)
SLERPing
• SLERP:
• Unit quaternion is not guaranteed
• What about continuity of interpolation?
2121 )/(sin))(sin()/(sin)))1((sin((),,( ququuqqslerp
![Page 23: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/23.jpg)
Continuity of SLERP
• Interpolate between points– [p0, …, pn-1, pn, pn+1, …]
• Bezier interpolation would compute intermediate points for each pn
– To define tangent at pn
– Define bn to be point before pn
– Define an to be point after pn
![Page 24: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/24.jpg)
Continuity of SLERP
• an = (pn – pn+1 + pn * ½) + (½ * pn+1)
• pn + pn – an = bn
pn-1
pn
pn+1
an
pn+ pn – pn+1
![Page 25: 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.](https://reader036.fdocuments.in/reader036/viewer/2022062804/5697bf931a28abf838c8f566/html5/thumbnails/25.jpg)
Continuity of SLERP
• To compute midway (average) points between quats, SLERP halfway
• Instead of adding vectors, concatenate rotations
an bn+1
qn+1qn
P1 = slerp(qn, qn, 1/3)
P2 = slerp(an, bn+1, 1/3)
P3 = slerp (bn+1, qn+1, 1/3)
P12 = slerp (p1, p2, 1/3)
P23 = slerp (p2, p3, 1/3)
P = slerp (p12, p23, 1/3)