I need to sort and remove vertex and I used this thing. But recently I realized that this method is terrible slow.
function Face(v1, v2, v3) {
var df = Math.hypot(v2[0] * 1 - v3[0] * 1, v2[1] * 1 - v3[1] * 1, v2[2] * 1 - v3[2] * 1);
if (df != 0) {
for (var dp = 0; dp < df; dp += gap) {
x = v3[0] * 1 + (v2[0] * 1 - v3[0] * 1) / df * dp;
y = v3[1] * 1 + (v2[1] * 1 - v3[1] * 1) / df * dp;
z = v3[2] * 1 + (v2[2] * 1 - v3[2] * 1) / df * dp;
var ds = Math.hypot(x - v1[0] * 1, y - v1[1] * 1, z - v1[2] * 1);
if (ds != 0) {
for (var dps = 0; dps < ds; dps += gap) {
fx = v1[0] * 1 + (x - v1[0] * 1) / ds * dps;
fy = v1[1] * 1 + (y - v1[1] * 1) / ds * dps;
fz = v1[2] * 1 + (z - v1[2] * 1) / ds * dps;
var ffx = Math.round(fx / gap) * gap;
var ffy = Math.round(fy / gap) * gap;
var ffz = Math.round(fz / gap) * gap;
if (check) {
if (!(findOne(output, [ffx, ffy, ffz]))) {
output.push([ffx, ffy, ffz]);
}
} else {
output.push([ffx, ffy, ffz]);
}
}
}
}
}
}
Face(vertex1,vertex2,vertex3); without checking, Much more faster. (This method is call almost 1000~10000 times)
findOne(arr,[1,2]);//returns true. (I NEED THIS)
arr.includes([1,2]);//returns false.
arr[0]==[1,2];// returns false.
function findOne(arr, arr2) {
for(var l=0;l<arr.length;l++){
if(arr[l][0]==arr2[0]&&arr[l][1]==arr2[1]&&arr[l][2]==arr2[2]){
return true;
}
}
return false;
}
I tried with arr0.include(arr1), but this doesnt work if param is array. if(arr0 == arr1) also didnt worked.
Does anyone know the solution?