What exactly constitutes the ground is left up to the GM. Everyone has a sense of what would constitue "the ground" at a given position. A GM ruling based on that will most likely satisfy anyone if made in advance (so no "your casting fails as that is not the ground"). I have never had problems with rulings like this, most players do not even question these as it is within their "sense of common" too. Even if a player contests it, they also have nothing to base that on and you trump them by being the GM.
The following is how I would rule:
- Being "at the height of the spell effect" is relative to "the ground".
- Casting is dependent on the ground at/under the target, not on the position of the caster.
- Something can only be "the ground" if a small or larger creature can stand on it for some time without balancing. So no throwing rocks up in the air and casting on them. Also no casting based on any tree you can climb with branches to stand on (unless it is the "World Tree" or something else on that level).
So in the masterfully illustrated example you cannot include the pterodactyl in the AoE while it flies around the tower at 75 feet. The ground is at the base of the tower in those positions. If he moves over the tower (to attack you, for example) you can include him in the cylinder as the tower is a stable platform you are able to stand on and thus is the ground there.
This can get surprisingly complicated.
So the first point is, you don't need to use any grid at all. In that case, rotating the cube is natural and you are right with the \$L\sqrt 3\$ diagonal case.
If you do use the grid however, it gets muddy. Dnd measures distances not in normal way, but just as a maximum of coordinates (this is a weird way of saying that diagonal movement costs the same as non-diagonal).
So either you sort of rotate the grid temporarily (in your head) to figure out the area of effect, in which case it works the same as the fist case, even though now you distance from the target is only \$L\$.
Or the grid stays and then you start studying the theory of metric spaces to figure out how does a cube in this situation even look like. The easiest to imagine would be the 45° rotation (2D) case, in which (C- caster, T-Target):
X
XXX
CXXXXT
XXX
X
Or to be more srict with the rules about origin and faces (the caster is by the south-west face facing towards north-east):
X
XXX
XXXXT
C XXX
X
Notice how the diagonal is 5 squares (or 25 feet) long, while the side is 3. But this feels a bit cheatsy since the concept of cube here is not very well defined.
Finally, note that DMG p.249 has rules/guidelines on how many targets does each shape "usually" hit for theater-of-mind and similar approaches. For Cube it states size/5 (round up), so 15 ft cube gives you around 3 affected targets (in situations where exact positioning is not a top priority).
Best Answer
Unfortunately, no (with one possible exception).
Although this isn't the place to say perhaps, I think I have a slight contention with the answers to the related questions on whether the caster including themselves in the area of effect, is completely inside the area in the way portrayed. I see this more as just the point of origin affecting the caster (as it says) but not that the entire area of effect has shifted.
Typically this would be so the caster can affect himself with a beneficial effect, which is likely the intention. In other words, the area of effect projects out in front (see the diagram below), but the caster, right on the point of origin, can be affected or not.
Nevertheless.
Even accepting the ruling given on the previous question, your scenario would only possibly work against larger creatures.
Either you are in the area and hence affected by the spell. Or you are not, which would mean the only way you could be in the center square of a cubic area of effect, yet not affected, would be if the cube was above you (or below you if you were somehow flying?). In this case a DM may rule it would only affect creatures that are taller than you, and tall enough to be affected by the blast that has just gone off above your head.
Nahyn Oklauq points out that it would be possible to lie down and cast Thunderwave from the ground, hence affecting same-sized creatures. This is playing a bit fast and loose with the rules (which are really geared towards a 2D map rather than these kind of 3D shenanigans), so would probably be DM fiat as to whether he would allow it.