Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Sliding mechanism rigging

giuseppetonello
Advocate

Sliding mechanism rigging

giuseppetonello
Advocate
Advocate

I need to rig three parts: a rail, a slider, a mechanical arm(or crank) and a dummy, like in this picture:

 

rail.jpg

 

The dummy is free to move in all directions and it should control the arm and the slider, which must move only inside the rail.

In other words, whenever you move the dummy you should be able to push or pull the linked arm and slider.

 

 

 

 

Joey
0 Likes
Reply
Accepted solutions (1)
987 Views
7 Replies
Replies (7)

leeminardi
Mentor
Mentor

I assume by "all directions" you mean full 3D (x,y,z).  This post may be similar to what you want to do excpet that your "cable" is a straight line in which case there may be a simpler solution.  Please post your Max file and I'll take a look at it.

lee.minardi

leeminardi
Mentor
Mentor

Here's a rig that I think will do what you want.

A position script controller is assigned to a dummy (DummyOnRail).  It's position is first guessed to be midway between the two ends of the line named "rail".  The distance from DummyOnRail to DummyManipulator is compared to the length of the arm.  If it's greater then a new guess position is made midway between end 1 and the midpoint.  If not then the new guess is midway between the midpoint and end  2.  The process is repeated 10 time yielding a solution if possible.  If DummyManipular is too far away then DummyOnRail snaps to the end of the rail. 

 

e1 = getknotpoint rail 1 1
e2 = getknotpoint rail 1 2
v12 = normalize(e2 - e1)
armLen = arm.height
g1 = e1
g2 = e2
gm = (e1 + e2)/2.
i = 1
while i < 10 do
(
if (distance gm dumMan) > armLen then
(
g2 = gm
gm = (g1 + gm)/2.
)
else 
(
g1 = gm
gm = (g2 + gm)/2.
)
i = i + 1
) -- while
gm

 

leeminardi_0-1667053851771.png

 

lee.minardi

leeminardi
Mentor
Mentor

I think this is a better solution than my last post. It uses some simple vector math to find the point on the rail.

 

e1 = getknotpoint rail 1 1
e2 = getknotpoint rail 1 2
v12 = normalize(e2 - e1)
armLen = arm.height
pp = (dot (dumMan - e1) v12) * v12 + e1
a = distance pp dumMan
b = (armLen^2 - a^2)^0.5
p = e1 + v12 * ((distance e1 pp) - b)
if armLen > (distance pp dumMan) then
p
else 
e1

 

Point pp is the projection of the dummy manipulator onto the rail. a and b are two side of a right triangle formed by dummyManipulator, pp, and the solution point p.  If the dummyManipulator is too far away the arm snaps to end 1.

 

lee.minardi

giuseppetonello
Advocate
Advocate

Thanks, @leeminardi let me get my head around your solution and get back in a while.

Joey
0 Likes

leeminardi
Mentor
Mentor

@giuseppetonello The following illustration may help you understand the script. Green arrows are vectors. P, PP dumMan, e1, and e2 can be considered vectors as well.  I visualize them as vectors going from 0,0,0 to the noted point.  Of course, they are free vectors and may be positioned anywhere.   The dot product of a vector (e.g., (dumMan - e2)) with a unit vector (v12) yields the magnitude of the vector projected onto the line of the unit vector (equals b in this example). Let me know if you have any questions.

leeminardi_0-1667688988281.png

 

lee.minardi

giuseppetonello
Advocate
Advocate

@leeminardi I've never seen a while loop in a position script. Can you explain what every iteraction (e.g. while i < 10) does? Also, the position script on the post above seems different than the one on the attached file.

Joey
0 Likes

leeminardi
Mentor
Mentor
Accepted solution

The position script in SLiding Rod .max (post #3) uses a numerical methods technique to determine the location of the slider.  It uses a series of guesses for the location improving on the guess with each iteration.  This solution was overly complex for the problem and you can ignore it.

 

The position script in SLiding Rod01 .max (post #4) uses an analytic approach.  It is a beter solution. Let me know if you have any about this solution.

 

lee.minardi