2
$\begingroup$

I'm making a kind of crane.

I need to control the lenght of the link beetween the shoulder and the hook, and the angle of rotation of the shoulder.

The control of the lenght of the link works fine.

enter image description here

Now i need to to rotate the hook the same angle that the shoulder. The issue is do it from the same axis that the shoulder.

How can I retrieve the vector of the axis of the shoulder ?

enter image description here

Thanks for help :)

$\endgroup$

2 Answers 2

2
$\begingroup$

Instead of joining all objects together with the base in a single Join Geometry node, join the parts of the arm first.

The "trick" here is that you do not rotate the object(s) as a whole, but to rotate the vectors (positions of the vertices) around a given center. To do that there is the Vector Rotate node.

So you join the parts of the arm with a Join Geometry node. Then you take a Set Position node to manipulate the positions of the vertices.

And here comes the Vector Rotate node. Plug a Position node into the Vector input to get the vertices' positions. The Center is the pivot point around which you want to rotate, which is the position of the "head" (instead of repeating typed in values I use a Vector input to plug it in everywhere it's needed so you can easily change the arm's position completely instead of having to set all values manually). On Axis you set the vector (1, 0, 0) because you want to rotate around the X axis. The Angle input finally gets the "Rotation" value from the group input converted to radians.

I also cleaned it all up a little, too many Set Position nodes, the Transform node was no longer needed either. Also I subtracted the "Length" input from the hooks position, since I thought it would be nicer to enter the length in positive values. As a base value for subtraction I used -4.4, this puts the hook in the position where it was originally in your setup at length = 0. At the end I used a second Join Geometry node to join the arm with the base. This is my final setup:

nodetree setup crane

With this setup you can move the arm via the Vector input node anywhere away from the base if you should change it afterwards no matter where the origin of the object is. You can also change the initial position of the hook with changing the first value in the Subtract node.

$\endgroup$
1
  • $\begingroup$ Thanks Gordon for your solution and explanation :) $\endgroup$ May 10, 2023 at 20:17
2
$\begingroup$

I first have to say, this is NOT "the" mathematical intelligent solution, but just a working solution:

So i changed some pivot points (shoulder), changed the object info of shoulder to relative, changed your GN tree like this:

enter image description here

result:

enter image description here

$\endgroup$
2
  • $\begingroup$ Something went wrong with your repositioning of the shoulder's pivot point... it's off center so the connection between hook and shoulder is not straight. $\endgroup$ May 10, 2023 at 8:05
  • $\begingroup$ Thanks Chris, perhaps it's not the most elegant solution, but is very easy to understand. $\endgroup$ May 10, 2023 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .