21 May 2015

Nanotechnology: An Introduction


Nanotechnology! Nowadays, almost any student claims to have an interest in becoming a scientist, working in laboratories, playing with atoms, fiddling with molecules, and on and on. Well, let me tell you one thing. If you fall in that 'almost any kid' category, then you might just end up finding nanotechnology exciting.

Nowadays in nanotechnology, things that were only “dreamt of”, are turning into a reality. But before we delve into the science of nanotechnology, let me point to you some exciting ways in which nanotechnology is being used today.

Have you ever “dreamt of” an invisibility cloak? Well if you have, then I suggest you stop dreaming because now invisibility cloaks have become a reality.

One other recent cutting edge invention is the “Ultra Ever Dry” product. And what this does, is that it does not allow any liquid irrespective of its viscosity to stain a substance on which the product has been sprayed on. The “Ultra Ever Dry” coating, creates a thin barrier of air at the nano scale, which prevents the coated substance from getting wet or dirty. And to see this mind-boggling product in action, you can take a look at:



Apart from this, there is also some interesting work going on in the field of medicine involving nanotechnology, where medical researchers are on the verge of creating an almost harmless cancer therapy which could possibly become a substitute to the standard chemotherapy.

There has been a quantum leap in the development of nanotechnology in the last five years. And from here, things only get better.

So let's get started with nanotechnology.

What is nanotechnology?

At a very high level, I would take nanotechnology as the science, engineering and technology practiced at the atomic or molecular level.

But going slightly deeper, it is a branch of science, which involves the manipulation of at least one dimension of a substance within the nano scale range of 1 to 100 nanometers (1 nanometer = 10-9 meters).

What is unique about nanotechnology?

There are many things that are unique to nanotechnology, though I feel the truly convincing answer to this, lies in the unusual behavioral-changes of substances at the nano scale.

What I mean by this is that substances show rather abnormal properties at the nano scale, which violate the norms of the Physics that we know so well as Classical Physics. We will understand and discuss this in greater detail a bit later.

Interesting concepts in nanotechnology

With this much of a background, I think we all are quite ready to take a look at some of the interesting concepts of nanotechnology!

Two main concepts are:
• Simple to Complex
• Larger to Smaller

Simple to Complex--

One of the most mind blowing concepts in which extensive research is being carried out is the ‘Simple to Complex’ also known as the ‘bottom-up approach’ concept. This concept involves molecular self assembly. In other words, scientists are trying to make molecules automatically arrange themselves into a desirable system.

Some of the fields where this is trying to be developed, is in the field of synthetic chemistry where scientists are trying to achieve self assembly of molecules into substances such as polymers, micro-computing where scientists are almost at the brink of having self assembled microcomputers and biology where substances like enzymes have already been self created!

Two main advantages of developing this Simple to Complex concept are:
• Production will become faster and more efficient.
• Both the purchasers as well as manufacturers will incur less cost.

Larger to Smaller--

As we had discussed earlier, the physical properties of substances begin to be different as the size of these substances start to enter the nano scale. These include differences in mechanical, thermal, electronic and catalytic properties of the substances. These changes, which occur in substances as their sizes are brought down from the macroscopic to the nano scale, constitute the major part of the ‘Larger to Smaller’ concept.

Some examples to give you a flavour of these ‘abnormal phenomena’, which occur among substances at the nano scale are:
• Plastic at the nano scale conducts electricity,
• Gold particles begin to appear red and purple,
• Particles of certain substances turn spontaneously from solid to liquid,
• Copper turns transparent,
• Platinum and Gold become catalysts, and so much more.

Why do substances begin to show these aberrant properties?

This can be explained by the drastic increase in the surface area to volume ratio, which exists at the nano scale. For example let us take a cube of side 8 units, which we will reduce thrice consecutively to an edge length of 6, 4 and then 2 units, and then observe the surface area to volume ratio. Then—

Edge length Surface Area Volume S.A. to V ratio
8 units 384 units2 512 units3 3/4 = 0.75 units-1
6 units 216 units2 216 units3 3/3 = 1 units-1
4 units 96 units2 64 units3 3/2 = 1.5 units-1
2 units 24 units2 8 units3 3/1 = 3 units-1

Now we can clearly see, that by reducing the dimensions of the cube, the surface area to volume ratio is increasing. This is also the case with any other three dimensional object. May it be a sphere, cylinder or cone. But, the more relevant question is how does the surface area to volume ratio cause an alteration in the behaviour of particles at the nano scale?

To understand this, let us continue with the example of a cube. If we take two identical sugar cubes of side = 10 units, and divide one of them into a 1000 equal blocks of 1 unit3 each, and leave the other one untouched, then the volume of the uncut and cut sugar cubes will remain the same. But, the surface area of the cut cube will be clearly larger than the surface area of the uncut cube. Now, if we were to dissolve both the cut and uncut sugar cubes, then the cut cubes will definitely dissolve quicker, as they share a greater contact area with the water as compared to the uncut cube.

It is this same kind of change that takes place in nanoparticles too, but the changes are much more drastic as the surface area to volume ratio in nanoparticles is much larger. Just for example’s sake, let us take a cube of side = 10-9metres or 1 nanometer. Then—

Surface Area = (10-9)2 x 6
=> (6 x 10-18)nm2

Volume = (10-9)3
=> 10-27nm3

Therefore the surface area to volume ratio = 6 x (10(-18)/10(-27))
=> 6 x 10(-18+27)
=> 6 x 109
=> 6,000,000,000 or Six billion nm-1!

And it is this huge surface to volume ratio, which causes abnormal properties in nanoparticles.

All of this is just the beginning of our understanding of the fast evolving field of nanotechnology. Some of the references I have provided below can help you understand more about this exciting field. If you have found anything interesting in the space and would like to share it, post a comment!

References:
1. http://www.nano.gov/nanotech-101/what/definition
2. http://science.howstuffworks.com/nanotechnology.htm
3. http://www.livescience.com/33816-quantum-mechanics- explanation.html
4. http://www.gizmag.com/invisibility-cloak-hides-macroscopic-objects/37542/
5. http://www.nano.gov/nanotech-101/special

12 May 2015

Coding Contests: Everything you need to know

What in the world is a Coding Contest??

It's a contest where you write code.
Okay, it's a contest where you're given a question, then you type your code and send it to the organizers. Then, your program is tested with different input to make sure you got it right.

What do you mean by "tested"?

The contest organizers have their own programs called graders, which run your program multiple times with different inputs. If the output of your program matches the correct answer in all cases, your program is correct!

But I thought a human tests my program. I even gave helpful output hints for the user like "Enter the number here: "!

Nope, humans usually don't test the code. In fact, if you display those "helpful output hints for the user", your program is wrong. Your program's output should match the answer exactly.


How do I know what my output should look like?

Read the question again. Usually, everything you need is specified in the question.
For example, look at SRS 008.

SRS 008

The questions specifies both how the input will be typed, and how the output should look.
If the answer is 2 and 4, like in the Sample Output, display only that. If there's anything else in the output, that answer is wrong.

Your program is being graded by a computer. You don't need to be nice to them! If you still want to include extra comments in your output, be prepared for a "WRONG ANSWER" comment from the grader.

Fine, I got the idea. But how do I take the input? Should I accept the input before anything else in the program is done?

No, you don't have to. The graders separate your input and output into two separate "streams". All the output is collected in one 'file', and the input is from another 'file'.
You can collect the necessary input from anywhere in the program. But you need to accept it in the right order, exactly as it is specified in the question.

Think of it this way. After you send me your code for SRS 008, I first compile it and get an executable. I have some input in input.txt, which I feed into your program. 

input.txt looks like this:
5

I specify that whatever your program displays is saved into a file called output.txt. Then I run your program.

I compare your output from output.txt to the answer output in answer.txt. If they match exactly, then your program worked properly.

You don't actually need to worry about any of this. Contest graders automatically take this into consideration. You can continue to use cin, cout, print, display and any other commands you usually use.

Cool. Can I get started now?

Well, you also need to know about test cases, constraints and time-limits.

[*Sigh*] What are test cases?

The graders test your program with different input. This is to make sure that your program works for every single type of input.
For example, the grader for SRS 008 would test your code with different input numbers, just to make sure that you didn't cheat and make the program display the same output every time. Graders also use multiple input to check if you took care of the constraints.

This is annoying. What are constraints?

The range of the input. For example:

Sample Question
When you submit your code, the grader will test your program for different values of A and B. You know the ranges of the two numbers. You shouldn't have made B an "unsigned int" because it needs to hold negative numbers too. Also, you need to make sure that you use a large enough data-type to accommodate large values of B.

In some problems, where the constraints are extremely large, the contest questions might try to make your life more difficult by adding time-limits...

Come on! What are time-limits?

Calm down! Time-limits just tell you how long your program has to give the right answer. Don't bother too much about this to begin with.
If you ever get a grader error saying "TIME LIMIT EXCEEDED", then your algorithm (the way you solved the problem) was too slow. You'll have to find a way to reduce the number of loops, and optimize your algorithm.

But for now, don't worry too much about it.

Okay, got it. Are we done now?

Yes, we're done.

Finally! Now I'm going to try out SRS 008.

Great! Message me if you have any questions.


1 May 2015

Algorithims:The Basics

Hello people of the internet !! Today You're going to learn a little (if not anything) about algorithms.
So let's start from the basics.....

What exactly is an Algorithm ?

Well Informally it is a computational procedure that takes in a few inputs and throws out another set of outputs. It's basically a bunch of steps that a computer does, which takes in some input data and transforms it into output data.

Algorithms can also be considered a tool for solving a well-specified computational problem. The statement of the problem specifies in general terms the desired Input/Output (I/O) relationship. An algorithm defines a certain procedure for achieving the I/O relationship expected. 

For example let's consider the age old Sorting Problem.
Basically the input is a bunch of numbers given in a random order, and the job of the Algorithm is to SORT these numbers into either ascending or descending order.

In this case what the problem is giving us as inputs is just a random bunch of numbers and asks the Algorithm to weave it's magic and spew these numbers out in a proper ascending or descending order.
This of course is  on the simpler side of this topic but there are many famous implementations of Algorithms.

But why are Algorithms used ?

When we are developing applications,What technologies do we normally prioritize  over others ?
  •  Devs  prioritize GUIs and focus on it's components 
  •  Manufacturers  focus on better fabrication technologies 
  • Some programmers  might even focus on implementing Object-Oriented Systems in their Software life cycle
These technologies are really important for the successful development of an application.

So why implement Algorithms in the first place?

  • The main reason algorithms are prioritized is because they themselves are (explicitly or not), required by applications for certain features. For example a travel web based service will require loads of hardware, refined GUIs and so on....
  • But they would also require certain features such as finding the shortest routes, sorting based on user reviews and other criteria. These are best implemented by using standard algorithms (or something better if you can think of something.)
Not only on an application level are they important, Algorithms are also used to design the hardware required, the working of the GUI itself uses algorithms. In fact even the processing of the code itself by the compiler, interpreter or the assembler requires algorithms.

With the ever increasing capacities of computers, we now have to solve larger problems than ever before, It helps to get the job done quicker and more efficiently and algorithms work much better than just plain brute force methods



let's go over Sort algorithms

Again these algorithms take input data and returns them  in a numerically ascending order or Alphabetical order. For simplicity's sake we will look over numerical examples only

There are many sorting algorithms.Each algorithm is fundamentally different from each other by the way they work. Normally an algorithm is chosen depending on the given data as some algorithms are better for a certain organization of data than others.(this will be explained later)

Three commonly used sorting algorithms are

1)Merge Sort

2)Quick Sort

3)Bubble Sort


Merge Sort:

Merge-sort-example-300px.gif 

Conceptually, a merge sort works as follows:

  1. Divide the unsorted list into n sublists, each containing 1 element (a list of 1 element is considered sorted).
  2. Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.

Quick Sort:

http://upload.wikimedia.org/wikipedia/commons/9/9c/Quicksort-example.gif 

Conceptually, a Quick sort works as follows:

  1. Pick an element, called a pivot, from the array.
  2. Reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
  3. Recursively apply the above steps to the sub-array of elements with smaller values and separately to the sub-array of elements with greater values.

Bubble Sort:


http://upload.wikimedia.org/wikipedia/commons/0/06/Bubble-sort.gif

Conceptually, a bubble sort works as follows:


  1.  Take the first 2 elements and sort them
  2. Then take the 2nd and 3rd elements and sort them
  3. Repeat these steps until the end of the elements are reached
  4. Repeat the following steps until the elements are fully sorted




So these algorithms are basically doing the same thing but in different ways. But one thing that differentiates between algorithms is the efficiency of the algorithm

So how do we determine the efficiency of an algorithm ? This is called the analysis of run time complexity (the words are just fancy, the concept is simple)

We normally consider 3 main representations of Time taken by the Algorithm to Sort in this case

1)Big Ω(Omega) notation(in terms of computer science) -This shows the least amount of time taken by an algorithm to complete. For example the Big  Ω notation of quick sort will be "cn log n" where "n" is the number of elements . This means that the least amount of steps taken by quick sort (most of the the time an already sorted bunch of elements) would be product of the number of elements and the log (base 2) of it and then this is multiplied time the time taken to perform each step 'c'.

2)Big Θ(Theta) notation - This shows the Maximum time taken by an algorithm (in the case of Sorting ones this is normally when the elements are in reverse order). Normally this is the best notation to design algorithms because this also shows that the algorithm is always gonna work in the given time frame and we can more or less decide how fast the algorithm is based on this. For example in quick sort the Big Θ is " cn2"  meaning that the time taken will be the time taken for each step times the number of elements squared.

3)Big O(Oh...) notation-This shows the Average time taken by an algorithm. This is the most common notation used and is considered the standard of viewing algorithms as it gives the viewer a basic idea of how the algorithm works on a normal case. This can also show the the best and worst case but this is beyond the scope of this article. Again in the case of quick sort the big O is "cn log n" (it's called quick sort for a reason. It is considered the most efficient because the average case is the best case).

As I have mentioned earlier  quick sort is the most efficient algorithm for most cases. The reason there are none quicker is because these algorithms are considered to be "stable". The whole process of checking whether an algorithm is stable is a tedious one. But It's a simple mechanic to explain.




So let's just say we are sorting a bunch of cards. Normally if we are taking just the numbers in mind, both the given arrangements are considered to be sorted but if we are also considering the suits also. We must consider that in this case the 5 of hearts must come before the 5 of spades and thus this case of sorting will be considered a 'stable' sort. This sort of sorting takes relatively longer time but gives this desired result and retains other properties also.







The above algorithms were only explained conceptually. Now I want to take it one step further and explain how algorithms are normally expressed by computer scientists. Pseudocode is a high level informal description of the algorithm following basic programming language conventions.


Here's the pseudocode for insertion sort:

 for i = 1 to length(A) - 1
    x = A[i]
    j = i
    while j > 0 and A[j-1] > x
        A[j] = A[j-1]
        j = j - 1
    end while
    A[j] = x
 end for 

This time instead of conceptually explaining The Sort,I will go through the pseudocode line by line 

for i = 1 to length(A) - 1
 
This statement states the starting of a loop which repeats the below statements as many times as the number of elements in the array (the below steps are done to all the elements in the array)

  x = A[i]
   j = i

This statement gives a variable X the value of the the ith term (the current index) and another variable j the value of i for the conditional loop later

    while j > 0 and A[j-1] > x
        A[j] = A[j-1]
        j = j - 1
    end while
    A[j] = x
 end for

Here's where most of the fun happens. so here basically it takes an element and checks whether it's bigger that it's previous element  and the element before that and so on until the first element. And in each iteration switches it the position of the present element with the previous element (if the value is greater).

And then again the whole process repeats with the next number on the array as the index value 


This marks the end of the article and hopefully you have leaned a little bit about algorithms.If anybody has any doubts or want to know more can surely IM me on my G+ account given below


References:
1)http://en.wikipedia.org/wiki/Sorting_algorithm
2)http://www.sorting-algorithms.com/
3)https://www.youtube.com/watch?v=SJwEwA5gOkM
4)Introduction to Algorithms-3rd Edition    



Attributions

  • "Insertion-sort-example-300px" by Swfung8 - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Insertion-sort-example-300px.gif#/media/File:Insertion-sort-example-300px.gif 
  • "Sorting stability playing cards" by User:Dcoetzee, User:WDGraham - Own work, based on File:Cards-2-Heart.svg, File:Cards-7-Spade.svg, File:Cards-5-Spade.svg, File:Cards-5-Heart.svg. Licensed under CC0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Sorting_stability_playing_cards.svg#/media/File:Sorting_stability_playing_cards.svg
  • "Bubble-sort-example-300px" by Swfung8 - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Bubble-sort-example-300px.gif#/media/File:Bubble-sort-example-300px.gif
  • "Quick-sort-example-300px" by Swfung8 - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Bubble-sort-example-300px.gif#/media/File:Bubble-sort-example-300px.gif
  • "Merge-sort-example-300px" by Swfung8 - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Bubble-sort-example-300px.gif#/media/File:Bubble-sort-example-300px.gif




15 Apr 2015

Programming for Physics Simulations – How is it Done ?


A lot of people even those who have experience in programming have very wrong ideas about how programs work. Moreover the common notion among the general public is that software development only requires knowledge and experience in programming, however its actually quite the contrary. Software development can have very high level of specialization unlike many other fields including medical, for instance one experienced cardiologist can do the same another cardiologist can. How two highly experienced web developers may not be able to do what the other can. What people don’t understand is programming on its own is just a tool and nearly worthless on its own. Its like maths, whats the use of maths? No use. But apply math in physics, chem, astronomy …… then suddenly it becomes very useful. That’s how programming is too , People often specialize in different fields like maths, physics and  architecture. Like for example if a developer needs to develop a CAD program , he or she would need to have a good knowledge of architecture to effectively develop a suitable product, therefore they would need to specialize in architecture too.

So here in this post I intend to instill some ideas into the minds of new developers. To do this I will explain how to simulate a basic physics concept used in cut the rope from scratch through C++ code. I will keep it as simple as possible. However one needs basic knowledge of trigonometry to follow. Please note that all the programs embedded on this post is either HTML5 or flash, however I will be discussing from C++ point of view.



This is what we are gonna make using C++, Its pretty basic right ? Yeah it is. But even this is not very easy as people might feel, Many people will be thinking oh whats the big deal, you pull it, it follows , whats so hard? Indeed you pull it, it follows but nothing on a computer ever happens on its own, Someone should take care of the physics through code.

Ok so how do I think the right way ?

The right way to think is not to think in terms of code but in terms of logic, Imagine this as a physics situation, there are 2 balls, separated by a distance and an elastic rope joined between them,  larger the distance, faster the ball moves. However even if the rope becomes slack, due to inertia the ball continues to be in motion. So inertia has to be also considered. Gravity needs to be considered to make the thing realistic. Finally the fact that we are working in a 2D space has to be kept in mind.  
On further analysis, You might feel that there is a need for friction / resistance between the balls, or they would never stop moving

Physics solution :

This is the solution to the problem in physics point of view

Here 'T' is the tension force in the elastic rope. 'x' is the extension (elongation) of  the rope, 'A' is the rope’s cross sectional area, 'L' is the natural length of the rope while 'Y' is the Young's modulus.  This is the formula derived from Hooke's law.

We need to resolve these forces into vectors since we are working in 2D space. Then we need to add the gravitational force on the vertical component so it will be T sinθ + mg.

From here its easy, all one needs to do is calculate acceleration in both components using 'F = ma', then find change in velocity using 'v = u + at', And from velocity you can find new position of the balls. But you might have already realized both acceleration and velocities keep on changing , that means to correctly calculate the final velocity, you will need to use integral calculus which is beyond the scope of this post.

However this analysis is correct and can be implemented in programming

Programming Implementation :

Remember I said we need integration to calculate the velocities and position at a given time? But in programming we have a work around i.e  Running several iterations to approximately calculate the velocity and position . This means we split a time interval, say 1 sec into many smaller time intervals Say 0.1 s, Since 0.1s is a very small interval, we can assume the acceleration and velocity doesn't change in that interval . Accuracy can be increased to any desired extent by decreasing the small time interval.

Ok now we are finally ready to get started
Main variables

float x1=200,y1=200,x2=200,y2=200, s=100;
float vx2=0,vy2=0;

(x1,y1) are the initial position of the first ball , the ball which is controlled by the mouse. (x2,y2) is the position of the ball which is connected to the first ball. 'vx2' and 'vy2' are the components of velocity of the second ball in the X and Y directions respectively. 's' is the natural length of the rope.

The following bits of code has to be put in a loop that runs the iterations

1)  Getting the coordinates of the mouse and setting that as the coordinates of the first ball
 
x1=mousex(); 
y1=mousey();

2) Finding distance and angle between the 2 centres.


float d1=distance(x1,y1,x2,y2);
float ang1=angle(x1,y1,x2,y2);

Here distance() is a function which calculates distance between 2 points at an instant of time and angle() is a function which calculates angle between 2 points i.e. angle made by the line joining the 2 points and the horizontal.

3) Checking if the rope is stretched

We calculate distance between the 2 balls to know if the rope is stretched and angle to resolve force into components

//If the rope is stretched
if(d1-s>0) {   //Resolving tension into vectors
    vy2+=(d1-s)*sin(ang1)*.007;
    vx2+=(d1-s)*cos(ang1)*.007;
}

/*  here all the constants clubbed together as 0.007 , you can change it
We are adding the force directly to velocities by assuming balls to be of unit
mass and time interval to also be unit time
*/

4) Adding gravitational force

 vy2+=.23;
 //Gravitational force added on y coordinate
// 0.23 is an experimentally calculated value ( you can experiment too ! )

5) Moving the body and friction
We move the body as follows as we have assumed time interval to be unit time interval

y2+=vy2;
 x2+=vx2;
//Friction reduces velocity by 1%
vy2*=.99;
vx2*=.99;
      
6) Summing up

//draws 2 circles on the screen
circle(x1,y1,25);
circle(x2,y2,25);
//draws a line between them
line(x1,y1,x2,y2);

And we are done !!
Several improvements can be made like having parameters such as length, area, masses of spheres etc. Further more this concept can be expanded on more than 2 balls


Full code :

#include<graphics.h>

#include<math.h>

//Distance is a function which calculates Distance between 2 points

float distance(int x1,int y1,int x2,int y2)

{

    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

}

//Angle is a function which calculates the angle between 2 points

// ( tan inverse of the Slope of the line joining the 2 points )

float angle(int x1 , int y1, int x2 , int y2)

{

    float ang;

    //In case the 2 points are perpendicular

    if(x1-x2==0)

    {

        ang=-1.57;

    }

    else

    {

        ang = atan((float)(y1 - y2) / (x1 - x2));

    }

    //Quadtrants

    if (ang < 0 && y1> y2)

    {

        ang += 3.14;

    }

    else if (ang > 0 && x1 < x2)

    {

        ang += 3.14;

    }

    return ang;

}

int main()

{

    //declaration of variables

    float x1=200,y1=200,x2=200,y2=200, s=100;

    float vx2=0,vy2=0;

    //Creating a new window

    initwindow (550, 400,"Windows BGI",50,50, false,true);

    while(1)

    {

        //Getting the coordinates of the mouse

        x1=mousex();

        y1=mousey();

        //Finding distance and angle between 2 points

        float d1=distance(x1,y1,x2,y2);

        float ang1=angle(x1,y1,x2,y2);

        //If the rope is stretched

        if(d1-s>0)

        {

            //Resolving tension into vectors

            vy2+=(d1-s)*sin(ang1)*.007;

            vx2+=(d1-s)*cos(ang1)*.007;

        }

        //Gravitational force on y coordinate

        vy2+=.23;

        //Now moving the body

        y2+=vy2;

        x2+=vx2;

        //Friction reduces velocity by 1%

        vy2*=.99;

        vx2*=.99;

        //draws 2 circles on the screen

        circle(x1,y1,25);

        circle(x2,y2,25);

        //draws a line between them

        line (x1,y1,x2,y2);

        //waits for 40 milliseconds

        delay(40);

        //something to do with memory

        swapbuffers();

        //clear the screen so that a new frame can be redrawn

        cleardevice();

    }

    return 0;

}

9 Apr 2015

Why I moved to an iPhone from Android


My first smartphone was an android phone. The first phone I got which wasn’t a hand-me-down was an android phone. The first phone I saved up for and bought was an android phone. Android introduced me to the world of tech, to the wondrous world of rooting, ROMming and the incredible XDA forums. Being known as someone with a major predilection for android, I surprised most of my friends when I told them that I had, a few weeks ago, switched to the iPhone 6. And now, after these few weeks of use, I do admit something that a year ago I wouldn't have said even if my life depended on it: The iPhone is better than most, if not all, android phones.

Back in March 2013, when I got my first respectable android phone, the Nexus 4, I despised the iPhone. I saw the iPhone 5 as the epitome of business exploitation. Exorbitant prices, specifications that were mostly along the lines of current android flagships, if not worse and a cagey OS with no customizability and ridiculous restrictions. And iTunes was (and still is, to be frank) a joke. Granted, its DAC put android phones to shame and in my eyes, it looked better than any other smartphone. That didn't make up for the other shortfalls though. I remember vehemently arguing against the iPhone 5S when it came out, convincing my dad to hang on to his failing Galaxy S2. My mom merely gave me a grin as I berated the iPhone franchise and ridiculed her aging iPhone 4. I told myself I would abhor iPhones and anything else that Apple made that ran iOS.


Two years later, what changed? Not much. I still believe Android is exponentially more powerful than iOS, has much greater potential and, after Lollipop, is more of a looker than iOS is.

Why switch to iPhone then? Two words: Consistency and Ecosystem.

Yes, the Galaxies and HTC Ones have more RAM. Yes, the Note 4 has twice as many megapixels (16 MP) in the primary camera. I’ll admit the “Retina” resolution of 750 × 1334 sounds pathetic against an LG G3’s 2K (QHD) screen. A fingerprint scanner and an aluminum body aren’t all that salient anymore. Sony’s Z phones can withstand dips, while the iPhone can’t.


Knowing all this, I would still recommend an iPhone over any other phone today. Coming from someone who was, till a few months ago a borderline fanboy for Android, that’s saying something.


The first thing that struck me after using the iPhone for a few days was how rewarding it was to be invested in Apple’s ecosystem. The iPhone and my Macbook sync so well, it seems like a given. Continuity, Handoff and everything else that had me excited for Yosemite make the iPhone and Macbook combination much more than just a sum of parts. Airdrop and Airplay live up to the hype. Assignments I work on in the bus on the iPhone sync with the Mac as soon as I connect to the school’s WiFi. Tabs I open on the Mac in school I can read on the iPhone, on the bus home. Backing up Photos on a computer aren't an issue anymore. Not that Android can’t compete: Chrome OS and Android supposedly feature similar integration, but Chrome OS doesn’t really cut it.


I don’t intend this as a damning statement, but the iPhone has worked better for me than any Android phone I’ve used. It doesn’t do as much as a Galaxy or a Note, but what it does do, it does perfectly. This and the consistency with which it works sets it apart from Android. If there’s one thing that’s set every iPhone apart from the Android flagships of its time, it’s how well it works. The Galaxy S6 has a truckload of features (gimmicks?), Sony’s Xperia Z3 boasts waterproofing and the LG G3 has some pretty slick camera tricks and knock on, putting the iPhone 6 seem austere in comparison. Every Android flagship puts the iPhone to shame on paper, with numerous processor cores, twice, sometimes thrice, as much RAM as the iPhone and much denser screens. But none of these seem to hold a candle to the iPhone in terms of everyday user experience and longevity.
In my experience at least, the iPhone 6 has just worked so much better than Android. I haven’t had to deal with abysmal battery life (Nexus 4 and 5), tons of rubbish gimmicks (Note 3), Touchwiz, which cannot seem to fix its issue of giving crazy lag after just a few months of use, and lots more. The Note 3 had a much larger battery, but for whatever reason the iPhone lasts just as long, if not longer. The Note 3 (13MP) and Nexus 4 (8MP) had better cameras on paper, but don’t even come within a one mile radius of the iPhone’s picture quality and its ability to take good shots 8 out of 10 times. I will admit that I prefer the Note’s (over)saturated AMOLED screen, but the iPhone’s IPS LCD is pretty darn good too. And Apple’s DAC makes the Note sound laughable.

I could go on about this, but I’ve also got to recognize Android’s merits over iOS. I really do miss the customizability and openness of Android. I miss the crazy power that it had at times, like rooting and ROMming and even Samsung’s S Note features. Perhaps the HTC One M9 would be the closest competitor to the iPhone from the Android world. I love HTC’s design for the One series, Sense 7 is beautiful most times, if not all, and it’s the only one with audio capabilities rivaling iPhones.

Maybe in a world where IB didn't take up all my time, I would've still stuck with Android. But at this point in my life, I’ve got a dedicated gaming system (PS4) and a Mac for productivity and Designing, leaving me with very few demands from my smartphone. The only prerequisite is that whatever it does, it should be able to do it perfectly, consistently. And at this moment, I don't see anything apart from an iPhone fulfilling my needs.

Maybe in a few years, when it’s time for an upgrade, I’ll buy the latest Nexus or One or hopefully a project Ara device and wait for the waves of nostalgia from years of android use to come crashing back.


(This article is comprised entirely of the author’s opinions and points of view. Your mileage is likely to vary, so please refrain from taking offense eat any statement made.)

26 Mar 2015

KHMD Infuse

The Kumaran Hacker Maker Designer Community held its first event on 3rd March 2015. Members of classes 7, 8, 9 and 11 came together in the High School AV Room. Here's the report.

Being the first KHMD event, INFUSE was carrying a lot of responsibility in terms of spreading popularity, awareness and love for everything related to hacking, making and functional design. 

We began with a talk by Gautam on KHMD; past, present and future, with the relevance and importance of KHMD as a community.

He spoke of how what we learn at school, however practical and informative, isn't enough for the budding hacker/maker/designer and therefore we needed something more, where students could help each other and grow as individuals and also improve the already good quality of students we churn out at Kumarans.

We had a video from Aniruddha Mysore, an alumnus, who wanted to applaud the community's efforts and enforce the idea of KHMD.

Mr. Sathya Prasad from Intel inspired the crowd with his talk on Makers space and what it means to be a maker. His speech was a hit and his easy language and stage presence complimented the message of the talk.

We also had an amazing demo of an in-house Oculus Thrift, built by Aabharan Hemanth, Adhesh Shenoy, Anurag Muttur, Rupith Baburaj and Kushal Naidu.

This seemed to be the highlight of the day and many students tried the device on and were enthralled by its performance.

The response of students after the event was brilliant and several people signed up to join the community.

Infuse was a blast!

Here's the video. Please visit https://www.youtube.com/watch?v=bNyDTBWiDSk for quick links to certain parts of the event.


Thanks to Aabharan Hemanth for editing all the footage. 

7 Mar 2015

Bi-Box Innovation Day




Hi Guys! Here is the long-awaited report on the Bi-Box Innovation Day which took place on 28 February (Saturday).


What is the Bi-Box program?


Bi-Box is a graphical interfaced programming system which consists of a Bi-Box (a micro-controller) where the connections are made. The Logic is designed using a graphical flow chart on a tablet and then uploaded via Bluetooth to the hardware. It is mainly focused on the students who are yet to be introduced to the logic of programming. All this is taught by external instructors from the Bi-Box company.


24 February (Tuesday/Day 1)

We were surprised when all of the sudden, selected students were asked to prepare for the Bi-Box Innovation Day which was going to take place within a matter of 4 days. We were called in and the teachers explained to us what was going to happen on that day. The teachers explained to us that there were going to be 5 main projects and several other filler projects. The main projects were the Argri-mation (The automated farm), E-Hospital (The fully automated hospital), The cloth pulling machine (The automated machine which saves the clothes from rain) and the Automated Cradle. We made up our minds to it and we were ready to start preparing as soon as the required materials and components arrived. I was not surprised when everybody got serious about this day after one of our instructors made a comment saying, "This is the biggest event that has ever happened to Bi-Box so let's make it a grand success!"

25 February (Wednesday/Day 2) 

The preparation for the big day was at full swing! We were called in for the last 2 periods but since we were so excited some of stayed for the last 4 periods! The teams for each of these projects were chosen and division of the work took place. Once the work was divided, the teams started brainstorming for ideas and the final ideas were chosen. But the day was bad as all of a sudden all our progress came to a halt due to technical issues. That day was when I realized how much the Bi-Box instructors cared about this day and were counting on this day. That day they stayed back at school until around 7 p.m just to finish some work which could not be done to cover up the time that we had lost.


26 February (Thursday/Day 3)

It was on this day that real progress was made. The programming part of the projects were done on this day and all that was left was to construct, assemble the models and fix the Bi-Box into it. This was the toughest part of the whole day as there were many technical issues but the teams were able to tackle these problems and move on.


27 February (Friday/Day 4 )

This was the final day of preparation and all the things were coming together and some other people interested in the small projects also joined in. The entire team got together and practiced the way they would present it. At the end, all were satisfied and were ready for the upcoming day.


INNOVATION DAY (28/02/2015)


When the day came, there was more audience than expected due to the PTM that was taking place along side. Everybody was busy just before it started. Badges, Bi-Boxes, Charts were all being distributed to the students taking part. When the time came, the program was at full swing. Everything was going according to plan, people were explaining, showing and telling them what the Bi-Box was.

Detailed description of the main projects


Safe Transport System : The Safe transport system is an automated transport system for the citizens. It features a bus which moves around the city and stops automatically when there is a person in front of it or when it reaches a signal / bus stop.


         

The Automatic Cloth Pulling Machine : The automatic cloth pulling machine helps people who dry their clothes in the open sun. If the machine senses rain, (using a rain sensor which works on the principles of conductivity) it starts a mechanism which pulls the clothes into the shed so that it does not get wet. When it is not raining it brings the clothes back out.        



Automated Baby Sitter : This automated baby sitter helps those who have tough time with babies. If the baby has wet his pants then it sends out an alarm to the mother/father/guardian saying that he has wet his pants. If the baby cries then it makes different colorful patterns using LEDs. 


The Agri-Mation : The Agri-Mation (which stands for Agricultural Automation) is a farm which has many automatic features in it. It has a automatic drip irrigation system that irrigates the crops when the soil is not moist. It has an automated greenhouse which opens in the morning and closes at night. It also has an intruder alarm in case somebody comes close to the farmhouse at night. It also has a fire alarm in case the field catches fire. It is also accompanied by a scarecrow which moves and a windmill as well.


The E - Hospital : The E-Hospital is a automated hospital that consists of a automated stretcher that carries the patient to the emergency room by itself. It also has automatic lights which switch on the moment night arrives. It also consists of some models like the test tubes with different types of blood inside which circulates around a room.




It was a big success. There was a counter which was present for the parents to vote whether they were satisfied or not. A total of 1359 parents voted that they were very satisfied. Overall, it was a huge success.

We thank the teachers and Bi-Box instructors for supporting us in this huge event!

If you have any doubt about what this program is and how the logic is done then don't hesitate to reach me out at gaganbhat6@gmail.com.