Rich Internet Application Technologies for Mathematica

Keehong Song

Pusan National University

Keywords

2002: Rich Internet Application (RIA)
- Flash technologies: Flash, Flex, Flash Remoting, Flash Communication Server, Open Laszlo
2004: Web 2.0 
 - Design Patterns and Business Models for the Next Generation of Software
2005: AJAX (Asynchronous JavaScript and XML)
- DHTML, DOM, XMLHttpRequest
- Javascript - Javascript Libraries: Prototype.js, Scriptaculous.js, Rico.js

A Typical RIA Model

AJAX for Mathematica

1. Plot Options  -  Toggle Effect

2. Draggable - Sortable Plot

Flash for Mathematica

Triangulations of a convex polygon

This is a Mathematica Notebook which finds and visualizes the triangulations of a convex polygon. As an example, 5-polygon has 5 triangulation as follows.

Depth first traversal is used to find the edges which conduce to the triangulizations of a convex polygon.

<< discreteMath`
catalanTree[{}] := {{}}
catalanTree[{a_}] := {{a}}
\(\(\(catalanTree[l_List] := 
	
        Module[{m = Rest[l], i, 
            fstElem = 
              First[l]}, 
		\((Insert[#, {fstElem}, 
                  2] &)\) /@ \((Flatten[#, 1] &)\)@
			Table[
                Distribute[
					{catalanTree[
                      Take[m, i]], 
						catalanTree[
                      Take[m, {i + 1, Length[m]}]]}, List], 
			{i, 0, 
                  Length[m]}]];\)\(
\)
    \)\)
NodeQ = Function[c, c =!= {}];
\(\(search[{lc_?NodeQ, {parent_}, rc_?NodeQ}, {l_, 
            r_}]	 := \((\((AppendTo[storage, #] &)\) /@ 
	{{l, 
                l + Length[Flatten[lc]] + 1}, 
	{l + Length[Flatten[lc]] + 
                  1, r}}; 
search[lc, {l, l + Length[Flatten[lc]] + 1}]; 

          search[rc, {l + Length[Flatten[lc]] + 1, r}])\);\)\)
\(\(search[{lc_?NodeQ, {parent_}, {}}, {l_, r_}] := 
	\((AppendTo[
            storage, {l + 1, r}]; search[lc, {l + 1, r}])\);\)\)
\(\(\(search[{{}, {parent_}, rc_?NodeQ}, {l_, r_}] := 
	\((AppendTo[
            storage, {l, v[[r]]}]; 
          search[rc, {l, 
              v[[r]]}])\);\)\(
\)
    \)\)
\(\(\(triangleEdges[n_] := 

        Block[{storage = \(branches = {}\), v, m, tree}, 
	\ v = 
            RotateRight[Range[n + 2], 1]; 
	\ tree = 
            catalanTree[Range[n]]; 
	\ Table[
            search[tree[[m]], {2, 
                1}]; 
		AppendTo[branches, 
              storage]; 
		storage = {}, 
		{m, 1, 
              Binomial[2  n, 
                  n]/\((n + 1)\)}]; 
		branches];\)\(
\)
    \)\)
\(\(\(triangulation[n_Integer, pairs_List] := 
	
        Module[{x = N[2  Pi/n], poly, v, edges}, 
		v = 
            Chop@Table[N[{Cos[x\ i], Sin[x\ i]}], {i, n}]; 
		poly = 
            Line /@ Partition[Append[v, First[v]], 2, 1]; 
		edges = 
            Line /@ \((\(v[\([#]\)] &\) /@ pairs)\); 
		Show[
            Graphics[{poly, edges}], 
		DisplayFunction -> Identity, 
            AspectRatio -> Automatic]
	];\)\(
\)
    \)\)
triangles[n_] := Binomial[2  n - 4, n - 2]/(n - 1);
tripic[n_] := 
      Map[triangulation[n, #] &,  triangleEdges[n - 2]]

triNum[n_] := 1/(n - 1) Binomial[2 (n - 2), n - 2]

\(showTriangulation[n_Integer, gons_] := 
	
      Module[{pic}, 
	 (*If\ the\ size\ is\ too\ small, \ 
          do\ not\ partition*) 
	
        pic = If[n >= 5, 
	
            Append[Partition[gons, 15], 
              Take[gons, \(-Mod[triangles[n], 15]\)]], 
	gons]; 
	
        Show[GraphicsArray[pic], 
          DisplayFunction -> $DisplayFunction]
	]\)

g = showTriangulation[6, tripic[7]]

Advantages of Web Platform

• Standardized tags/scripts are easy to develop 
	- Rapid development, low development cost
• No installation, updates or patches are necessary
	-  Low delivery and maintenance costs
• Applications are accessible from networked computers 
	- Availability, flexibility
• Applications can run on different operating systems 
	- Platform independence
• User interface (UI) is simple and standardized 	
	- Low learning curve for end users
• Richer user experiences - Audio, video, communications
• No page reloading
• Support both online and offline
• Enable more complex applications - (e.g. MS Outlook vs Webmail)
• More responsive and interactive

Websites

site1