mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-14 12:23:03 +01:00
Some method for generic boolean algorithm
This commit is contained in:
parent
898cd156bf
commit
9983904a70
3 changed files with 33 additions and 10 deletions
|
|
@ -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'
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue