You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
James-Oswald opened this issue
Oct 9, 2023
· 0 comments
· Fixed by #108
Assignees
Labels
BugSomething isn't working. Rightmost number in semantic versioningrequiredThis feature is required to be implemented by the current implementation team
We have divergent overlaps implementations causing issues.
in elipse.ts
publicoverlaps(otherShape: Rectangle|Ellipse): boolean {if(otherShapeinstanceofRectangle){for(leti=0;i<4;i++){if(this.containsPoint(otherShape.getCorners()[i])){returntrue;}}returnfalse;}else{//check if the rectangular bounding boxes of the ellipse overlapif(this.boundingBox.overlaps((otherShapeasEllipse).boundingBox)||//this.boundingBox.containsShape((otherShape as Ellipse).boundingBox) ||(otherShapeasEllipse).boundingBox.containsShape(this.boundingBox)){//return true;//if there is an overlap, check if points along the ellipse curve overlap//this can be done by checking if points along the curve of this ellipse//are within the other ellipseconstpoints: Point[]=this.getEllipsePoints();for(leti=0;i<points.length;i++){if(otherShape.containsPoint(points[i])){returntrue;}}}returnfalse;}}
and in rectangle.ts
publicoverlaps(otherShape: Rectangle|Ellipse): boolean {if(otherShapeinstanceofRectangle){returnthis.edgesOverlap(otherShape);}elseif(otherShapeinstanceofEllipse){for(leti=0;i<4;i++){if(otherShape.containsPoint(this.getCorners()[i])){returntrue;}}returnfalse;}else{throwError("Invalid Shape passed to overlaps, must be a Rectangle | Ellipse");}}
elipse.overlaps(rectangle) and rectangle.overlaps(ellipse) should ALWAYS return the same thing
but clearly, they don't due to the fact we have completely deferent implementations.
You should move ALL of this logic to a single helper function (probably in a new file, AEGUtils or something) overlaps(s1 : Rectangle | Ellipse, s2 : Rectangle | Ellipse) that both methods call.
The text was updated successfully, but these errors were encountered:
James-Oswald
added
Bug
Something isn't working. Rightmost number in semantic versioning
required
This feature is required to be implemented by the current implementation team
labels
Oct 9, 2023
BugSomething isn't working. Rightmost number in semantic versioningrequiredThis feature is required to be implemented by the current implementation team
We have divergent overlaps implementations causing issues.
in elipse.ts
and in rectangle.ts
elipse.overlaps(rectangle)
andrectangle.overlaps(ellipse)
should ALWAYS return the same thingbut clearly, they don't due to the fact we have completely deferent implementations.
You should move ALL of this logic to a single helper function (probably in a new file, AEGUtils or something)
overlaps(s1 : Rectangle | Ellipse, s2 : Rectangle | Ellipse)
that both methods call.The text was updated successfully, but these errors were encountered: