# Attach Flower head to simmed geometry.

## Recommended Posts

Hi everyone.

I have flower with of which I have isolated the stem and ran it through a simulation. I now want to reattach the head of the flower back to the stem but I obviously want the heads orientation to match with the new simulated stem.

I have tried point deform but cannot get it to work. Although it does seems to be close its not matching up.

attached is a hip with an isolated simple example of what I am trying to do.

Any help is greatly appreciated.

Thanks

##### Share on other sites

would Radius = 0 in pointdeform do ?

##### Share on other sites

7 minutes ago, Noobini said:

would Radius = 0 in pointdeform do ?

unfortunately not. I know it works in the example file I provided, but with lots and lots of flowers and animation on the stems it wont work unfortunately.

Edited by Jesper Rahlff
##### Share on other sites

Hi! I love this kind of stuff

I have attached an example. I had just 5 minutes to do it so I couldn't test it properly but it should work. The idea is to use the normal of the attachment point between the flower and the stem and transfer the rotation from the stem to the flower.

Basically you use the dihedral function to find the difference between the rotation of the flower in the rest position and the rotation of the simulated stem (I have use a trasform node to move it around). After you found it you transfer this rotation to the transform matrix of the flower which is packed. I packed it just because is easier but I guess you can do it also without packing.

When I have some time I can explain it better if you need to

##### Share on other sites

Just take point from stem, if you use wire you have there orient attribute, if not calculate matrix, and apply matrix to flower head. If you dont need orient you can use just matrix

```vector4 orientr=quaternion(3@rot); //matrix for flawer head
vector restP = point(1, "restP", point.number.from.stem);
matrix m = set(qconvert(orientr));
translate(m, restP);
p@restorient = orientr;

vector4 orient = point(1, "orient", point.number.from.stem);
orient = qmultiply(orient,orientr);
vector pos = point(1, "P", point.number.from.stem);
matrix t = set(qconvert(orient));
translate(t, pos);

matrix r = invert(m)*t;
@P *= r;
@orient = orient;```

##### Share on other sites

That's really smart Andrii! I have a couple of questions if you don't mind:

- So the translate function is for apply the rotation matrix to the flower geometry right? Basically is an offset based on the point position

- Why the qmultiply? What is going to return the multiplication of two quaternions?

##### Share on other sites

Brilliant solutions both of them. Thank you for taking the time, this solved my problem right away.

Time and time again the Odforce community just shows why it is the top of the league.

##### Share on other sites

23 hours ago, Andrea said:

That's really smart Andrii! I have a couple of questions if you don't mind:

- So the translate function is for apply the rotation matrix to the flower geometry right? Basically is an offset based on the point position

- Why the qmultiply? What is going to return the multiplication of two quaternions?

translate function just move matrix to the position

qmultiply its the same as multiply matrix but for quaternions, its optional, you can skip this, I need to save initial orientation and use this one.

##### Share on other sites

On 3/5/2019 at 4:45 AM, Jesper Rahlff said:

Brilliant solutions both of them. Thank you for taking the time, this solved my problem right away.

Time and time again the Odforce community just shows why it is the top of the league.

16 hours ago, tamagochy said:

translate function just move matrix to the position

qmultiply its the same as multiply matrix but for quaternions, its optional, you can skip this, I need to save initial orientation and use this one.

Understood, thank you!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×