Linear Interpola-on from Cells Han-Wei Shen The Ohio State - - PowerPoint PPT Presentation
Linear Interpola-on from Cells Han-Wei Shen The Ohio State - - PowerPoint PPT Presentation
Linear Interpola-on from Cells Han-Wei Shen The Ohio State University Why Interpola-on? Most visualiza-on algorithms have to deal with discrete data Data aEributes that define at the cell ver-ces (d) polyline (e) triangle (b)
Why Interpola-on?
- Most visualiza-on algorithms have to deal
with discrete data
– Data aEributes that define at the cell ver-ces
(a) vertex (b) Polyvertex (c) line (d) polyline (e) triangle (e) Quadrilateral (e) Polygon (f) Tetrahedron (f) Hexahedron
Why Interpola-on?
p P = ? 10 13 9 12
- Example: Produce a color map from a 2D
regular grid
- 1. Interpolate the values from the cell corners to get
the value of P
- 2. Apply a color to P
Linear Interpola-on (LERP)
- Linear interpola-on (lerp): connec-ng two
points with a straight line in the func-on plot
x f(x)
x1 f(x1) x2 f(x2) P lerp(f(x1),f(x2) true value
Linear Interpola-on (LERP)
- General form:
v1 v2 v3 v4
- P
vi : value at vertex i
wi: weight for vi
Vp = Σ wi * vi (weighted sum)
Linear Interpola-on (LERP)
- General form:
- Essen-al informa-on needed:
– Cell type – Data at cell corners – Parametric coordinates of the point in ques-on (P)
- Related to the posi-on of point P in the cell
Vp = Σ wi * vi (weighted sum)
v1 v2 v3 v4
- P
vi : value at vertex i
wi: weight for vi
LERP in Line
- Parametric coordinate of P: α = a / (a+b)
a b
v1 v2 P
- Linearly interpolated value of P:
Vp ? lerp(v1,v2, α )
Vp = (1- α ) * V1 + α * V2
Lerp in Triangle
A B C P Vp ?
Lerp in Triangle
A B C P Vp ?
δA
Lerp in Triangle
A B C P Vp ?
δA δB
Lerp in Triangle
A B C P Vp ?
δA δB δC
Lerp in Triangle
A B C P Vp ?
δA δB δC
- Parametric coordinates of P: (α,β,γ)
α = δA / (δA + δB + δC) β = δB / (δA + δB + δC) γ = δC / (δA + δB + δC)
Baricentric Coordinates
- Linearly interpolated value of P: VA * α + VB * β + VC * γ
Lerp in Rectangle
A B C D Vp ? P
Lerp in Rectangle
A B C D Vp ? P
- Parametric coordinates of P: (α,β)
α = a / width;
a a
Lerp in Rectangle
A B C D Vp ? P L1 L2
- Value at L1 = Lerp(VA,VB,α) ;
- Value at L2 = Lerp(VC,VD,α) ;
- Parametric coordinates of P: (α,β)
α = a / width;
a a
Lerp in Rectangle
A B C D Vp ? P L1 L2
b a
- Parametric coordinates of P: (α,β)
α = a / width;
a
Lerp in Rectangle
A B C D Vp ? P L1 L2
b a
- Parametric coordinates of P: (α,β)
α = a / width; β = b / height
a
Lerp in Rectangle
A B C D Vp ? P L1 L2
- Linearly interpolated value of P: Lerp(VL1, VL2, β)
b a
- Parametric coordinates of P: (α,β)
α = a / width; β = b / height
a
Lerp in Rectangle
A B C D Vp ? P L1 L2
- Linearly interpolated value of P: Lerp(VL1, VL2, β)
b a
- Parametric coordinates of P: (α,β)
α = a / width; β = b / height
a
Bi-linear interpola-on Bi-Lerp(VA,VB, VC,VD)
Lerp in Cube
x y z V2 V6 V4 V0 V5 V1 V3 V7
P
Lerp in Cube
x y z V2 V6 V4 V0 V5 V1 V3 V7 B A
- Value at A = Bi-Lerp(V0,V1,V2,V3) ;
- Value at B = Bi-Lerp(V4,V5,V6,V7) ;
P
Lerp in Cube
x y z V2 V6 V4 V0 V5 V1 V3 V7 B A
- Value at A = Bi-Lerp(V0,V1,V2,V3) ;
- Value at B = Bi-Lerp(V4,V5,V6,V7) ;
P
Lerp in Cube
x y z V2 V6 V4 V0 V5 V1 V3 V7 B A
- Value at A = Bi-Lerp(V0,V1,V2,V3) ;
- Value at B = Bi-Lerp(V4,V5,V6,V7) ;
- Value at P = Lerp(A,B, PA/AB);
P Tri-linear interpola-on
Lerp in Cube
x y z c a b V2 V6 V4 V0 V5 V1 V3 V7
P
- Parametric coordinates of P: (α,β)
α = a / width; β = b / depth (along y); γ = c / height
- Value at P =
(1-α)(1-β)(1-γ)V0 + α(1-β)(1-γ)V1 + (1-α)β(1-γ)V2 + αβ(1-γ)V3 + (1-α)(1-β)γV4 + α(1-β)γV5 + (1-α)βγV6 + αbρV7
Another way to perform calculate the value at P:
Lerp in Cube
x y z c a b V2 V6 V4 V0 V5 V1 V3 V7
P
- Parametric coordinates of P: (α,β,γ)
α = a / width; β = b / depth (along y); γ = c / height
- Value at P =
(1-α)(1-β)(1-γ)V0 + α(1-β)(1-γ)V1 + (1-α)β(1-γ)V2 + αβ(1-γ)V3 + (1-α)(1-β)γV4 + α(1-β)γV5 + (1-α)βγV6 + αβγV7
Another way to perform calculate the value at P:
Lerp in Tetrahedron
P A B C D
Lerp in Tetrahedron
P
- Break the tetrahedron ABCD into four sub tetrahedra:
ABCP, BDCP, ACDP, ADBP
- Calculate the volume of each small tetrahedra
- Calculate P’s parametric (tetrahedral) coordinates
based on the ra-os of the volumes
A B C D
Lerp in Tetrahedron
P A B C D
- Tetrahedral coordinates of P: (α,β,γ,δ)
α = VBDCP / VABCD β = VACDP / VABCD γ = VADBP / VABCD δ = VABCP / VABCD
- Linearly interpolated value of P: VA * α + VB * β + VC * γ + VD * δ