Compare commits

...

2 Commits

Author SHA1 Message Date
Matthieu Baumann
ac4af8fb18 fix Circle::intersectBbox 2025-08-29 11:54:31 +02:00
Erik Mellegard
279f93c4ba Fix Circle intersectBBox 2025-06-13 10:14:15 +02:00
5 changed files with 14 additions and 5 deletions

View File

@@ -45,7 +45,6 @@ export let DefaultActionsForContextMenu = (function () {
const a = aladinInstance;
const selectObjects = (selection) => {
console.log(selection)
a.view.selectObjects(selection);
};
return [

View File

@@ -251,7 +251,7 @@ export let Footprint= (function() {
return true;
}
}
return false;
return this.shapes.some((shape) => shape.intersectsBBox(x, y, w, h, view));
};
return Footprint;

View File

@@ -135,10 +135,12 @@ export class Selector {
}
// footprints
overlayItems = cat.getFootprints();
if (overlayItems) {
const {x, y, w, h} = selection.bbox();
for (var l = 0; l < overlayItems.length; l++) {
f = overlayItems[l];
if (f.intersectsBBox(x, y, w, h, view)) {
objListPerCatalog.push(f);
}

View File

@@ -322,10 +322,17 @@ export let Circle = (function() {
};
// From StackOverflow: https://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection
Circle.prototype.intersectsBBox = function(x, y, w, h) {
Circle.prototype.intersectsBBox = function(x, y, w, h, view) {
var centerXyview = view.aladin.world2pix(this.centerRaDec[0], this.centerRaDec[1]);
if (!centerXyview) {
return false;
}
// compute the absolute distance between the middle of the bbox
// and the center of the circle
const circleDistance = {
x: Math.abs(this.center.x - x),
y: Math.abs(this.center.y - y)
x: Math.abs(centerXyview[0] - (x + w/2)),
y: Math.abs(centerXyview[1] - (y + h/2))
};
if (circleDistance.x > (w/2 + this.radius)) { return false; }

View File

@@ -346,6 +346,7 @@ export let Ellipse = (function() {
Ellipse.prototype.intersectsBBox = function(x, y, w, h) {
// todo
return false;
};
return Ellipse;