# Geeking out

I am a dyed-in-the-wool geek. When I first moved into my apartment here at UCI, and found out that all my stuff didn’t quite fit into my room, what did I do about it?

I drafted the floor plan of my room, and made paper cutouts of all my furniture. Then arranged and re-arranged all the paper squares until I found a layout I liked. It was a rather tedious process, but it worked quite well. The paper was much easier to shuffle around than the furniture it represented.

Then, I decided that the corner where I put my desk was not very well lit; and instead of a lamp, I wanted ceiling lights. At a nearby Lowes I saw some under-counter lights, a pack of six 20-Watt Xenon pucks. Well, given that my desk sits in a recessed section of the room, and that a line of lights isn’t nearly as nice as, say, a half-ellipse, I had to figure out some way of generating the coordinates for the placement of those lights.

Originally I was going to do this by hand, on paper, so, I checked out the wikipedia article about the ellipse; which gave me a nice parameterized formulation.

where may be restricted to the interval .

Using this formula, I whipped up a program to generate the coordinates for the lights:

#include <QApplication> #include <QtGui> #include <QDebug>   int main( int argc, char *argv[] ) { QApplication app(argc, argv);   QPixmap pix(100,100); pix.fill(); QPainter painter(&pix); painter.translate(50,50); painter.setRenderHint( QPainter::Antialiasing );   painter.setPen( QPen(QBrush(Qt::green), 1) ); painter.drawPoint( QPointF(0.,0.) ); painter.drawRect( -36,0, 72,24 );   painter.setPen( QPen(QBrush(Qt::blue), 1) ); painter.drawEllipse( -36,-24, 72,48 );   painter.setPen( QPen(QBrush(Qt::red), 2) ); for (int i=0; i<6; i++) { qreal t = 3.14159*(i+.5)/6.; qreal x = 36*cos(t); qreal y = 24*sin(t); qDebug() << "x: " << 36-x << " y: " << y; painter.drawPoint(QPointF(x,y)); } painter.end();   QLabel *label = new QLabel; label->setPixmap(pix); label->show();   return app.exec(); }

Which, generated the output:

 x: 34.7733 y: 6.21165 x: 25.4559 y: 16.9706 x: 9.31752 y: 23.1822 x: -9.31743 y: 23.1822 x: -25.4558 y: 16.9706 x: -34.7733 y: 6.21171