3d-interface/js/HermiteTest/HermiteTest.js

45 lines
1015 B
JavaScript
Raw Normal View History

2015-04-14 12:02:35 +02:00
var container = document.getElementById('content');
function print(text) {
var content = document.createTextNode(text);
var new_line = document.createElement('br');
container.appendChild(content);
container.appendChild(new_line);
}
function toString(variable) {
if (variable instanceof THREE.Vector3) {
return variable.x + ', ' + variable.y + ', ' + variable.z;
} else {
return variable;
}
}
// Test with THREE.Vector3
2015-04-16 12:23:47 +02:00
// t = [0,1];
// f = [new THREE.Vector3(0,0,0), new THREE.Vector3(1,1,1)];
// fp = [new THREE.Vector3(0,1,2), new THREE.Vector3(0,0,0)];
2015-04-14 12:02:35 +02:00
// Test with doubles
2015-04-16 12:23:47 +02:00
t = [0,1];
f = [0,1];
fp = [-1,-1];
2015-04-14 12:02:35 +02:00
2015-04-20 16:34:41 +02:00
var hermite = new Hermite.special.Polynom(0, 1, -1);
2015-04-14 12:02:35 +02:00
print('M = [');
for (var t = 0; t < 1; t += 0.01) {
var res = hermite.eval(t);
2015-04-20 16:34:41 +02:00
print("\t" + t + ',' + toString(res) + ';');
2015-04-14 12:02:35 +02:00
}
print('];');
print('MP = [');
for (var t = 0; t < 1; t += 0.01) {
var res = hermite.prime(t);
2015-04-20 16:34:41 +02:00
print("\t" + t + ',' + toString(res) + ';');
2015-04-14 12:02:35 +02:00
}
print('];');