Sunday, 15 December 2013

Final thoughts on "Nanotechnology: The Basics"

Yesterday I took the final exam of "Nanotechnology: The Basics" online course.
The course is held by professor Vicki Colvin and professor Daniel Mittleman from the RICE university on Coursera.


I didn't have much time, so I attended just the basic lessons. I found the topics of the course really interesting.

The course lasted four weeks. Here below the list of the weekly topics:
  1. Introduction to nanotechnology
  2. Nanoelectronics
  3. Nanomagnetics
  4. Nanophotonics

The most interesting thing I have learned during the course is how the material properties completely changes when they are really small.

Another fascinating effect we seen is the quantum confinement effect. Take a look at at the Quantum dot page on wikipedia!



Tuesday, 10 December 2013

Color fading with arduino

Yesterday evening I encountered this question on StackOverflow website.


In my opinion, the low quality of the original code is the main problem here. I suggested Tristan to use the Arduino Tinker Library and I wrote an example just for him.

#include <Vect3d.h>
#include <SerialLog.h>

Tinker::Vect3d<float> red(255,0,0);
Tinker::Vect3d<float> green(0,255,0);
Tinker::SerialLog serialLog;

void setup(){
  Serial.begin(9600);
  serialLog.display("Fade color example");  
  serialLog.endline();
}

void loop(){
  //fade factor computation
  const uint32_t t   = millis()%10000;
  const float cosArg = t/10000.*3.1415*2;
  const float fade   = abs(cos(cosArg));

  //Here's the color computation... as you can see is very easy to do!! :)
  Tinker::Vect3d<uint8_t> finalColor(red*fade + green*(1-fade));

  //We print the vect3d on the arduino serial port
  Tinker::LOG::displayVect3d(finalColor,&serialLog);
  serialLog.endline();
  delay(500);
}
This example will print the following output on the serial port:
Fade color example
V[255;0;0]
V[242;12;0]
V[206;48;0]
V[149;105;0]
V[78;176;0]
V[0;254;0]
V[79;175;0]
V[150;104;0]
V[206;48;0]
V[242;12;0]
V[254;0;0]
V[242;12;0]
V[205;49;0]
V[148;106;0]
V[77;177;0]
V[1;253;0]
V[80;174;0]
V[151;103;0]

If you want to fade multiple colors in one of your sketch you can simply use this code! :)

PS: Today I found this question on stack overflow: http://stackoverflow.com/questions/20482642/how-to-fade-between-two-vectors-by-value.

I'm really proud that someone is using the Arduino Tinker Library :)

Tuesday, 19 November 2013

Seam Carving

As I promised to you, here is the pics of some images elaborated with Seam Carving algortihm.

For each image I'll provide its reduced version and the energy image during last iteration of the algorithm.

San Marino







Iseo Lake




Marone

A nice village on the Iseo Lake



hohenschwangau castle





Wednesday, 13 November 2013

Algorithms - Part II

I'm attending the online course "Algorithms - Part II" on Coursera which is held by Kevin Wayne and Robert Sedgewick from Princeton University. 


I already have a good knowledge of most of the Algorithms which are dealt in this course. Despite that, the course is very interesting and funny because of the weekly assignments: they consist of the application of the algorithms presented in lectures applied to real and sharp problems. 

In the second week the Ariel Shamir's Seam Carving algorithm is proposed as an application of a shotest path algorithm.


According to Coursera Honor Code I will not post any code of my algorithms, but I will show you some results instead. In fact I find this algorithm very interesting and smart! :)

PS: I already read about Ariel Shamir and expecially one of his amazing work. Have a look at this!



Saturday, 26 October 2013

Arduino LCD Logger

The post "Arduino Tinker Library"  introduces the technique by which an LCD logger with no effort can be created with a different concrete implementation of the AbstractLog class.

My set up consist of an LCD display which is contained in the Arduino Starter Kit. You can easily program it with the LiquidCrystal Library.

Connecting LCD Display

The hardware set up is really simple


And here's the result



LiquidCrystalLog

Now we are ready to use the LCD display as a logger. In the LiquidCrystalLog.h file you can find a concrete implementation of the class AbstractLog.
You can also find a new example, called vect3d_LiquidCrystalLog. As you can see, the original source code has not beeing modified, except for the log variable: it's now a LiquidCrystalLog type variable.
Here's a video of the new logger



You can write every type of logger, SD Card logger, Bluethoot logger, RF logger and so on.

Friday, 25 October 2013

Arduino Tinker Library



I've just started working on my Arduino C++ library. You can find it on GitHub: feel free to download it and use it for your projects.

I'll try to build a modern C++ library with advanced techniques and many examples. I'll suggest you a couple of books by which I am inspired:

Log Interface

AbstractLog.h contains an abstract class that you can use in your algorithm class to log every operation.
In SerialLog.h you will find a concrete implementation of AbstractLog which write your algorithm log on the Arduino serial port
In the future I'll show you how to log on a LCD display instead!

Vect3d

Vect3d.h contains a class that represent a 3-dimensional vector. You can use it to do some calculation on a generic 3D space (euclidean space, RGB color space ...)


If you install the Arduino Tinker Library you will find into Arduino IDE an example on how to use Vect3d in your code (File -> Examples -> ArduinoTinkerLibrary -> vect3d)

If you open the Arduino Serial Monitor (Tools -> Serial Monitor or Ctrl+Shift+M) you should see the following output

Vect3d Example
Constructor
V[0;0;0]
V[128;128;128]
V[64;64;64]
V[0.00;0.00;0.00]
V[1.00;1.00;1.00]
V[1.00;1.00;1.00]
V[123.00;456.00;789.00]
Copy
V[64.00;64.00;64.00]
V[1.00;1.00;1.00]
Test
f1 == b2
f3 != b2
Sum
V[124.00;457.00;790.00]
V[124.00;458.00;792.00]
V[129;129;129]
V[130;131;132]
Sub
V[122.00;455.00;788.00]
V[122.00;454.00;786.00]
V[129;130;131]
V[127;127;127]
Scalar Mul
V[307.50;1140.00;1972.50]
V[3.00;3.00;3.00]
Scalar Div
V[49.20;182.40;315.60]
V[1.00;1.00;1.00]
External functions
NormL1(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 189.00
NormL2(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 13.86
dot(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 192.00
cross(V[123.00;456.00;789.00] - V[64.00;64.00;64.00]): V[-21312.00;42624.00;-21312.00]


Tuesday, 22 October 2013

KD-Tree art

Lately I've worked on a KD-Tree implementation.
I've programmed a 2D log system using OpenCV which allows the visualization of the data structures.

After some test, a nice idea came up to my mind! Why shouldn't I post my data structures as a piece of mathematical art to launch my blog?! ;)

Here is the result: some points which lay on two circle and a sinc, inserted into a KD-Tree.


PS: As you can see the point x=0 of the sinc is not in the correct position! I have left it, so that it would remaind me that a PC doesn't know the concept of limit