Friday, March 20, 2009

Creating 3D Spheres in Adobe Illustrator CS3

As I mentioned in previous posts, I do some molecular dynamics work. It's helpful sometimes to have cartoon-ish pictures to aid in atomic visualization, especially when describing domains with different types of atoms. I'm also a big fan of really pretty graphics, even at the expense of time. I got a copy of Adobe Illustrator CS3 after using CS for way too long, and decided to play around. After a Google search I found out most of the information I needed, but was unfamiliar with the use of some of the tools. After compiling information from a few different sites, I finally got the hang of it. Still, what's the point in learning if you don't share what you know?

Once you're in Illustrator you're going to want to start with a simple circle. I usually show the grid and set snap to grid via the View menu. Make the path invisible and fill the circle with a solid color of your choice. Next, you are going to use the scissors tool (often hidden under the eraser or knife tool) to cut the circle in half. Do this by actively selecting the circle (so the paths are shown, you can do it with the white pointer known as the direct selection tool). Next, with the scissors tool, click the anchor point at the bottom of the circle, and then again at the top of the circle. If this has been done correctly, the middle point of the circle will suddenly shift right as shown in the pictures. Drag the right half of the circle away and delete the left half. Next, select the right half of the circle and go to Effect -> 3D -> Revolve. Leave the settings as the default, and select the preview box. You should now see your 3D sphere. Feel free to play with the lighting and other options, but I've found the default settings look best.

Thursday, March 12, 2009

Installing gnuplot on Mac OS X 10.5 (Leopard)

Not to many people's surprise anymore, I'm both an engineer and a Mac user. While this would have been a serious anomaly a couple years ago, it seems more and more common these days, especially when working with other Unix/Linux machines. That aside, I had long been plotting all my data using the various functions in Matlab, and for the most part, I was very happy with the results (see here for reference). What I found, however, is that 3D scatter plots came out looking pretty terrible, and my start in molecular dynamics simulations required the scatter plots somewhat frequently.

So, there I was, looking lustfully at the gnuplot demos, so rich in their 3D visualization options. However, after downloading, extracting, and messing around in the terminal I found latest build (4.2.4) was having some issues with the makefile, even after configuration. I searched on the web for a while for some help which was fruitless until I stumbled upon this little nugget, which was a great relief, as I tend to be sort of lazy when sifting through readme's. To be honest, that entry alone has all the information you really need, but it assumes some basic awareness of a few things I hadn't heard about before, so I thought I'd post this information in a more outright manner.
  1. MacPorts: Probably one of the coolest things ever, simple as hell, and quite powerful. MacPorts allows you to install a number of software packages by simply typing "install packagename" in the Terminal. Installation of MacPorts is a breeze once you download their disk image (.dmg) and run their installer (.mpkg), which you can get here.
  2. Once MacPorts has been installed, you'll need to start a new Terminal session. At that point, it's as easy as typing "sudo port install gnuplot" in the Terminal. I'll warn you, this installation can take a while (~30 minutes) as you download and install all the smaller software packages required.
And that's about it. Just start the terminal up and type "gnuplot". If there are any questions, leave a comment. I've only done this on 10.5, but MacPorts claims to support the latest OS, and the last release (10.4 for now). I have no reason to doubt anything they say considering how simple this all was. They should start some funny rumors since their credibility is so high right now.

UPDATE: Thanks to some feedback, I failed to note that you should install X11 and XCode before attempting to install MacPorts. X11 is available on your OS X install disc, and XCode is available (at no cost) on the Apple Developer webpage.

Wednesday, March 11, 2009

March Madness on your Conky

March Madness is here and and what better way to keep track of the action than with a scoreboard tracker at the bottom of your screen. Check out the image below:

This is accomplished by combining a python script with the conky variable scroll. The python script will get the data, parse it and put it into a acceptable format for conky to handle the display. I've talked about conky earlier and using displaying the last instant message.

Copy the following code and save it as bottomscore.py


#!/usr/bin/python
import urllib
# Open html page
fweb = urllib.urlopen("http://scores.espn.go.com/ncb/bottomline/scores")

gamestr=''
score=''
# Manipulate str for unneccessary chars
raw=str(fweb.readline())
raw=raw.replace('%20',' ');
raw=raw.replace('^','');
raw=raw.replace('&','\n')

# Open data storage
f=open('bottom.dat', 'w')
f.write(raw)
f.close()
f=open('bottom.dat', 'r')

# Parse each line, get game, create str, append str
for line in f:
if line.find('_left')>1:
gamestr=line[line.find('=')+1:-1]
score= score + gamestr + ' | '

f.close()
print score


My conky script is as follows. Save this
#avoid flicker
double_buffer yes

#own window to run simultanious 2 or more conkys
own_window yes
own_window_transparent no
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager, above

#borders
draw_borders no
border_margin 0

#shades
draw_shades no

#position
gap_x 0
gap_y 0
alignment bottom_middle

#behaviour
update_interval 1

#colour
default_color 8f8f8f
#default_shade_color 000000
own_window_colour 262626

text_buffer_size 1400

#font
use_xft yes
xftfont bauhaus:pixelsize=10

#to prevent window from moving
use_spacer none
minimum_size 1400

TEXT
${color e0e0e0} ${scroll 2847 ${execpi 60 python ~/scripts/bottomscore.py}}

Remember to edit your .conkyrc to run the right path to bottomscore.py. You may need to edit certain parameters for your screen resolution but this should give you a good start. Any questions, post a comment.
Pro Tip:To run multiple conky screens:"conky -c .conkyrc2"

Monday, March 2, 2009

How to Burn Compressed Video Files to DVD in Ubuntu

With some help from Realtimeedit and MEncoder, I developed a script file to convert common compressed video files into an .iso file which can be burned onto a DVD for set top playback on your TV.

Before you run the script, you'll need to install the following packages:

MEncoder: sudo apt-get install mencoder
DVD Author: sudo apt-get install dvdauthor

Download the script file here.

When you run the script it will prompt you for the directory, name, and extension of the video file. It will then prompt you for the aspect ratio of video file and run MEncoder to decompress the file to an mpeg format. It will then run DVD Author to write to DVD format and create an .iso file.

Use any DVD burning software to burn the .iso image to a DVD.

Hope this works for you, any comments are always appreciated.