Last active
December 12, 2015 05:48
-
-
Save mazbox/4724446 to your computer and use it in GitHub Desktop.
How to bilinear interpolate a quad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ofVec2f rowCols[5][5]; | |
ofVec2f texz[5][5]; | |
int i = 0; | |
int j = 0; | |
for(float xx = 0; xx <= 1; xx += 0.25) { | |
// here's the meat | |
ofVec2f p0_p1 = quad[0]*xx + quad[1]*(1.f-xx); | |
ofVec2f p4_p3 = quad[2]*xx + quad[3]*(1.f-xx); | |
j = 0; | |
for(float yy = 0; yy <= 1; yy += 0.25) { | |
ofVec2f p = p0_p1 * yy + p4_p3 * (1.f - yy); | |
rowCols[i][j] = p; | |
texz[i][j] = ofVec2f(xx, yy); | |
j++; | |
} | |
i++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment