Is intention the result of rational or logical thinking or some other? According to one of many sources, the definition of intention is described as Right intention is the intention and resolve to give up the causes of suffering, to give up ill-will and to adopt harmlessness. It contrasts with wrong intention, which involves craving for worldly things (wealth, sex, power) and the wish to harm.

What is unclear is whether intention is an act or thought that precedes or follows rational thought?

My understanding is that intention plays a critical role in one karma. If my thought is the result of anger however i do not have intent to harm is that not the result of rational thought? 

If i do act irrationally, to save or protect a life, is that not intention without thought?

EDIT

To add to ChrisW's question on clarification, when i say that if my thought is of anger e.g. how this person would disappear or no longer be around, but this is not followed by action because rationally i do not wish to cause harm. 

The second example of irrational thought is that when caught in the spur of the moment, i may say or do things however this is to protect a child.
Lets take 2 examples where the action are the same:


A surgeon takes a knife and cuts through a person's stomach to save his life
A robber takes a knife and cuts through a person's stomach kill him and take his belongings


In both cases the action is the same but what differs is the intentions. Hence it is the intention that counts.

Now lets take another example.

A baby squirrel falls into the sea and is washed away. The mother squirrel dips her tail into the sea and runs to the shaking off water with the intention of drying water of the whole sea.

The intention is good but irrational. Regardless of rationality the Karmic effects would nevertheless good as the intention is good.