09 july 2013 update
DESCRIPTION
Trigons, Normals, and Quadragons Vector-based Solutions to the Classic Problems of Computer Graphics. 09 July 2013 update. Notes / Options: Slideshow animated (F5) See also slide footnotes. J. Philip Barnes. Overview. Display a 3D-math-modeled shape on a 2D screen. Presentation Contents - PowerPoint PPT PresentationTRANSCRIPT
1 Pelican Aero Group
09 July 2013 update
Trigons, Normals, and QuadragonsVector-based Solutions to the Classic
Problems of Computer Graphics
Notes / Options:Slideshow animated (F5)See also slide footnotes
J. Philip Barnes
2 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Overview
Presentation Contents • “Flexible-cylinder” geometry grid • Geometry math modeling tools• Vectors ~ history & key operations • Fast world-to-pyramid transformation• Review & Renew: Rotation matrices • Review & Renew: Z-buffer & Ray-casting • Vector solution : “Point-in-polygon” • Vector solution: Inter-vertex interpolation• Vector solution: Constant-curvature Tesselation• “Pyranometer” ambient lighting model• Apply ~ "Render Raptor" & “TrigonoSoar”
Display a 3D-math-modeled shape on a 2D screen
3 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
“Flexible Cylinder” Geometry Grid
Computer graphics classic problem 1:Generate and manage 3D geometry
Arrays and SubscriptsObject (n), Row (i), Col (j),Vertex (k), Quadragon (m)
l
qlq
z
x
y
Quadragon
VertexNormal
Vertex
4 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Geometry Math-model Building Blocks
Pseudo-Cosine
0.0 0.2 0.4 0.6 0.8 1.00.0
0.2
0.4
0.6
0.8
1.0
e y / ymax
= cos m (hp/2)
h x / xmax
m = 2.0 1.0 0.5
Exponential
0.0 0.2 0.4 0.6 0.8 1.00.0
0.2
0.4
0.6
0.8
1.0
e = e-5h m
Pseudo-Sine
0.0 0.2 0.4 0.6 0.8 1.00.0
0.2
0.4
0.6
0.8
1.0
e = sin (hm p)
h
Varabola
0.0 0.2 0.4 0.6 0.8 1.00.0
0.2
0.4
0.6
0.8
1.0
e = h m
h
5 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Review, Renew, Theory, & History* of the Casteljau-Bézier Curve • P. De Casteljau first conceived (1963) today’s “Bézier Curve”
• His notes & algorithm remained proprietary at Citroën for years• Set (Np) Control points for control polygon near, not on, curve• (Np-1, Np-2,...) interpolation series on polygon-sides for x(t), y(t)
• De Casteljau’s Algorithm is represented by the Bernstein Basis• as discovered by A.R. Forrest ~ Geometric construct → math
• S. Bernstein’s polynomial (B) derivative (dB/dt) is introduced herein• P. Bézier independently conceived (1966) the control polygon
• Weight factors not widely used (differ from Casteljau/Bernstein) • Bézier’s work at Rénault is the foundation of UNISURF & CATIA
* R.T. Farouki, The Bernstein polynomial basis: a centennial retrospective, UC Davis, 03 Mar 2012 * G. Farin, A History of Curves and Surfaces in CAGD, Arizona State University, 2007
t = 1/3 p1
p2
pNp
p3
x
y 1/3
1/31/3 x,y
Animated graphic (shift F5) [dB/dt][dc/dt](t)
notes) chart (see Bc(t)
:parametric are (dc/dt) rate & w...z,y,x,(c) coordinate any
(p) "points, control" 2N For
pN
1ii
pN
1ii
p
pi
pi
c
c
11
2
11
1
11
1
11
ipNip
ipNi
ii
pNiii
pi
ttiN
tti
adtdBttaB
iNiN
a p
)()(
)()(
)/()(
)!()!()!(
6 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
0.0 0.2 0.4 0.6 0.8 1.00.0
0.2
0.4
0.6
0.8
1.0Np = 6 points, Yp(Xp)
Xp
Yp
2
34
5 6 1
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.00.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0 Bernstein PolynomialsB1B2B3B4B5B6
t
Bi
Area = 1/Np
SB i = 1
t
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.00.0
0.2
0.4
0.6
0.8
1.0Resulting x(t), y(t)
t
x = S Bi Xpi
y = S Bi Ypi
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0-2.0
-1.0
0.0
1.0
2.0
3.0 "Velocities" dx/dt, dy/dt
t
dx/dt = S (dB/dt)i Xpi
dy/dt = S (dB/dt)i Ypi
Demo: Casteljau-Bézier 2D Curve Example
V = (dx/dt) i + (dy/dt) j
N=VxkV
7 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
“TrigonoSoar” Math-modeled 3D Surface
Chord, thickness, twist, etc. parametric along the spar from centerline to winglet tip
xyz
Aero axes
8 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Math-modeled Aircraft
AlgebratrossWandering Albatross
RegenoSoarRegenerative-soarer
9 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
“RenderRaptor” ~ Wireframe & Flat-Shade
10 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
z
x
yB
A
g
C
c
ik
j
Unit vectorsa A / |A|b B / |B|c C / |C|
cos g = a bsin g = |axb|
Vectors ~ Origin and Key Operations
J. Willard Gibbs Oliver Heaviside
11 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
zx
y
B
A
C=AxB
ik
j
Vector Cross Product ~ Elegant Visual Derivation
Add cross products, each axisImportant ~ Retain order A:B
Cx = Ay Bz - Az By Cy = Az Bx - Ax Bz Cz = Homework !
z, k x,i
y, j
Ax
Bx
ByAy
Az
Bz
To obtain the cross product AxB above, simply add the orthogonal
cross product components as shown at upper right
12 Pelican Aero Group
n
e f
e
e f cosn
Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Fast World-to-Pyramid Transform & 90o Exclusion Criteria
f
e
y-ye
k
z-ze
1. cosn = |zf - ze| / ef ; sinn = -(yf - ye) / ef 2. sine = (xf - xe) / (ef cosn) ; cose = (zf - ze) / (ef cosn) 3. Rotate (e) about y-ye axis through point (e)4. Rotate (n) about x-xe axis through point (e)5. Optionally rotate (k) for “cockpit-roll” effect6. Project to screen (perspective transformation)
v
xs, zs
xp
yp
nx-xe
Graphics classic problem 2:Efficiently project any vertex (v) in 3D onto 2D screen, given: eye point (e) and focus point (f) Approach:Twice rotate the world about axes through (e), operating on coordinate differences (x-xe etc.)
First test a new "90-deg exclusion" criterion. Skip transformations for any quadragon which, after transformation, would have all vertices (v) at least 90o from the line of sight, based on the angle included by the vectors ev & ef using only the dot-product sign. This adds 3 multiplications (xv-xe)(xf -xe) + (yv-ye)(yf -ye) + (zv-ze)(zf -ze) for all vertex coordinates, but avoids at least 9 to transform excluded vertices & unit-normals.
FocuspointEye
point ef
After world
rotations
evBefore world
rotations
View Pyramid
e
Chart origin: JPB, 2007
Animated graphic (shift F5)
13 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Rotation Matrix Concatenation ~ Review and Renew
) j(i, between"" )(k subscript 3 Note
:matrices 3x3 two of ionConcatenat) , ,( rotations pyramidtoWorld
) , ,(yaw & pitch, roll, Manuever
rd
3
1
;k
kjikij BACBAC
knensApplicatio&Reviewproduct -Matrix
worlde
e
e
wp
pyramide
e
e
k LLjkLikijwp
zzyyxx
Tzzyyxx
whereT
enk
kne
:)(
:][T transform pyramid-to-world the Apply];[ matrix rotation roll" cockpit" optional an &
][ ],[ matrices rotation north & east Defineleft. to right proceed ionsconcatenat Rotation
wp
3
1
3
1
transform pyramid-to-world:nApplicatio
3
1
3
1
3
1
3
1
3
1
k LLjkLik
k LLjkLikij
kkjikij
CBACBAD
BCAD
BCACBAD
)(
:left-to-right matrices, 3 eConcatenat
3
1
3
1
3
1
3
1
3
1
3
1
3
1
)(
)()(
kmjLm
L mkLikij
mjk L m
LmkLikij
kkjikij
DCBAE
DCBAE
BCDAE
BCDADCBAE
:therefore and
:left-to-right matrices, 4 eConcatenat
kkkk
k
k
nnnnn
n
ee
eee
e
1 0 00 cos sin0 sin- cos
][
:(e) through axis-z , )( roll" cockpit" :Optioncos sin 0sin- cos 00 0 1
][
:(e) through axis-x an about )( rotate Then,cos 0 sin-0 1 0
sin 0 cos][
:(e) through axis-y a about ) ( rotate First,
14 Pelican Aero Group
Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Demo: object-maneuver and world-pyramid rotations
Stationary object, moving observer
Fixed observer, maneuvering object
15 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Screen Plane
Polygon Pipeline Overview (incl. inner surfaces when applicable)
Z-buffer (E. Catmull / W. Straber, 1974) Suggested Implementation J. Philip Barnes, 2013Sort QiPs by in(out)-facing and (zc) Initialize: For each pixel (i,j), zref = - For each in(out)-facing QiP (q'gon-in-pyramid)Get pixel box upper-left/lower-right pixel indices For each pixel (i,j) of the pixel boxGet pixel screen coordinates (xp,yp) Test: (p) inside q'gon projection ; OK, interp. (zp)Test at pixel (i,j): zp > zref ; OK, zref = zp Interp. normals at (p) ; shade pixel if it is visible
boundingbox
Ray-casting (Arthur Appel, 1968) Projection-Ray / Z-buffer Hybrid, J. Philip Barnes, 2013Sort QiPs by (zc) ; Initialize: “hit_index” = -1 For each “screen-raybox” pixel (p); zref = - Get pixel sceen x-y ; Cast eye-to-pixel ray For each QiP, test: 2D overlap box includes (p) OK, test: point (p) is inside QiP projectionOK, interpolate (zp) on QiP ; Test: zp > zref OK, hit_index = QiP_index ; zref = zp At hit, interp. normals ; shade pixel if it is visible
pixel box
pixel (p)
x
y
Polygon Pipeline Filter J. Philip Barnes, 2013Initialize: No q'gons-in-pyramid ("QiP"=0) ~ partly/fully Init: “raybox” corners to screen center (if ray-casting) For each quadragon of each polyhedron:Get/set vertex model coords., normals, & in/out colorsModel-to-World transform q'gon vertex coords. onlyCheck: all q'gon vertices pass the 90o exclusion testOK, World-pyramid & perspective x'form vertex coords. Test: q'gon at least partially overlaps the screen ; OK, Model-world and world-pyramid x'form vertex normalsGet 4 corners of q'gon bounding box and 2 of pixel-box Update raybox top-left, low-right corners (if ray-casting)Get q'gon centroid (zc) ; assess in(out)-facing Add q’gon as member of “quadragons in pyramid” (QiP)
RayboxScreen
quadragon
z
16 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
x
y
2
3
1
P
PE1P1
E2
E3
Define:Ei Edge vector, vertex(i)-to-next(i+1)Pi Point vector, vertex(i)-to-point (P)z Unit vector out of the page
Observe:(P) inside: E1 x P1 points out of the page(P) outside: E1 x P1 points into the page
Therefore:
Point (P) is outside if, for any vertex (i),( Ei x Pi ) ● k < 0
Postulate: Applies to any convex polygon
Vector determination of "point-in-polygon"
Computer graphics classic problem 3:Given 2D coordinates of vertices and point (P), determine if (P) resides inside
Chart origin: JPB, 2007
17 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Inter-vertex Interpolation ~ Vector SolutionComputer graphics classic problem 4:Given coords. & properties at vertices 1-2-3, interpolate the properties at point (p)
x
y
p
o
2
3
1
4
Ro4 = Ro1 + R14 = Ro1 + a R1p = Ro2 + R24 = Ro2 + b R23
Finally, interpolate at (p):zp = z1 + [z2 + b (z3-z2) -z1] / a
Equate Ro4 (Dx) & (Dy) to get a, b
Apply vector tip-to-tail addition & scalingSolve for & store two “position parameters”
b
a
/xxyyyyxx/xxyyyyxx
xxyyyyxx
pp
pp
121121
32123212
321321
Classic method: “scan line” (comp. intensive)Contemporary method: Barycentric Coords.Complementary Alternative : Vectors
18 Pelican Aero Group
Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Constant-curvature Tesselation
• Apply: Breakup curved polygon to avoid edge-rendering artifacts• Whenever at least one vertex is not visible
• Task: Get Cartesian coordinates of curved-polygon edge midpoint• Problem: Barycentric coordinates assume a planar trigon surface
• But the trigon plane typically models a sphere, bowl, cylinder, or saddle surface
• Solution: Assume each trigon edge has constant curvature• Method is exact for spherical surfaces, and perhaps so for cylindrical surfaces
• Unit-normal dot product (ua ●ub) gets cos (q) ; solve for local curve radius (r)
• Vector cross product then gets from (m) to (e), [convex / concave automatic]
Computer graphics classic problem 5:Tesselation of curved polygon Cartesian coordinates
a
be
cf
ga
bem
q
r
Tesselateabc to efg Side view of trigon
edge ab, midpoint (m),true surface point (e),
& unit normals
19 Pelican Aero Group
Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
“Pyranometer Model” of Ambient Lighting
Classic lighting model: Uniform ambient Then add illumination
Problem:“Grey silhouette” until lights are added
Poor foundation of total reflection model
Idea:Vary ambient reflection with orientation
~ good foundation before illumination
Implementation:pyranometer measures "skydome" light
- Rotated on it side ~ half the intensity- Inverted ~ zero intensity (@ albedo=0)
Computer graphics classic problem 6:Model ambient light before illumination
pyranometer disk seesonly the sky "dome"
Sun shade
Define:pyranometer tilt angle (t)Ground albedo (a)
Ambient Reflectance r = 1 - t/p + a t/p
Chart origin: JPB, 2007
20 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Pyranometer Vs. Uniform Ambient Model (cloudy day)
“Uniform” ambient
“Pyranometer”Ambient
GroundAlbedo = 0.5
GroundAlbedo = 0.0
“Pyranometer”
Ambient
21 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
"Render Raptor" ~ Math-modeled Aircraft
22 Pelican Aero Group
Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Summary ~ Trigons, Normals, and Quadragons
New Solutions: computer graphics classic problems• Complementary, faster, or better, with added insight• Graphical derivation of vector cross product• Fast world-to-pyramid transform ~ just two rotations• Rotation concatenation ~ Review and Renew• 90o exclusion criterion for world-to-pyramid transform• Polygon Pipeline Overview ~ Z-buffer & Ray Casting• Point-in-polygon ~ vector-based determination • Interpolation at point (p) ~ vector-based alternative• Constant-curvature Tesselation• “Pyranometer” ambient-lighting model foundation
23 Pelican Aero Group Trigons, Normals, and Quadragons J. Philip Barnes 09 July 2013 www.HowFliesTheAlbatross.com
Phil Barnes has a Bachelor’s Degree in Mechanical Engineering from the University of Arizona and a Master’s Degree in Aerospace Engineering from Cal Poly Pomona. He has 32-years of experience in performance analysis and computer modeling of aerospace vehicles, engines, and subsystems, primarily at Northrop Grumman. He has authored SAE technical papers on aerodynamics, dynamic soaring, and regenerative soaring. This latest presentation brings together Phil’s knowledge and passions for computer graphics, and geometry math modeling.
About the Author