Minor patch: Bringing labels closer

January 30, 2008

When I looked at a freshly compiled version of KStars after a long time, and zoomed in on M31, the label that read ‘M31′ was far, far away from the Galaxy, as if it were labeling the empty sky! (The separation was about 2 degrees between the left top corner of the label and the center of M31) Same was the case with M33 – this time the labeling was 50 arcminutes away.
After some tinkering around, it was pretty obvious that the offset of the label was calculated by taking the major axis of the object and scaling it by various zoom factors and adding an additional constant displacement. Now, the correct solution is to find out the actual distance of the bottom left portion of the object’s boundary from the center, so that the label is just placed outside the object to it’s bottom left. I didn’t know how to calculate that, because I don’t know the angle at which the major axis of the ellipse / rectangle is inclined. So I tried changing the computation to take the average of the major and minor axes. Now it looks a little more decent, but as is expected, there are times when the label comes too close (or maybe penetrates into) the object boundary!
Anybody willing to do a better computation should help KStars by letting the devel mailing list know!
The patch is on SVN commit #768419 to the Trunk. I know it is really a dumb patch, but makes things look better.

Here’s a copy of the patch:

— trunk/KDE/kdeedu/kstars/kstars/deepskyobject.cpp #768418:768419
@@ -328,8 +328,12 @@
double DeepSkyObject::labelOffset() const {
//Calculate object size in pixels
double majorAxis = a();
- if ( majorAxis == 0.0 && type() == 1 ) majorAxis = 1.0; //catalog stars
+ double minorAxis = b();
+ if ( majorAxis == 0.0 && type() == 1 ) { //catalog stars
+ majorAxis = 1.0;
+ minorAxis = 1.0;
+ }
double scale = SkyMap::Instance()->scale();
- double size = majorAxis * scale * dms::PI * Options::zoomFactor()/10800.0;
+ double size = ((majorAxis + minorAxis) / 2.0 ) * scale * dms::PI * Options::zoomFactor()/10800.0;
return 0.5*size + 4.;
}

Entry Filed under: KStars. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Pages

a

Archives

Tags

aKademy asteroid magnitudes astronomy Astrophotography AWK BASH Bugfix camera camstream Carnatic Flute Carnatic Music Carnatic Vocal Commit D-Bus DBus Debian diffraction FOSS.IN GNOKII GNU grunt GSoC Hackathon IIT IITM IIT Madras KDE KDE.IN kstars Linux mail merge Mass SMS mcabber Parallel Port Philips ToUcam Photography PlanetKDE procmail Saarang segfault streamer SVN The GIMP Violin Webcam

Recent Comments

pip on A python IRC bot for keeping u…
coenEveveLeld on Shaastra 2009 Hackfest –…
Jaiswar Hemant H. on A summer at TIFR
Aditya shanker raghu… on A summer at TIFR
Aditya shanker raghu… on About Me