First Rain Ride of 2009

My first decent rainy ride in more than 2 years, turned out to be a really good and satisfying in the end. Though I have ridden to Mumbai in the very first rains of the season, it was more of a high speed run on near perfect piece of tarmac.

In search of a decent resort in or around Mulshi, for a family outing next weekend, I decided to visit there on a motorcycle.

By the time I got kitted for the ride it was lunch time, though the normal routeto Mulshi is via Chandni Chowk – Pirangut – Paud, I have been on that stretch so many times that today I was just not feeling like riding on the very same stretch. So, I head out in opposite direction on NH4. After filling more than enough fuel for the ride at Shell pump (a rare thing for me, I often land up filling lesser fuel than needed for the ride and then searching for one later) I headed towards Lonavala. After having covered some 10 odd km’s, I got bored of the tarmac and got onto a road through villages and headed towards Pavana dam.

It was a bumpy, slow ride all the way with lush green scenery all around me. Though it was bone dry in Pune, as soon  as I got on this road rain god welcomes me with heavy showers. All my plans of stopping to capture greenery were put on hold, thanks to rain.

Enjoying every water filled pothole, occasional good section of tarmac and gravel, I reach the dam. Disappointed to see it not yet fully filled. A small stop and I was heading towards Paud. Just as I started to climb, the beautiful view of Tung fort made me get off the road for some offroading on slush + green grass stretches.

The ride till Paud was kinda monotonous with no rains and no great view that would made me stand up on brakes. Road conditions deteriorated soon after Paud and I was already in no mood to repeat the Paud – Mulshi stretch on my way back.

After finishing the inspection of all the probably resorts, I was feeling hungry so pulled over for a pit stop around 3:15. Missal Pav it would be for the near empty stomach. While having food I decided to head towards Lonavala. It was almost 4pm and with bike’s chain a bit loose for my comfort and rear sprocket having a bit of play (may be rubber bushing/bearing gone), there was a distinct possibility of getting stranded in a jungle. All part and parcel of adventure on two wheels, I said and got on the bike and headed towards Tamhini.

The road was bit better than before but the non-stop rain was giving very little chance to bring out the camera. Just after crossing Tamhini village, I got off the road and got on the offroad section towards Amby Valley. After a decent stretch initially, consisting of broken tarmac and some gravel I got on a stretch that was mostly a layer of stones, almost till the end. With rain, jungle and hardly any civilization, I wasn’t complaining much about the road surface. After all I didn’t want to go berserk on near perfect tarmac.
It was disappointing to see not too many sections of road under water, not enough water streams or over flowing rivers, as I encountered during my last ride on this section.

Before it got anywhere close to dark I was on the tarmac section near Amby valley, twisties at its best. It was tempting me to push like crazy in search of scraping my knees against tarmac. Alas, if wishes were horses I would have been on a 223bhp machine and not a 223cc machine. In no time I was riding in thick fog, with near zero visibility, so all plans of pressing that “red” button were put to rest. Though the pace was really slow, still it was fun. After all I was still out of city limits with not much traffic to deal with.

Soon the dream run came to an end, as I approached Bushi Dam. With no fog and rain around, I switched from fun mode to reach home mode. After a initial struggle to pass the long queue of cars, I somehow managed to come out on NH4. The traffic is diverted and I came out just next to the turn for Rajmachi. It was very very tempting to take the turn but with clock well past 6, it was just too late for my comfort. So, it was time to slot into top gear and finally press the “red” button to head home before it gets dark. In the end, just managed to park my bike in garage before it was pitch dark to end a much needed and entertaining ride.

When: 8th Auguest 2009
Route: Pune – Pavana Dam – Paud – Mulshi – Tamhini – Kundalika – Amby Valley – Lonavala – Pune.
Distance: 213km’s
Time taken: 6hrs 35min.

Back from Snow Land ala Ladakh

and I’m back, back to modern civilization.
The above picture is one that was clicked during the trip, as we climbed up Chang La after it was happily snowed for more than 30minutes. During this trip, I got to experience more than what I was looking for.

I’ll try to pen down the wonderful experience I had during this trip as soon as possible and share them with your all soon, very soon. 🙂

Out of reach

Pangong Tso

It is not that I was very actively updating my blog here, that anyone will notice that I’m away from Internet for sometime.

Still, for those who stay in touch with me via e-mail, IM’s and other mode of communication, please note that I’ll be out of reach for next two weeks. The picture above should give you an indication as to where I can be found, if at all. 🙂

Mailbox #1: Pointer query

Query: What this pointer exactly holds in this case and how it works.

int *p;
p = (int *)300;

In the above assignment statement, we are storing an integer into a pointer. Since it will not be allowed directly, hence a type casting is required.
Once the assignment is done, pointer p will contain 300 and it will be interpreted as an address. Dereferencing the pointer p, will try to access an integer stored at address 300. The result will be garbage (unless you know what is stored at address 300). Also, the safe execution of the dereferencing statement will depend on the OS in which the code is executed. As under Linux the program will generate segment fault/core dump.

Read Pointer in C/C++ Part – 1 for more explanation.

Query: What is this declaration ? For this printf what will be the answer and why?

double *p,*q;
p=(double *)4000;
q=(double *)2000;

For the explanation about declaration, see the above explanation.

In the printf() we are printing the result of subtracting two pointers of the same type. The number of memory locations between the two addresses will be 4000 – 2000 = 2000bytes. Since the size of double (as both are double pointers) is 8 bytes. The result will be 2000 / 8 = 250. Hence, printf() will print 250 as the output.

Read Pointer in C/C++ Part – 2 for more explanation.

Pointer in C/C++ Part – 2

Having covered the basics about pointers in last article, let’s look into pointer arithmetic. The arithmetic operations that are allowed with pointers are adding/subtracting integer to/from a pointer and subtracting two pointers.

How to add/subtract integer to/from pointer?
The result of adding/subtracting an integer (‘n’) to/from a pointer will be the address of the nth element (of the same type as pointer) with address in pointer used as a base address.

Let’s look into this with an example. Say we have an integer (32-bit integer) pointer pointing to address 1000. Now if we want to add integer 4 to this address, what the result will be?
So, we will assume address 1000 as the base address into which we will be adding integer, 4. Now, since the pointer is an integer pointer, it means at address 1000 an integer will be stored, since it’s a 32-bit integer, it will take 4 bytes. Hence, starting from address 4 byte will be used by that integer (address 1000, 1001, 1002 & 1003). So, next integer will be stored only starting from address 1004, and taking 4 bytes.

By the above explanation we can see that since every integer takes 4 bytes, going to next valid integer, we need to increment the address by 4 bytes or 4n bytes to reach nth integer. Now, this number 4 has come from the fact that the pointer’s type was integer pointer. Had it was a character pointer, we would have to increment address by 1 byte to reach the next valid character.

So, we can form the following generic formula to find the result of adding an integer to an address.

Result = Pointer + Integer * sizeof(Value stored at Pointer Address).

Let’s apply this to our example:
Pointer = 1000
Integer = 4
Value stored at Pointer Address = integer (as it is a integer pointer)
Sizeof(Value stored at Pointer Address) = 4 (it is a 32-bit integer)

Result = 1000 + 4 * 4 = 1016.

If we replace addition with subtraction in the above text, we can come up with the following formula to subtract an integer from a pointer.

Result = Pointer – Integer * sizeof(Value stored at Pointer Address).

So what is the type of the value that we get as a result of adding/subtracting integer to/from pointer? The answer is, same type as the pointer which was involved in addition/subtraction operation, i.e.,  Integer pointer, in the above example.

How to subtract two pointers?
Two pointers of same or different types can be subtracted from each other. Though, normally we subtract pointers of same type only.

In short, subtracting two pointers of same type tells us how many elements of the type of pointers can be stored between those two addresses. In case we subtract two pointers of different types, the result is number of elements, of largest type (type that needs more memory) of pointer, that can be stored between two addresses.

The type of value returned by subtracting two pointers is of type integer, as it gives us the element count.

Let’s subtract two pointers of the same type. Say the two pointers are pA and pB with addresses 2000 and 1000 and their types are integer pointers. So, if we do pB – pA. The result should be number of integers that can be stored between 2000 and 1000. Since the memory locations between 2000 and 1000 are 1000 and each integer takes 4 bytes (32-bit integer). Number of integers that can fit in 1000bytes will be 1000/4 = 250. So, if we subtract two integer pointers with addresses 2000 and 1000, the result will be 25.

Now, the above can be put in a generic formula as follows.
Result = (PointerA – PointerB)/sizeof(Value stored at PointerA or PointerB).

Now, let’s look at the case where the two pointers are of different types, say pA is character pointer and pB is short integer pointer. Since size of a character is 1byte and size of short integer is 2bytes, the result of subtraction will tell us how many short integers can be stored in between the two pointers getting subtracted. Since there are 1000 memory locations between two pointers, the result will be 1000/2 = 500.

Now, the above can be put in a generic formula as follows.
Result = (PointerA – PointerB)/MAX(sizeof(Value stored at PointerA), sizeof(Value stored at PointerB)).

Similar topics
Pointer in C/C++ Part – 1

In & Around Lavasa

Sunrise viewed through wild flowers.

After spending almost entire night @ office, I dumped the idea of hitting bed. Started in dark towards Lavasa to greet Sun a very good morning. Also got a chance to ride my bike into Lavasa township. Picture from a wonderful morning.

View from Lavasa Top, just before Sun was about to come out.
View from Lavasa Top, just before Sun was about to come out.

It was not just me but moon also waiting to greet Sun.
It was not just me but moon also waiting to greet Sun.

First view of the sun as it come out to brighten up the sky.
First view of the sun as it come out to brighten up the sky.

Watching Sun rise from Lavasa top.
Watching Sun rise from Lavasa top. Watching Sun rise from Lavasa top.

Viewing Sun through leaves of a tree.
Viewing Sun through leaves of a tree.

Temghar Dam backwaters view from road to Lavasa city.
Temghar Dam backwaters view from road to Lavasa city.

Standing on the banks of warasgaon dam backwaters.
Standing on the banks of warasgaon dam backwaters.

Warasgaon Dam backwater as viewed from Lavasa City.
Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City. Warasgaon Dam backwater as viewed from Lavasa City.

Twisties – No matter how much you have them, you always want more.
Twisties - No matter how much you have them, you always want more. Twisties - No matter how much you have them, you always want more.

CBZ Standing at the bottom of Lavasa township. Towards Warasgaon end.
CBZ Standing at the bottom of Lavasa township. Towards Warasgaon end.

Standing in Lavasa city.
Standing in Lavasa city. Standing in Lavasa city.

While I was sipping on Tea, I found this young chap making the most of the early morning warm Sun rays.
While I was sipping on Tea, I found this young chap making the most of the early morning warm Sun rays.

Click on image to view in bigger size.

Pointer in C/C++ Part – 1

Wanted to start such posts for a long time. After Abhay posted his queries related to pointers, I decided better late than never. I’ll try to post such stuff more frequent. 🙂
Will always be looking forward for your feedback.

What is a pointer?
Pointer is a variable that stores an address as its value.

How to declare a pointer?
To declare a variable as pointer we have to use “*” along with variable name, in its declaration. Following declaration declares variable i as a pointer to integer.

int *i;

“*” in the declaration is associated with the variable name, which means in the following declaration while i is a pointer variable, j is of integer.

int* i, j;

The correct way to declare multiple variables as pointers, in same statement, is by adding “*” before each variable name, as shown below.

int *i, *j;

Another way would be to use typedef to create a new type and use that to declare variables of that type.

typedef int * INT_PTR;
INT_PTR i, j;

Pointer initialization.
While it is ok not to initialize a static and global variable, as they are by default initialized to 0 (zero), it is always better to initialize a local variable, to avoid using the garbage value stored in it. Since a pointer stores an address, it becomes more important to make sure we initialize a pointer to a known value, as accessing a random (garbage) address can result in core dump (linux)/segmentation fault (windows).

Now the question is how do we get a valid address to initialize a pointer variable?

One way is to initialize a pointer with the address of a existing variable, as shown below.

int i;
int *p = &i; // Initialize pointer p, with address of variable i.

Another way is to dynamically allocate memory and use that address to initialize the pointer variable, as shown below.

int *p = (int *) malloc(sizeof(int));
int *q = new int; // Only for C++ programs.

One more way is, this should be used very carefully, to initialize pointer with a “known” address. This known address might be of some memory reserved by OS and documented. In this case we specify the address as a integer and typecast it to pointer type, before storing it in pointer variable, as shown below. When storing integer into a pointer in the following way one must be very careful in doing so becuase after storing that integer into a pointer, any access of that pointer variable will access the contents of the memory address at the integer location.

int *p = (int *) 0x0417; // Address of a byte where MS-DOS stores status of some keyboard keys.

New Year Special – Ghats near Pune

Lavasa Curve

It’s a belief that what ever we do at the start of New Year, we will keep doing that for the rest of year. I wanted to ride out on 31st night but then family and friends had some plans so I decided to party instead.

Couple of days later, it was the first weekend of year and I decided, better late than never. So, I head out to some near by places. Saturday ride was sort of warm up and hence it was just 103km trip, a slow one at that (Ride duration: 2hrs 45min).
Lack of interest in riding on straight roads, I decided to head to near by twisties and sure it was fun even at speeds around 50km/hr (yes, I was running in my bike after a new block piston kit).

Lavasa Curve

The route I took was Chandani Chowk – Mutha – Lavasa – Mutha – Pirangut – Paud – Hinjewadi.

Sunday I decided to head towards Mahabaleshwar, while I was cruising on NH4 at yawning speed I realized I’m not carrying my bike’s original RC book (often documents are checked at Panchgani, only of two wheelers, as if we are criminals while people in cages are all saints). So when I saw a familiar turn off NH4, I jammed my brakes (must have put down a few mm’s of rubber on tarmac) and got off the boring highway. This was the road I have taken for the last time in Jun’03 (when we went for Pulsar Yahoo Group’s Annual meet). This is a lesser known (to travelers) road that takes you to Bhor. Yes, I dumped Mahabaleshwar in favour of Bhor and Varandha Ghat.

Enroute VarandhaEnroute Varandha

The nature of road hasn’t changed much once we cross Bhor. Though its pothole free tarmac almost all the way, there is plenty of gravel on both the edges and in center. I love it, you over cook a curve, run wide and either you will go off the road or can go and kiss mother earth.
Varandha Ghat CurveVarandha Ghat Curve

Since rains have just gone by, water levels are good in the dam en-route.

Backwaters of Neera DamBackwaters of Neera DamBackwaters of Neera Dam

After a small break for hot bhajis and tea in Varandha ghat I headed towards Mahad. It was closing on 5pm and I knew I’ll have to climb back in dark, on my way back. Having climbed Tamhini in dark few days back on CBZ, I wasn’t too worried of taking the same route again.

Varandha Ghat's Valley ViewVarandha Ghat

Once I reached Mahad, I saw Poladpur (to go towards Mahabaleshwar) some 15km’s away and there was no distance to Mangaon (to go towards Mulshi) given, I guessed that Mangaon can’t be too far away so I headed towards it, after few km’s I realized my mistake as it was still some 30km’s away and the sun has started to go behind hills. By the time I reached Mangaon it was 6:15pm and after filling some fuel (yeah twice I have started the climb to Tamhini with bike about to hit reserve – no way was I going to repeat that mistake).

The Mangaon – Vilhe road was almost empty of traffic and in lovely condition. Even though it was dark, it was fun riding in that section filled with twisties. After Vilhe, I decided to stay with couple of cars that were climbing Tamhini but with me not wanting to stress my new engine, mid way thru the ghat one car was too fast for me while the other was too slow, as a result I was left all alone. It was a bit scary and I was remembering only all the scary stories I have heard about this area. Hoping to catch some slow moving vehicle ahead, I kept on riding but I wasn’t that lucky. Once I passed the last dhaba on top of ghat, it was me and my bike all alone. Other than my bike’s headlamp, moon and stars were the only light sources visible. I wanted to stop and click some pictures but wasn’t able to gather enough courage to do so. After riding all alone for some 15min’s I caught up with some traffic as the bad stretch of road has started. Then on it was just a matter of keeping up with them.

Following with vehicles I reached Mulshi lake and what a beautiful view it was, I told myself I’m coming back here in night again, of course not alone :-). As I was feeling hungry, I halted for dinner and then it was a slow cruise till home.

Route: Pune – Bhor – Mahad – Mangaon – Vile – Tamhini – Mulshi – Pune
Distance: 300km’s
Ride Duration: 8hrs 30min

Click on image to view in bigger size.

Panning & Moon’o’graphy – 2

Today I was out again in night sharpening my panning shots. Lday luck was with me and the very first shot came out almost perfect (to my liking). As I was hand holding the camera, I started with ISO1600 and hence some grain can be seen in the image.

Clicked using Canon 70-200 f/4 L lense on 400D, shot @ ISO 1600, 188mm, f/4 and 1/10sec shutter speed.

Motivated by my effort, I got the tripod out and started to practise on the moving objets. Now, I was able to bring the ISO down to 400 without too much blurr as I was no more hand holding the camera. Following is one of the many clics.

Clicked using Canon 70-200 f/4 L lense on 400D, shot @ ISO400, 145mm f/4 and 1/5sec shutter speed.

While I was out, I also decided to capture the white moon, almost in its full shape.

Clicked using Canon 70-200 f/4 L lense on 400D, shot @ ISO100, 200mm f/8 and 1/125sec shutter speed.

Similar topics
Panning – My Debut shots

Panning – My Debut shots

My Pan Shots

Last night as I was done shooting moon from my house balcony, I looked at the well illuminated empty road, some 100m away from me. Tried to click some shots but due to not using a tripod most of them didn’t came well. In between I clicked a zooming car and thats when I decided to try my hand at Panning. Due to low light condition, I had to use higher ISO and really slow shutter speed and hence shots were having too much noise/not sharp enough.

So today morning I decided to venture out once again and here are some of the shots I managed.

My Pan ShotsMy Pan Shots

My Pan ShotsMy Pan Shots

Click on image to view in bigger size.

So how did I clicked them?
I used a slow shutter speed (resulting in larger f-stop/small aperture) and switched between “One Shot” & “AI Servo” (or something like that). Moved the camera along with the moving car/bike. Click and kept moving, when I didn’t moved the camera as I clicked, the object came blurred.

What is Panning?
In simple terms, its about clicking a picture by keeping the moving object in the frame by moving the camera along the object and clicking it at the same time. This will blurr out the background, giving a sense of motion in the image.

For these shots I used my Canon 400D with 70-200 f/4 L lense.