[android-developers] google api demo question about drawBitmapMesh algorithm
Hi all,
I'm not good at mathematics algorithm, so i can't undanstand the following code
private void warp(float cx, float cy) {
final float K = 10000; // why it is 10000 ??
float[] src = mOrig;
float[] dst = mVerts;
for (int i = 0; i < COUNT*2; i += 2) {
float x = src[i+0];
float y = src[i+1];
float dx = cx - x;
float dy = cy - y;
float dd = dx*dx + dy*dy;
float d = FloatMath.sqrt(dd);
float pull = K / (dd + 0.000001f);
pull /= (d + 0.000001f); // so it is pull = d * K / (dd), what is it meaning ?
final float K = 10000; // why it is 10000 ??
float[] src = mOrig;
float[] dst = mVerts;
for (int i = 0; i < COUNT*2; i += 2) {
float x = src[i+0];
float y = src[i+1];
float dx = cx - x;
float dy = cy - y;
float dd = dx*dx + dy*dy;
float d = FloatMath.sqrt(dd);
float pull = K / (dd + 0.000001f);
pull /= (d + 0.000001f); // so it is pull = d * K / (dd), what is it meaning ?
// let me take a example, there have a triangle, a, b, c
// pull is c/sqrt(a*a + b*b) then * 10000? what is the result meaning?? maybe the c/sqrt(a*a + b*) is 1 or less 1 or more then 1. can anyone tell me why it * 10000?
// and what it meaning about the result d * K / (dd), ?
android.util.Log.d("skia", "index " + i + " dist=" + d + " pull=" + pull);
if (pull >= 1) {
dst[i+0] = cx;
dst[i+1] = cy;
} else {
dst[i+0] = x + dx * pull;
dst[i+1] = y + dy * pull;
}
}
}
dst[i+0] = cx;
dst[i+1] = cy;
} else {
dst[i+0] = x + dx * pull;
dst[i+1] = y + dy * pull;
}
}
}
best regards, thanks.
-- You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home