1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
function calcCoplanar(id) {
var tmp = new Array();
tmp[0] = new Array();
tmp[1] = new Array();
tmp[2] = new Array();
var num = parseInt(id.replace("p", ""));
var grp = parseInt(num / 3);
var i, d;
var vec = new Array(-1, -1, -1);
var xn, yn, zn;
var v1, v2, vt;
var str;
readData();
clearData();
var inputs = wCCinputs(ccInput);
var colin = pointsCollinearCheck();
if (colin) {
//in case all points are collinear
document.getElementById('planeEquation').innerHTML = "";
document.getElementById('collinear').innerHTML = "The points are collinear (on the same line - they do not form a plane)";
return;
}
if (inputs >= 3) {
planeDefinition();
//If 3 points entered calculate plane equation only
A = round(determinant(replaceCol(matPlane, 0, vec)), ppl);
if (A < 0) fac = -1; else fac = 1;
A *= fac;
B = round(determinant(replaceCol(matPlane, 1, vec)) * fac, ppl);
C = round(determinant(replaceCol(matPlane, 2, vec)) * fac, ppl);
D = round(det, ppl) * fac;
document.getElementById('planeEquation').innerHTML = formatPlaneEqu(A, B, C, D, ppl, 1);
document.getElementById('collinear').innerHTML = "The points are coplanar (3 points are always coplanar)";
}
else{
document.getElementById('planeEquation').innerHTML = "";
document.getElementById('collinear').innerHTML = "";
}
if (inputs >= 4) {
//At least 4 inputs entered
CCcoplanar = CCplane;
str = "The points are coplanar";
document.getElementById('collinear').innerHTML = "The points are coplanar";
for (i = 0; i < inputs; i++) {
var count = i * 3;
if ((CCplane & Math.pow(2, i)) != Math.pow(2, i)) {
xn = mata[i][0];
yn = mata[i][1];
zn = mata[i][2];
d = (A * xn + B * yn + C * zn + D) / Math.sqrt(A * A + B * B + C * C);
if (d != 0) {
document.getElementById('g' + i).innerHTML = round(d, ppl);
document.getElementById('g' + i).style.visibility = "visible";
str = "The points are not coplanar";
}
else {
CCcoplanar += Math.pow(2, i);
}
}
}
document.getElementById('collinear').innerHTML = str;
highLightPlane();
}
}
|