Producing a simple 3d Animation with Mathematica 7.0 running in parallel on four kernels.

This is an advance on something I am currently working for www.isallaboutmath.com

I need to produce some Spheres in 3d rotating in space so I figure since I have Mathematica 7.0 and it produces very good 3d images I should be able to use it.

I am going to list the code and explained what it does

p1[\[Theta]_] := RotationTransform[\[Theta], {0, 0, 1}][{0, 3.5, 0}];
a1[\[Theta]_] :=
RotationTransform[\[Theta], {0, 0, 1}][{0, 3.5, -1/2}];
a2[\[Theta]_] := RotationTransform[\[Theta], {0, 0, 1}][{0, 3.5, 1/2}];
r[\[Theta]_] :=
Rasterize[
Style[Graphics3D[{Sphere[{0, 0, 0}, .8], Sphere[p1[\[Theta]], 1/4],
{Orange, Tube[{a1[\[Theta]], a2[\[Theta]]}, 0.04]},
{Blue, Tube[{{0, 0, 0}, p1[\[Theta]]}, 0.04]},
{Red, Tube[{{0, 0, -1}, {0, 0, 1}}
]}}, PlotRange -> 4.5, Boxed -> False, Background -> Black,
ImageSize -> {790, 480}, ViewPoint -> {3, 3, 3},
BaseStyle -> Yellow, Axes -> False, AspectRatio -> 1]
, Antialiasing -> True], RasterSize -> 2500];
DistributeDefinitions[p1];
DistributeDefinitions[r];
DistributeDefinitions[a1];
DistributeDefinitions[a2];
ParallelTable[
Export["planeta" <> ToString[\[Theta]] <> “.png”,
r[N[\[Theta], 4]/100], ImageResolution -> 2500,
ImageSize -> {790, 480}], {\[Theta], 0, 628, 1}]

p1[\[Theta]_] := RotationTransform[\[Theta], {0, 0, 1}][{0, 3.5, 0}];

a1[\[Theta]_] :=

RotationTransform[\[Theta], {0, 0, 1}][{0, 3.5, -1/2}];

a2[\[Theta]_] := RotationTransform[\[Theta], {0, 0, 1}][{0, 3.5, 1/2}];

r[\[Theta]_] :=

Rasterize[

Style[Graphics3D[{Sphere[{0, 0, 0}, .8], Sphere[p1[\[Theta]], 1/4],

{Orange, Tube[{a1[\[Theta]], a2[\[Theta]]}, 0.04]},

{Blue, Tube[{{0, 0, 0}, p1[\[Theta]]}, 0.04]},

{Red, Tube[{{0, 0, -1}, {0, 0, 1}}

]}}, PlotRange -> 4.5, Boxed -> False, Background -> Black,

ImageSize -> {790, 480}, ViewPoint -> {3, 3, 3},

BaseStyle -> Yellow, Axes -> False, AspectRatio -> 1]

, Antialiasing -> True], RasterSize -> 2500];

DistributeDefinitions[p1];

DistributeDefinitions[r];

DistributeDefinitions[a1];

DistributeDefinitions[a2];

ParallelTable[

Export["planet" <> ToString[\[Theta]] <> “.png”,

r[N[\[Theta], 4]/100], ImageResolution -> 2500,

ImageSize -> {790, 480}], {\[Theta], 0, 628, 1}]

The first 3 lines are making rotations around the z axis in 3d space of a point located at (0,3.5,0) and two other points located at (0,3.5,-1/2) and (0,3.5,1/2).

The next line where we define the function r is the meat of the program and where most of the hard work is done we use Rasterize to get an image the argument we use in the function defined represents the angle of rotation of the object we are rotating in our case we will be rotating a sphere and a line.

Since doing this computations is very computer intensive task and Mathematica 7.0 by default give you access to 4 parallel kernels we decided to use the parallel power of Mathematica 7.0.  So we need to distribute the definitions of the functions we have created and that is archive with DistributeDefinitions and can be seen on the next 4 lines.

Finally we get to the ParallelTable this is very much equivalent to Table command in Mathematica but it is executed in parallel!

We use Export to produce an image on a local directory  and in our case we are exporting png images (a type of compressed raster image) we are using also very high resolution as to produce very good quality images.

Since we need to output a sequence of images they need to be name in an increasing and ordered sequence so that the graphics program where we will assemble the animation can pick up the images easily. In our case we use Adobe After Effect CS4 to transform the sequence of images out of Mathematica 7.0 to produce the animation. This method produce images of very good quality. The images in this case will be named planet1.png, planet2.png, …. up to planet628.png

and the rotation of the angle will go from 0 to 6.28 or approximately 2 Pi! so one complete round trip around the center.

This is one image of the animation.

planeta19

The image seems to be a little squash this has to do with Mathematica producing images for video once it gets into Adobe After Effect we can select Interpret Footage with Pixel Aspect Ratio of 0.91 ratio and then the sphere will look round again!

Here is the short animation

The results of this will appear in an upcoming animation for www.isallaboutmath.com about Thales of Miletus.

Leave a Comment

Filed under math, Mathematica, mathematics

Making learning Fun. Algodoo.

http://www.algodoo.com/wiki/Home

Algodoo is a fantastic software that provides a unique learning experience for kids and adults is derive from Phun a software we describe here a while back.

See prior post on Phun at

http://blog.isallaboutmath.com/2008/06/09/livios-mathematical-creation-with-phun/

Leave a Comment

Filed under math

Conformal Mappings and Art

Follow the link to see some awesome applications of the Conformal mapping to pictures

http://www.flickr.com/photos/sbprzd/sets/72157594172266668/

Leave a Comment

Filed under math

The Oracle of Wolfram. Wolframalpha.

It could be said this is the comming of age of search engine. We have seen yahoo first then google and many other minor stars. Get ready now we have

http://www.wolframalpha.com/ 

What is so different or new about this search engine?

Well to start it uses Mathematica to produce the result of the queries! Mathematica is a wonderful software that allows one to do very sofisticated mathematical computation and that have a lot of information embeded in the system.

Wolframalpha allows one to not just search for information but to find new information from existing information in other words to mined information to ask questions to correlated information.

 I found some cute things from Wolframalpha already.

At one point I guess their servers were overwhelm and I got this answer!

I’m sorry Dave, I’m afraid I can’t do that. (Famous line from Arthur C Clarke 2001 Space Odyssey.

WolframAlpha2

On the other hand I try something simple like getting Pi to 100,000 digits and after paging a few times got this errors that shows part of the inner workings of the system is Mathematica Code !!!

 

wolfram1

To learn more about wolfram alphahttp://www.wolfram.com/products/mathematica/madepossible/wolframalpha.html

Leave a Comment

Filed under Mathematica

Tania Brugera Performance. With Spanish Subtitles.

 

Tania Brugera is a Cuban performance artist

See this video where she explain some of her work in English

 

Leave a Comment

Filed under math

Fab Labs. The future coming…

This is a wonderful TED talk about the fabrication labs from MIT

http://www.ted.com/index.php/talks/neil_gershenfeld_on_fab_labs.html

the MIT site

http://fab.cba.mit.edu/content/tools/

Leave a Comment

Filed under math

The magic of life. Cell animation.

See what is inside of each of us

http://multimedia.mcb.harvard.edu/anim_innerlife_lo.html

 

see also this TED talk

 

http://www.ted.com/index.php/talks/david_bolinsky_animates_a_cell.html

 

to think that from all this a consciousness arises that is able to learn about itself!

Leave a Comment

Filed under math

Freedom beautiful freedom!

Here is a performance in Cuba. Yoani Sanchez and many others use a minute to express freely

 

 

http://www.youtube.com/watch?v=XVV1Q6qT8Kk

What follows is a translation of what Yoani Sanchez said.

Cuba is an island surrounded by sea and is also an island surrounded by censorship. Some of the information control and especially the Internet have opened up some cracks with blogs. In the wake of alternative blogosphere and is known to a good part of the Cuban population. We are a … accentuate the awakening of public opinion.

The authorities consider the technology as a wild horse to be tame. The independent bloggers want to run freely. Difficulties in disseminating our sites are many. Passed from hand to hand and thanks to flash memory, CDs, the obsolete diskettes the content of the blogs  goes through the island.

Internet is becoming a public forum of discussion where the Cubans are writing opinions. The real island is starting to be a virtual island that is more democratic and more pluralistic. Unfortunately these winds of free expression in the Internet have only just started to show up in our watchful reality.
Let us not wait for the authorization to enter the internet. To have a blog or to write an opinion.

It is time to jump the wall of control.

See this blog post by Yoani

http://desdecuba.com/generationy/?p=472

and this other blog post by Claudia

http://octavocercoen.blogspot.com/2009/03/one-minute-of-freedom-per-person.html

Leave a Comment

Filed under blog, censorship, cuba, democracy, internet

Some Physics TED Talks

Brian Cox on the Supercollider and particle physics.

 

http://www.ted.com/index.php/talks/brian_cox_on_cern_s_supercollider.html

Brian Greene on String Theory

 

http://www.ted.com/index.php/talks/brian_greene_on_string_theory.html

Leave a Comment

Filed under math

Bottom of the Barrel.

I wrote two prior posts with statistical information about Cuba

In one I computed the average salary to be equal to 233.00 dollars approximately and in the other I show a map of  with all the countries who’s GDP per capita are less than Cuba’s GDP per capita.

Since the actual average pay for Cubans is 233.00 dollars and since that should equate to the GDP per capita I wanted to know what countries have a GDP per capita of less than 233.00 dollars.

Here is the answer I get from Mathematica

 Select[CountryData[], CountryData[#, "GDPPerCapita"] < 233 &]

{“Afghanistan”, “Burundi”, “DemocraticRepublicCongo”, “Ethiopia”,

“GuineaBissau”, “Liberia”, “Malawi”, “Myanmar”, “Niger”, 

“SierraLeone”, “Zimbabwe”}

 

and here is a map showing in color the countries whos GDP per capita is less than Cuba’s average salary!

 

worldcubagdppercapita2

Leave a Comment

Filed under cuba