# 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 |

You, my friend, are a true geek. But you already knew that ;) I’m eager to hear more about life in the big city and at the UCI campus. I hope you keep blogging!

Would it have been more practical to eschew the algebraic approach and go for the geometric?

And, btw… 2 + 9 = 9 + 2, despite what your spam protection believes.

Yes, I thought about the geometric approach, but then I would’ve needed some string, tacks, a protractor, and a long enough straight edge. But alas, I was only equipped with an 18in ruler and a computer. So I took the algebraic approach, because it was easier to directly measure using the walls as my guide, and rounding to the nearest 1/4in.

Yeah, I admit the spam filtering is really simplistic, and I should probably go for something more interesting such as stealing questions from gre physics and math exams.