How I do mine is to look for the first touch within a given area of the screen. When that occurs, I mark that as the center point of the stick. I'll draw an axis at that location from then on.
As that touch moves, I simply subtract the new coordinates from the original to figure the amount of deflection of the virtual stick. You can scale these deflection values to whatever you feel will work best for you...left as -1.0 and right as 1.0, or percentage values...whatever works best for your purposes.
I render a blob of some sort at this point where the finger is so I can see how far it is deflected. The graphics of the virtual stick are therefore an axis and a point blob showing the deflection.
There is usually a limit to how far you can deflect any stick. A physical stick, will naturally have a physical barrier and this is not present in the virtual equivalent. Therefore, you must usefully account for this lack of feedback the player would normally have.
The most important thing to take into account is not to all of a sudden 'cancel' the input just because the finger has moved beyond the maximum deflection from the origin. If you're moving a player, the player will just stop if the input is cancelled. This could be argued as feedback, but this stop moving, correct your deflection and start moving again cycle is far too frustrating for many games and players. Therefore, let the finger go beyond the stick and simply clamp the deflection only, not disable it. The deflection should also follow the finger, even if it is moving outside of the graphic representing the virtual stick. The benefit of this is that you do away with the need for a player to receive feedback from what would normally be the physical constraint imposed on moving the stick to a maximum deflection.
Ideally however, you will still give the player some feedback regarding how far they are deflecting the stick. The axis is part of this, however this is not convenient to look at. Instead, focus on providing a visible response directly where the player is looking. The most convenient example of this would be moving the virtual player proportionally according to the level of stick deflection - exactly what an analog control is for.
In full, this technique allows for a virtual controller with a floating origin (wherever your put your finger down you'll get a virtual stick). A virtual controller just doesn't have the physical feel of the origin so the advantage of this is you don't have to remember or use 'muscle memory' in order to determine where the center of the stick was. If you wish to return the control deflection to the origin you simply lift your finger and replace it. You learn this little trick very easily and it quickly becomes natural.
Some argue that fixed origin is better for a virtual controller. The implementation for a fixed origin stick is not much different to the above - just fix the origin and never move it. Personally I find these to be a little annoying if only because a lot of them don't offer any configuration with regard to the location of the stick. This will mean the location may not be ideal depending on the size of your hand - typically you use your thumb so depending on the location, your thumb will be cramped or stretched to use it which is uncomfortable.
Of course the downside of the floating origin is that you have to keep your finger on the screen or the origin will reset and your deflection is lost. Also, with your first touch defining the origin then to deflect the stick straight away you have to put your finger down and then move it. You can't just put your finger down and have the stick deflected straight away, as you can with one of fixed origin.
I still prefer floating though. Tablets are large and despite being light, they are not light enough to hold easily for playing with virtual sticks while pressing on the screen. At least for even a small duration I think this is uncomfortable. Allowing the player to therefore re-position their hands as often as necessary helps them to constantly loosen their grip and flex the hand, which I think is essential. Requiring a fixed pose for the hand for the entire duration of play, even if it is minutes can be excruciating and this is a big problem for a fixed virtual stick.
Despite my personal preference however, I actually think games should support both fixed and floating types...it's almost no effort. I also think that given the sticks are virtual, it's also correct and almost zero effort to support left handed configurations. There is no physical constraint to this, so why not?