Some method for generic boolean algorithm

This commit is contained in:
Val Erastov 2017-06-27 19:22:37 -07:00 committed by xibyte
parent 898cd156bf
commit 9983904a70
3 changed files with 33 additions and 10 deletions

View file

@ -85,8 +85,11 @@ export class NurbsSurface {
this.verb = verbSurface;
}
coplanarUnsigned(other, tolerance) {
const tess = this.verb.tessellate({maxDepth: 3});
toNurbs() {
return this;
}
coplanarUnsignedForSameClass(other, tolerance) {
throw 'not implemented'
}
}

View file

@ -52,16 +52,14 @@ export class Plane extends Surface {
return this.__3dTr;
}
coplanarUnsigned(other, tol) {
return other instanceof Plane &&
math.areVectorsEqual(this.normal.multiply(this.w), other.normal.multiply(other.w), tol);
coplanarUnsignedForSameClass(other, tol) {
return math.areVectorsEqual(this.normal.multiply(this.w), other.normal.multiply(other.w), tol);
//TODO: store this.normal.multiply(this.w) in a field since it's constant value
}
equals(other, tol) {
return other instanceof Plane &&
math.areVectorsEqual(this.normal, other.normal, tol) &&
math.areEqual(this.w, other.w, tol);
equalsForSameClass(other, tol) {
return math.areVectorsEqual(this.normal, other.normal, tol) &&
math.areEqual(this.w, other.w, tol);
}
toParametricForm() {

View file

@ -13,8 +13,30 @@ export class Surface {
throw 'not implemented';
}
coplanarUnsignedForSameClass(other, tol) {
throw 'not implemented';
}
equalsUnsignedForSameClass(other, tol) {
throw 'not implemented';
}
isSameClass(other) {
return this.constructor.name == other.constructor.name;
}
coplanarUnsigned(other, tol) {
if (this.isSameClass(other)) {
return this.coplanarUnsignedForSameClass(other, tol)
}
return this.toNurbs().coplanarUnsignedForSameClass(other.toNurbs());
}
equals(other, tol) {
if (this.isSameClass(other)) {
return this.equalsForSameClass(other, tol)
}
return this.toNurbs().equalsForSameClass(other.toNurbs());
}
}
Surface.prototype.isPlane = false;