Skip to content

Commit

Permalink
big circle draw fix for #126. Try to make the source inside the circle
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatthieu3 committed Oct 23, 2023
1 parent bda3e50 commit 733f81f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions examples/al-big-circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
import A from '../src/js/A.js';
let aladin;
A.init.then(() => {
// Start up Aladin Lite
aladin = A.aladin('#aladin-lite-div', {survey: "CDS/P/DSS2/color", target: 'M 1', fov: 0.2, showContextMenu: true, fullScreen: true});
aladin = A.aladin('#aladin-lite-div', {target: 'M 1', fov: 180});

var overlay = A.graphicOverlay({color: '#ee2345', lineWidth: 3});
aladin.addOverlay(overlay);
overlay.add(A.circle(83.66067, 22.03081, 40.0, {color: 'cyan'})); // radius in degrees
overlay.add(A.circle(83.66067, 0, 30, {color: 'cyan'})); // radius in degrees
var cat = A.catalog({name: 'Some markers', sourceSize: 18});
aladin.addCatalog(cat);
cat.addSources([A.marker(83, 29, {popupTitle: 'Point1', popupDesc: 'Does not show up in circle'})]);

aladin.on("footprintClicked", (footprint) => {
console.log("footprint clicked catched", footprint)
Expand Down
10 changes: 5 additions & 5 deletions src/js/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ export let Circle = (function() {
let hidden = true;

var ra, dec, vertOnCircle, dx, dy;
if (view.fov > 90) {
this.radius = Number.POSITIVE_INFINITY;
//if (this.radiusDegrees > 30) {
this.radius = Number.NEGATIVE_INFINITY;

// Project 4 points lying on the circle and take the minimal dist with the center as radius
[[-1, 0], [1, 0], [0, -1], [0, 1]].forEach(([cardDirRa, cardDirDec]) => {
Expand All @@ -181,12 +181,12 @@ export let Circle = (function() {
dx = vertOnCircle[0] - this.center.x;
dy = vertOnCircle[1] - this.center.y;

this.radius = Math.min(Math.sqrt(dx*dx + dy*dy), this.radius);
this.radius = Math.max(Math.sqrt(dx*dx + dy*dy), this.radius);

hidden = false;
}
});
} else {
/*} else {
ra = this.centerRaDec[0] + this.radiusDegrees;
dec = this.centerRaDec[1];
Expand All @@ -199,7 +199,7 @@ export let Circle = (function() {
this.radius = Math.sqrt(dx*dx + dy*dy);
hidden = false;
}
}
}*/

if (hidden) {
return;
Expand Down

0 comments on commit 733f81f

Please sign in to comment.