% 区分線形補間（2変数関数）

pi = [0;0]; pj = [1;0]; pk = [0;1];
fi = 3; fj = 5; fk = 2;

Nijk = @(p) Nijk_param(p, pi, pj, pk);
Njki = @(p) Njki_param(p, pi, pj, pk);
Nkij = @(p) Nkij_param(p, pi, pj, pk);
f = @(p) fi*Nijk(p) + fj*Njki(p) + fk*Nkij(p);

for p = [ pi, pj, pk ]
    v = f(p);
    fprintf("%f at ( %f, %f )\n", v, p(1), p(2));
end

fprintf("稜線 PiPj\n");
for s = 0:0.2:1
    p = (1-s)*pi + s*pj;
    v = f(p);
    fprintf("%f at ( %f, %f )\n", v, p(1), p(2));
end

fprintf("稜線 PjPk\n");
for s = 0:0.2:1
    p = (1-s)*pj + s*pk;
    v = f(p);
    fprintf("%f at ( %f, %f )\n", v, p(1), p(2));
end

fprintf("PiとPjPkの中点を結ぶ直線\n");
for s = 0:0.2:1
    p = (1-s)*pi + s*((pj+pk)/2);
    v = f(p);
    fprintf("%f at ( %f, %f )\n", v, p(1), p(2));
end
