Is it possible to influence IK based on target's orientation

My objectives

Hey everyone, recently I’ve taken a project to try to create a viewmodel project where I have tried to use roblox’s IK constraints but they sadly didn’t work in my viewmodel rig, to this I decided to use cosine rule to perform IK myself and apply it to my already existing joints

I have been able to achieve the result of my arm extending to the target in correct directions and arm bending ways, however I seek to improve the looks of the system by also influencing the arm’s rotation to the object’s rotation.

What I’ve tried

I have tried to translate the rotation of the target attachment to my viewmodel however it seems to rotate the whole model from the base with it, It does this as most likely it assumes I rotate my final target in a circular motion as well however the effect I am looking to get is more of how parts of you arm twist in real life

image

image

In upper images I demonstrate how even though the attachment is goes in 45 degree angle to the side, the viewmodel orientation stays the same

I have looked at other examples and tutorials on IK joints, but it seems that because IK examples are modelled in 2D space and and are cylindrical objects, there is not much attention to the orientation of the components that go into actually transforming the series of connected objects

If anybody knows their math and on if it’s possible to even get the object to gradually change the orientation to the desired orientation do let me know!

Parts aren’t linked to the attachment. Attachments are linked to parts. However you could now get the attachment’s orientation, and add that to the arm, because the attachment works with an offset. I suspect this would be done with quaternions, but I’ve never touched those.