게임 개발을 위해 accelerometer를 공부하고 있습니다.
http://xiangchen.wordpress.com/2011/12/17/an-android-accelerometer-example/
위 사이트에 있는 예제를 실행해보고 있는데요.
탄성. 즉 마찰인 부분을 수정했으면 하는데 공식들이 이해가 안가서요...
// taking into account the frictions
mAx = Math.signum(mAx) * Math.abs(mAx) * (1 - FACTOR_FRICTION * Math.abs(mAz) / GRAVITY);
mAy = Math.signum(mAy) * Math.abs(mAy) * (1 - FACTOR_FRICTION * Math.abs(mAz) / GRAVITY);
이부분과
// calculate and update the ball's position
public boolean updateOvalCenter() {
mVx -= mAx * mDeltaT;
mVy += mAy * mDeltaT;
mXCenter += (int)(mDeltaT * (mVx + 0.5 * mAx * mDeltaT));
mYCenter += (int)(mDeltaT * (mVy + 0.5 * mAy * mDeltaT));
if(mXCenter < RADIUS){
mXCenter = RADIUS;
mVx = -mVx * FACTOR_BOUNCEBACK;
}
if(mYCenter < RADIUS) {
mYCenter = RADIUS;
mVy = -mVy * FACTOR_BOUNCEBACK;
}
if(mXCenter > mWidthScreen - RADIUS) {
mXCenter = mWidthScreen - RADIUS;
mVx = -mVx * FACTOR_BOUNCEBACK;
}
if(mYCenter > mHeightScreen - 2 * RADIUS) {
mYCenter = mHeightScreen - 2 * RADIUS;
mVy = -mVy * FACTOR_BOUNCEBACK;
}
return true;
}
이 함수부분에 사용된 공식의 원리를 알고 싶습니다.. 물리와 수학을 못해서..ㅠㅠ
흐름이라도 설명해주세요. 부탁드립니다:)