O, i c wut u did thar.
Actually, Why don't you just take the mathwork out of it and create "no transform" zones built into your levels?
If you're worried about overlapping a wall on one side (or two adjacent, in a corner) you can run a simple distance check in your cardinal directions. Alternatively, write a push algorithm so that your monster can transform in "safe to transform" areas without worrying how close to the wall he is.
I just think the whole "let's write thirty-thousand detectors" thing is an awful lot of work to accomplish what can otherwise be planned for and convincingly faked.