# PythonCE for Windows CE

I'm playing with the PythonCE library for Windows CE devices, and I'm building a little graphic application (GUI) with it just to be sure that the chosen technology is the appropriate. I've always used the embedded VC++ and VB and I think it's time to move on and try new things. I've tested this library on my DELL Axim x50.

Once done, your pocket device will have installed the python command line:
Then, for executing graphical applications, we need to install the TKinter library. You'll succeed if you follow the next instructions to install the TKinter library on your pocket device:

Using TKinter for Windows CE:

1. The following archive contains 2 folders: "Windows" and "tcl8.4.3". Put all the files in "Windows" in the "Windows" folder of your PDA.
2. Create a "lib" folder in the "Program files" folder of your PDA.
3. Inside the "tcl8.4.3" folder in your archive you will find two folders: "library" and "tk8.4". Copy the "tk8.4" folder into the "lib" folder you just created on your PDA.
4. Copy all the files in "library" into a folder named "tcl8.4" you will create inside the same "lib" folder.
If  you succeed, you can execute the next example and try it on our device:

from Tkinter import *

def onCanvasClick(event):
print 'Got canvas click', event.x, event.y, event.widget

root = Tk()
root.title('MyAPP')
canv = Canvas(root, width=100, height=100)
img = PhotoImage(file='\\My Documents\\logo.gif')
canv.create_image(240,250, image=img, anchor=CENTER)
obj1 = canv.create_text(50, 30, fill="red", text='text1')
obj2 = canv.create_text(50, 70, fill="red", text='text2')
widget = Label(root, text='This is a Label')
widget.config(bg='black', fg='yellow')
widget.pack(expand=YES, fill=BOTH)
canv.bind('<Double-1>', onCanvasClick)
canv.pack()
root.mainloop()


Output Example:

# Building today the schools of tomorrow

This post is dedicated to Richard Gerver who attended the Global Education Forum held in Madrid this year, where different topics related to education were discussed. This video is the last one published in Redes about building today the schools of tomorrow (in Spanish).

"In The XXI century the only thing we know for sure is that it's going to be very different. Now the industry needs more imagination, more creativity, more skilled workers to work together, with a different mentality, a mentality more open to suggestions from others on their team".
Philip Hudson
Director SEK Catalonia
More videos:

This post is dedicated to Ken Robinson an its "Changing education paradigms". "Creativity expert Sir Ken Robinson challenges the way we're educating our children. He champions a radical rethink of our school systems, to cultivate creativity and acknowledge multiple types of intelligence".

Related videos:

Enjoy the video!.

# Piecewise function plotter

I've been working lately on a front-end application to draw and generate the piecewise-defined functions that are mainly used for the input fuzzy sets. This application is developed with Delphi and for generating the outputs it uses the GNUplot and the LateX equation editor. The application is called Thundax Piecewise v1.1 and you can download it from here. This win32 installation package contains the required files to work with the GNUplot. This software is for academical purposes and with it you can define the piecewise-defined functions without wasting your time trying to draw the graphs and the equations.

Using the application:
If you want to get the equations from the previous image, you only need to add the points (x,y) (defined as 4 points per graph), add the equation description, the range and the number of samples:
The description of the parameters:
• Points per graph: default value = 4. Number of points that are used to define the function:
• Range-x: Default value [0:30]. Range to be displayed at x-axis.

• Range-y: Default value [-0.1:1.1]. Range to be displayed at y-axis.
• Samples: default value = 1. Number of samples for the x-axis. In a range from 1 to 10 with a sample of 1 it will show all the numbers.

Once everything is done, you just need to let the application generate the graph output automatically using GNUPlot (If the function is not plotted, check the script and execute it into the GNUplot command prompt):
And then copy-and paste the output script to Latex editor and get the piecewise function for each one:
The only thing the applications does, is to parse the input data and transform it as scripts for the GNUplot and Latex. The conversion is pretty simple and the scripts examples are like these:
GNUPlot Script example:
cold(x)=(x<=40? 0: cold2(x))
cold2(x)=(x<=40 & x > 40? 1: cold3(x))
cold3(x)=(x<=50 & x > 40? -0.1*x + 5: cold4(x))
cold4(x)=(x<=50 & x > 50? 1: cold5(x))
cold5(x)=(x>50? 0:0)
cool(x)=(x<=40? 0: cool2(x))
cool2(x)=(x<=55 & x > 40? 0.066667*x  -2.666667: cool3(x))
cool3(x)=(x<=55 & x > 55? 1: cool4(x))
cool4(x)=(x<=65 & x > 55? -0.1*x + 6.5: cool5(x))
cool5(x)=(x>65? 0:0)
justright(x)=(x<=60? 0: justright2(x))
justright2(x)=(x<=65 & x > 60? 0.2*x  -12: justright3(x))
justright3(x)=(x<=65 & x > 65? 1: justright4(x))
justright4(x)=(x<=70 & x > 65? -0.2*x + 14: justright5(x))
justright5(x)=(x>70? 0:0)
warm(x)=(x<=65? 0: warm2(x))
warm2(x)=(x<=75 & x > 65? 0.1*x  -6.5: warm3(x))
warm3(x)=(x<=75 & x > 75? 1: warm4(x))
warm4(x)=(x<=85 & x > 75? -0.1*x + 8.5: warm5(x))
warm5(x)=(x>85? 0:0)
hot(x)=(x<=80? 0: hot2(x))
hot2(x)=(x<=90 & x > 80? 0.1*x  -8: hot3(x))
hot3(x)=(x<=90 & x > 90? 1: hot4(x))
hot4(x)=(x<=90 & x > 90? 1: hot5(x))
hot5(x)=(x>90? 0:0)
set yrange[-0.1:1.1]
set xtics 0, 15
set grid
set samples 1001
bind Close "exit gnuplot"
plot [40:90] cold(x) ,cool(x) ,justright(x) ,warm(x) ,hot(x)


Notice that we use the function bind Close "exit gnuplot" to bind the exit of the application once the user has closed the plotted graph. (And I think this function is available since version 4.4).
Latex Script example:
cold(x)=\begin{Bmatrix}{0}&\mbox{if}& x\leq40\\{1}&\mbox{if}& 40< x \leq40\\{-0.1*x + 5}&\mbox{if}& 40< x \leq50\\{1}&\mbox{if}& 50< x \leq50\\{0}&\mbox{if}& x > 50\end{matrix}\\
cool(x)=\begin{Bmatrix}{0}&\mbox{if}& x\leq40\\{0.066667*x  -2.666667}&\mbox{if}& 40< x \leq55\\{1}&\mbox{if}& 55< x \leq55\\{-0.1*x + 6.5}&\mbox{if}& 55< x \leq65\\{0}&\mbox{if}& x > 65\end{matrix}\\
justright(x)=\begin{Bmatrix}{0}&\mbox{if}& x\leq60\\{0.2*x  -12}&\mbox{if}& 60< x \leq65\\{1}&\mbox{if}& 65< x \leq65\\{-0.2*x + 14}&\mbox{if}& 65< x \leq70\\{0}&\mbox{if}& x > 70\end{matrix}\\
warm(x)=\begin{Bmatrix}{0}&\mbox{if}& x\leq65\\{0.1*x  -6.5}&\mbox{if}& 65< x \leq75\\{1}&\mbox{if}& 75< x \leq75\\{-0.1*x + 8.5}&\mbox{if}& 75< x \leq85\\{0}&\mbox{if}& x > 85\end{matrix}\\
hot(x)=\begin{Bmatrix}{0}&\mbox{if}& x\leq80\\{0.1*x  -8}&\mbox{if}& 80< x \leq90\\{1}&\mbox{if}& 90< x \leq90\\{1}&\mbox{if}& 90< x \leq90\\{0}&\mbox{if}& x > 90\end{matrix}\\


I'm still working on this project and for the next milestone I'll try to add the Weighted average method to calc the area of the graph and the ability to save the data of the project.

# Building my own Delphi Physics Engine part II

Going on with my DPE (Delphi Physics Engine) I've improved my old version (Building my own Delphi Physics Engine Part I) of the Jansen Mechanism by creating the rest of the legs displaced 120º each one. I've been fixing the damping level of the framework just to be sure that the movements are as realistic as possible. In this version, the movement is quite realistic and we can trace the movement of the leg by plotting the kinetic analysis:

A physics engine is computer software that provides an approximate simulation of certain simple physical systems, such as rigid body dynamics (including collision detection), soft body dynamics, and fluid dynamics, of use in the domains of computer graphics, video games and film. Their main uses are in video games (typically as middleware), in which case the simulations are in real-time. The term is sometimes used more generally to describe any software system for simulating physical phenomena, such as high-performance scientific simulation. Wikipedia.

Here you can see the CGI result with the hanging version of the Jansen mechanism with one leg and with three legs:

And the final version with the development of the Jansen machine. In this version (Thundax Test Forces v2.exe) if you press 'p' the machine will start walking and if you want to change direction, you only need to press the 'z'.

What's next?. Now I'll try to reproduce different physics systems and show how it goes. The Easy Java Simulations tool, offers a wide range of examples that I would like to try.
Enjoy the learning!.

# Building my own Delphi Physics Engine part I

These days I've been working on my own Delphi Physics Engine based on the very well known APE (ActionScript Physics Engine) with some improvements that will help developers to build models very fast. In this beta version I've done the following improvements:
• Enhance user performance.
• Drastic reduction of Memory leaks.
• Improve the interoperability between objects.
• Improve maths algorithms to collision detection.
• Use the VLO GDI Render to perform the drawing of the shapes.
In this first insight into the Engine, I'm going to show you a model of the Jansen mechanism, a kinetic sculpture that can move with the help of several pairs of legs.

I've built my own model taking advantage of the physic engine and imagination!.
Here you can see my own model:
The movement is still not very well performed, but it's due to the measures of the different parts of the sculpture. As for the calculation points, I've used the next template:
You can download the demo project from here (Thundax Test Forces). To play with the application, you only need to press 'z' to start the kinetic sculpture, and as for the objects below the sculpture, press 'd' and you'll force a collision between two objects.

The next days I'll be improving the model (you can see the kinetic analysis that is plotted below the sculpture) and adding the extra foot to perform a fully movement.

Enjoy the learning!.