nParticles Instances orienting on 2 axis (Plane-Orientation)


Dear All

I have a question regarding nPartciles and Instances. Before I start, I am a Z-up user due to my architectural background. I have a general setup / Workflow for instancing geometry and orient them correctly to the surface normal with and without random rotation which works perfect (See first picture).

Initial Setup, Align to Surface normal, random rotation around Normal

I am currently looking to populate a wall with plants. The plants are modeled/hanging so that they look like gravity is affecting them on one side. Therefor a orientation to the surface normal works still fine, but the random rotation, or the default rotation doesnt work anymore. Ideally all the plants need to be rotated so that they are hanging downwards.

My problem is that i cannot figure out the default rotation of the object after instancing and aligning to the surface normal. If i could get the 2nd vector of the nparticle, i could calculate(with some crossVec) the missing angle and rotate them into place.

Has anyone an idea on how to figure out the missing rotation, or another workflow for doing a proper 2-axis (Plane) orientation?

Thank you in advance.

Kind regards



Adding the desired reference

Left, target reference, all instances normal to the surface and pointing downwards
Right, calculating the desired orientation for rotation


Small Update

I found a solution that works in 99% of cases.
Please find the expression in the picture:

Oriented to surface normal and always pointing downwards

The trick is that the geometry is somehow aligned towards the World X Vector. If you project the World X Vector onto the local plane defined by the Surface normal, and calculate the angle between that one and the vector pointing downwards in the surface-normal-plane you get the necessary rotation in Z.

It only fails under certain angles which i will neglect for now.
If you have any other suggestion please let me know.

Kind regards