Here's the thing - what altitude are you starting at? There are alot of factors involved. The impossible turn may or may not be impossible depending on how high you are when the engine quits. Some airplanes will glide better than others. Making the 180 when the engine quits in a PA28 at 500' may be perfectly doable. In something more complex like a PA32 - 500' probably isn't going to be enough.
If you are going to consider the turn back to the runway, know how much altitude you need and know your airplane.
You're right that there are a lot of factors. In addition to knowing how much altitude your plane loses in the turn, you can pay attention to whether you have reached that height (AGL) by the time you cross the departure threshold, because if you haven't, you may not be able to reach the runway after a turnback (although this will depend on your climb and descent angles).
The above does NOT guarantee that you will have enough altitude to make it.
Here is some of what I have been taught:
-At sea level with no wind, at max gross a 172 or 182 requires about 3500 feet of runway. (I assume this is on a standard day.) Each knot of headwind decreases the runway length needed by about 130 feet.
-If your climb angle is less than your descent angle, then extra altitude above the required turnaround height hurts instead of helping, because of how far you had to travel away from the airport to gain that altitude. Consequently, it's beneficial to climb at Vx instead of Vy.
-Calculate the necessary climb rate prior to take off, and then watch to see if you get that climb rate. The formula I was given is that the climb rate, in hundreds of feet per minute, needs to be at least the ground speed in knots divided by the glide ratio. For a Cessna 172 or 182, the glide ratio was stated to be about nine-to-one, and can be adjusted by adding one for each seven knots of headwind.
-If you see that you are not getting the needed climb rate, consider turning crosswind early and climbing in the pattern.
-Land straight ahead if possible.
-Practice turnbacks regularly at altitude or don't even try it.
Note that I am not saying that any pilot should or should not try this. This is only a summary of what I have been taught.