calcSurfacePoint function
dynamic
calcSurfacePoint(
- dynamic p,
- dynamic q,
- dynamic U,
- dynamic V,
- dynamic P,
- dynamic u,
- dynamic v,
- dynamic target,
Implementation
calcSurfacePoint(p, q, U, V, P, u, v, target) {
var uspan = findSpan(p, u, U);
var vspan = findSpan(q, v, V);
var nu = calcBasisFunctions(uspan, u, p, U);
var nv = calcBasisFunctions(vspan, v, q, V);
var temp = [];
for (var l = 0; l <= q; ++l) {
temp[l] = Vector4(0, 0, 0, 0);
for (var k = 0; k <= p; ++k) {
var point = P[uspan - p + k][vspan - q + l].clone();
var w = point.w;
point.x *= w;
point.y *= w;
point.z *= w;
temp[l].add(point.multiplyScalar(nu[k]));
}
}
Vector4 sw = Vector4(0, 0, 0, 0);
for (var l = 0; l <= q; ++l) {
sw.add(temp[l].multiplyScalar(nv[l]));
}
sw.divideScalar(sw.w);
target.set(sw.x, sw.y, sw.z);
}