This question on Stack Overflow has an accepted answer that discusses the mathematics of rotation around an axis other than one of the three coordinate axis:
A product of the aforementioned matrices should be enough if you only need rotations around cardinal axes (X, Y or Z) like in the question posted. However, in many situations you might want to rotate ...
The valleys and flat areas where things grow can be identified by a combination of the normal and the curvature of the mesh. Geometry Nodes can distribute plants to follow this pattern.
For example, given this geometry:
The terrain normal in the Z direction is:
The curvature for the terrain is:
Details for Blender 2.93.4
Enable the Tissue add-on.