Thorns mechanics are very convoluted and there is no wonder you don't know how it works.
First, the mechanic: In theory, every time a source does damage to you, you do damage back at the source. This applies to ranged attacks, melee attacks, spells, ground effects, everything. Some exceptions apply however, and Blizzard has changed how thorns work in certain situations. For example, Ghom's poison gas. This cloud does damage in small amounts but insanely fast. If thorns were to apply to each individual tick the return damage would be insanely high with a high enough thorns stat. So Blizzard decided to cap the damage intervals at some level, making thorns tick somewhat fast but not to the point where it is OP. (In ghom's case, this is a very recent change). This probably applies to many more abilities and effects in the game, I don't know them all though.
As for the damage thorns does, the calculation of this damage is very much hidden in-game. You have a base Thorns value, the one you get from items and passives. Say this value is 10.000(ten thousand). Then to calculate the actual damage done to whatever source hitting you, this formula is applied:
So if you're a Crusader, and you have 8000 strength and 10.000 thorns (as displayed in the stats details on your character sheet), your actual thorns damage would be: 10.000 * ((8000 / 4) / 100) = 10.000 * (2000 / 100) = 10000 * 20 = 200.000.
So 8000 strength and 10.000 Thorns gives you 200.000 damage return on all sources of damage you take. This effect can crit.
Hope that was understandable. All this is stuff I've tested myself, if anything is wrong please do correct me.
First, the mechanic: In theory, every time a source does damage to you, you do damage back at the source. This applies to ranged attacks, melee attacks, spells, ground effects, everything. Some exceptions apply however, and Blizzard has changed how thorns work in certain situations. For example, Ghom's poison gas. This cloud does damage in small amounts but insanely fast. If thorns were to apply to each individual tick the return damage would be insanely high with a high enough thorns stat. So Blizzard decided to cap the damage intervals at some level, making thorns tick somewhat fast but not to the point where it is OP. (In ghom's case, this is a very recent change). This probably applies to many more abilities and effects in the game, I don't know them all though.
As for the damage thorns does, the calculation of this damage is very much hidden in-game. You have a base Thorns value, the one you get from items and passives. Say this value is 10.000(ten thousand). Then to calculate the actual damage done to whatever source hitting you, this formula is applied:
Actual thorns damage = Thorns * ((Your mainstat / 4) / 100)
So if you're a Crusader, and you have 8000 strength and 10.000 thorns (as displayed in the stats details on your character sheet), your actual thorns damage would be: 10.000 * ((8000 / 4) / 100) = 10.000 * (2000 / 100) = 10000 * 20 = 200.000.
So 8000 strength and 10.000 Thorns gives you 200.000 damage return on all sources of damage you take. This effect can crit.
Hope that was understandable. All this is stuff I've tested myself, if anything is wrong please do correct me.