Linear Interpolation CSCE 4813 Spring 2021 Linear Interpolation

  • Slides: 11
Download presentation
Linear Interpolation CSCE 4813 Spring 2021

Linear Interpolation CSCE 4813 Spring 2021

Linear Interpolation • Consider the problem of finding points (x, y) on a line

Linear Interpolation • Consider the problem of finding points (x, y) on a line defined by two points (x 1, y 1) and (x 2, y 2). • The slope is constant on the line, so (y-y 1)/(x-x 1) = (y 2 -y 1)/x 2 -x 1) • Solving for y, we get y = (y 2 -y 1)*(x-x 1)/(x 2 -x 1) + y 1 (x, y) (x 1, y 1) (x 2, y 2)

Linear Interpolation • If we let A = (x-x 1)/(x 2 -x 1), we

Linear Interpolation • If we let A = (x-x 1)/(x 2 -x 1), we get y = (y 2 -y 1)*A + y 1 • This can be written as y = A*y 2 + (1 -A)*y 1 • Y is a weighted average of y 1, y 2 where the weights are equal to the fraction of the line’s length on the opposite side of the x, y point (x, y) A (x 1, y 1) 1 -A (x 2, y 2)

Linear Interpolation • If we let A = (x-x 1)/(x 2 -x 1), we

Linear Interpolation • If we let A = (x-x 1)/(x 2 -x 1), we get y = (y 2 -y 1)*A + y 1 • This can be written as y = A*y 2 + (1 -A)*y 1 • Y is a weighted average of y 1, y 2 where the weights are equal to the fraction of the line’s length on the opposite side of the x, y point (x, y) A (x 1, y 1) 1 -A (x 2, y 2)

Linear Interpolation • If we let A = (x-x 1)/(x 2 -x 1), we

Linear Interpolation • If we let A = (x-x 1)/(x 2 -x 1), we get y = (y 2 -y 1)*A + y 1 • This can be written as y = A*y 2 + (1 -A)*y 1 • Y is a weighted average of y 1, y 2 where the weights are equal to the fraction of the line’s length on the opposite side of the x, y point (x, y) A (x 1, y 1) 1 -A (x 2, y 2)

Bilinear Interpolation • Consider the problem of finding points (x, y) in the rectangular

Bilinear Interpolation • Consider the problem of finding points (x, y) in the rectangular region defined by four points (x 1, y 1) (x 2, y 2) (x 3, y 3) and (x 4, y 4) (x 2, y 2) (x, y) (x 1, y 1) (x 3, y 3)

Bilinear Interpolation • We linearly interpolate between (x 1, y 1) (x 2, y

Bilinear Interpolation • We linearly interpolate between (x 1, y 1) (x 2, y 2) to get (x 1’, y 1’) • Solving, we have y 1’ = (y 2 -y 1)*(x 1’-x 1)/(x 2 -x 1) + y 1 • If we let A = (x 1’-x 1)/(x 2 -x 1), we have y 1’ = A*y 2 + (1 -A)*y 1 (x 4, y 4) (x 2, y 2) 1 -A (x, y) (x 1’, y 1’) A (x 1, y 1) (x 3, y 3)

Bilinear Interpolation • We linearly interpolate between (x 3, y 3) (x 4, y

Bilinear Interpolation • We linearly interpolate between (x 3, y 3) (x 4, y 4) to get (x 2’, y 2’) • Solving, we have y 2’ = (y 4 -y 3)*(x 2’-x 3)/(x 4 -x 3) + y 3 • If we let A = (x 2’-x 3)/(x 4 -x 3), we have y 2’ = A*y 4 + (1 -A)*y 3 (x 4, y 4) (x 2, y 2) 1 -A (x 1’, y 1’) A (x 1, y 1) 1 -A (x, y) (x 2’, y 2’) A (x 3, y 3)

Bilinear Interpolation • We linearly interpolate between (x 1’, y 1’) (x 2’, y

Bilinear Interpolation • We linearly interpolate between (x 1’, y 1’) (x 2’, y 2’) to get (x, y) • Solving, we have y = (y 2’-y 1’)*(x-x 1’)/(x 2’-x 1’) + y 1’ • If we let B = (x-x 1’)/(x 2’-x 1’), we have y = B*y 2’ + (1 -B)*y 1’ (x 4, y 4) (x 2, y 2) 1 -A (x 1’, y 1’) A (x 1, y 1) B 1 -A (x, y) 1 -B (x 2’, y 2’) A (x 3, y 3)

Bilinear Interpolation • Substituting y 1’ and y 2’ into y = B*y 2’

Bilinear Interpolation • Substituting y 1’ and y 2’ into y = B*y 2’ + (1 -B)*y 1’ we get • y = B*(A*y 4 + (1 -A)*y 3) + (1 -B)*(A*y 2 + (1 -A)*y 1) • y = A*B*y 4 + (1 -A)*B*y 3 - A*(1 -B)*y 2 + (1 -A)*(1 -B)*y 1 (x 4, y 4) (x 2, y 2) 1 -A (x 1’, y 1’) A (x 1, y 1) B 1 -A (x, y) 1 -B (x 2’, y 2’) A (x 3, y 3)

Bilinear Interpolation • Y is a weighted average of y 1, y 2, y

Bilinear Interpolation • Y is a weighted average of y 1, y 2, y 3, y 4 where weights are equal to the area of the opposite rectangle • y = y 4*A*B + y 3*(1 -A)*B - y 2*A*(1 -B) + y 1*(1 -A)*(1 -B) (x 4, y 4) (x 2, y 2) 1 -A (x 1’, y 1’) A (x 1, y 1) B 1 -A (x, y) 1 -B (x 2’, y 2’) A (x 3, y 3)