직선상에 두점이 주어 졌을 때 두점 사이의 임의 점 의 값을 찾는 방법

x1 : 점1, x2 : 점2, t = 0.0~1.0

value = x1 + ((x2-x1) * t)

또는

value = x1 * (1.0f - t) + x2 * t

 

#include<iostream>
#include<conio.h>
#include <math.h>

using namespace std;

 

 

//선형보간법(linear interpolation)

double L_Inter(double x1, double x2, double t)
{
 return (x1+((x2-x1)*t));
}
void main()
{
  double X1 = 0.0;
 double X2 = 3.0;

 cout << X1 << "\t" << X2 << endl;
 for(int i = 0; i <= 10; i++)
 {
  cout << (i*0.1) << " : " << L_Inter(X1, X2, (i*0.1)) << endl;
 }
 cout << endl;
}

출처 : http://cafe.naver.com/jgcafe/596



함수는 뭔말인지 다 알아먹으니까 스킵하고

어째서 저 식이 나오는지좀 설명해줘바.

맨 위에 value랑 t는 뭐하는건지도 부탁할께.

30분 보고있어도 모르겠다 ㅅㅂㅋㅋㅋㅋㅋㅋㅋㅋ