Tracking Monte Carlo particles (or in this case, ray traces) through a geometry can be tricky because of the subtlety of edge cases. Today I discovered that my tracking routine failed when given a direction of −0.0 . I never imagined that the existence of signed zeroes in IEEE floating point arithmetic could ever bite me.
23 February 2011
21 February 2011
Starting Terminal.app with multiple tabs in multiple directories
Almost every time I open up Terminal, I've wanted three tabs open with three particular directories. That means using Cmd-Tab a lot and tab completion to change the directory. I finally got fed up with that and invented a solution to take care of that automatically.
The first step is creating a "Window group" in the terminal. Go to the menu item "Windows < Save Windows as Group…", make up a name, and make sure "use this group at startup" is checked.
The second step is to edit your ~/.bash_profile
and add something like this, where each "if" statement gets a different command. This is adaptable to changing the base directory, sshing, etc.
# change PWD to python by default function change_default_directory() { TTYN=$(tty | sed -e 's/.*ttys\([0-9]*\)/\1/') if [[ $TTYN == 000 ]]; then cd ~/_code/pytrt/ elif [[ $TTYN == 001 ]]; then cd ~/_code/_build/pytrt/ elif [[ $TTYN == 002 ]]; then cd ~/_code/_build/pytrtDEBUG/ elif [[ $TTYN == 003 ]]; then cd ~/_research/current/ fi } if [ -n "$PS1" ]; then change_default_directory; fi
Add more elif
blocks if you open five windows, take away more if you open fewer. Enjoy!
12 February 2011
Reflecting on the hard work I've put into my research code
I am still proud of my code to get the angle in a quadrature set reflected across an axis. It's a little crazy.
const AngleT& getReflectedAngle(const AngleT& a, unsigned int axis ) const { return angles_[ (a.getOctantIndex() ^ (1 + ( axis << 1)) + 1) * numAnglesPerOctant_ - 1 - a.getSubIndex() ]; }
This section of code is copyright © 2011 Seth R Johnson, All rights reserved.