Nov 24, 2008

Extract font outlines

I find this tip from the talk: Doing Physics with Mathematica 6 by Michael Trott

 

GCText[text_,tsize_]:= ImportString[ExportString[Cell[TextData[StyleBox[
text, FontWeight->"Bold",FontFamily->"Helvetica"]], "Text", tsize], "PDF"]][[1]]

outlines =  (First /@ Cases[GCText["ABC", 20], _Polygon, Infinity]);

Graphics3D[{FaceForm[],EdgeForm[Black],Polygon[Map[Append[#, 10]&, outlines, {-2}]]}];

for fun:

image

Oct 5, 2008

QHull for Mathematica

mPower.m is a Mathematica package that interfaces with qhull binaries.

Installation guide is not for windows platform.

Here is the quick way to get it running on Windows Vista with Mathematica 6.0.

1. download mPower.m, and put it into the Applications subdirectory of $UserBaseDirectory 

In[1]:= $UserBaseDirectory

Out[1]= C:\Users\...\AppData\Roaming\Mathematica

2. download qhull for windows, put it into the folder C:\qhull

3. open mPower.m, modify the following two lines,

$QHULL=ToFileName[{$UserBaseDirectory, "Applications", "qhull", "src"}]

to: $QHULL="C:\\qhull\\"

qhullFiles={"qconvex",  "qdelaunay", "qhalf","qhull", "qvoronoi"};

to: qhullFiles={"qconvex.exe",  "qdelaunay.exe", "qhalf.exe","qhull.exe", \
"qvoronoi.exe"};

4. then testing, ignore the warning on regtet and pwrvtx, we only need qhull

<< "mPower.m"

points = RandomReal[1, {10, 3}];

ch = convexHull[points, convexHullFormat -> {facetNormals -> True, facets -> True}]

 

Thanks to the mPower developers

Aug 7, 2008

Financial Data: AAPL vs MSFT

Technologically speaking, Apple and Microsoft are two quite different companies in many ways. We all know that in recently several years, Apple stock is very hot. Here is the stock price: APPL vs MSFT since 2004, the legend is not necessary for this graph.

DateListPlot[{FinancialData["AAPL",{2004}], FinancialData["MSFT",{2004}]}, Joined->True, Filling->Bottom]

aaplvsmsft

Google Insights for Search gives another way to present it.

Google search volume index for "AAPL" since 2004

aapl

Google search volume index for "MSFT" since 2004

msft

Aug 6, 2008

How to extract points from a plot

pts=Cases[theplot, x_GraphicsType:>First@x, Infinity];

Example 1:

g=Plot[Sin[x],{x,0,2Pi}];
pts=Cases[g,x_Line:>First@x,Infinity];
ListPlot[pts]

image

Example 2:

g=Plot3D[Cos[x]+Cos[y],{x,0,4Pi},{y,0,4Pi}];
pts=Cases[g,x_GraphicsComplex:>First@x,Infinity];
ListPointPlot3D[pts]

image

Jul 16, 2008

Wolfram Screencast Gallery

There are some very impressive  presentations in Screencast Gallery.

I watched Spinthariscope by Theodore Gray. This simple shape editor is particularly interesting.

image

image