You are on page 1of 1

The Slug Algorithm

sluglibrary.com
Root Eligibility Winding Number
Class y3 < 0 y2 < 0 y1 < 0 Root 2 Root 1
A 0 0 0 0 0
+1
B 0 0 1 1 0 +1 −1 +1
−0.15 +0.82
0.67
C 0 1 0 1 1 −1 +1
0

D 0 1 1 1 0 +1
+1
−0.5 0 +0.5

E 1 0 0 0 1
F 1 0 1 1 1 Quadratic Bézier curve
2
p ( t ) = (1 − t ) p 1 + 2t (1 − t ) p 2 + t 2p 3 p i = ( xi , y i )
G 1 1 0 0 1 Ray intersection equation p y ( t ) = ( y1 − 2 y 2 + y 3 ) t 2 − 2 ( y1 − y 2 ) t + y1 = 0
H 1 1 1 0 0
b − b 2 − ac b + b 2 − ac d d
t1 = t2 = p y (t 1 ) ≤ 0 p y (t 2 ) ≥ 0
0x2E 0x74 Potential solutions a a dt dt
a = y1 − 2 y 2 + y 3 b = y1 − y 2 c = y1

Class A Change to winding number + sat ( k px (t 1 ) + 12 ) if root 1 eligible


y y y y for ray in positive x direction − sat ( k px (t 2 ) + 12 ) if root 2 eligible
p1 p2 p1 p2 k = pixels per em
Change to winding number − sat ( 12 − k px (t 1 )) if root 1 eligible
for ray in negative x direction + sat ( 12 − k p x (t 2 )) if root 2 eligible
x x x x
p1 p2 p3 p2 p3 p1 p3 p3

y y y y Geometry Bands
p3 p1 p3 p2 p3 p1 p3
Glyph with 16 quadratic Bézier curves 2 7 7 7 6 7 5 6
p2
x x x x 5
p1 p2 p2 p1
5
4

Class B 2
y y y y
p2 p3 p2 p3
5
p2 p3 p2 5
x x x x 5
p3

p1 p1 p1 p1

Class C Bounding Polygons


y y y y Boxes 4 vertices, 2 triangles
p1 p3
p1 p3
p1 p3 p3 p1
x x x x

p2 p2 p2 p2
Polygons 3–6 vertices, 1–4 triangles

Class D Class H
y y y
p3

p3
x x p2 x

p1 p2 p1 p2 p1 p3 Dynamic Dilation
m = transformation matrix from object space to clip space
Class E p + dn
w = viewport width h = viewport height
d = object-space dilation distance
y y y y
p1 p2 p1 p2 d ( px , p y ) = object-space vertex position
p
( n x , n y ) = object-space vertex normal nˆ = n n
p1 p2 d
x x x x
p2 p1 w m 00 ( px + dnˆ x ) + m 01 ( p y + dnˆ y ) + m 03 m 00 p x + m 01 p y + m 03
Δx = −
2 m 30 ( p x + dnˆ x ) + m 31 ( p y + dnˆ y ) + m 33 m 30 p x + m 31 p y + m 33
p3 p3 p3 p3 h m 10 ( px + dnˆ x ) + m 11 ( p y + dnˆ y ) + m 13 m 10 p x + m 11 p y + m 13
Δy = −
2 m 30 ( p x + dnˆ x ) + m 31 ( p y + dnˆ y ) + m 33 m 30 p x + m 31 p y + m 33

Class F Class G (Δ x) 2 + (Δ y ) 2 =
1
(half-pixel viewport-space dilation)
4
y y y y
p2 p1
s = m 30 p x + m 31 p y + m 33 t = m 30 nˆ x + m 31nˆ y

p2 p1
u = w s ( m 00 nˆ x + m 01 nˆ y ) − t ( m 00 p x + m 01 p y + m 03 )
x x x x v = h s ( m 10 nˆ x + m 11 nˆ y ) − t ( m 10 p x + m 11 p y + m 13 )

p1 s 3t + s 2 u 2 + v 2
p3 d=
p1 p3 p2 p3 p2 p3 u 2 + v 2 − s 2t 2

Copyright © 2021

You might also like