Stormworks: Build and Rescue

Stormworks: Build and Rescue

Not enough ratings
3d IK arm demo
   
Award
Favorite
Favorited
Unfavorite
Tags: v0.2.42
File Size
Posted
Updated
126.196 KB
20 Jul, 2018 @ 9:42am
20 Jul, 2018 @ 4:44pm
2 Change Notes ( view )

Subscribe to download
3d IK arm demo

Description
This simple setup lets you control the arm's endpoint by moving naturally in 3 axes.

You can use the throttle sliders or pilot seat (w/s, a/d, up/down) to adjust the endpoint goal.

This is not a general IK solver but an efficient geometric setup for controlling this specific type of arm (2-axis base joint, 1-axis elbow joint).

HOW IT WORKS
  • Takes a set of 3 input coordinates (x,y,z). It is important to limit these ranges to sensible values so that the arm can reach most of the play area.

  • First, the (x,y) target vector is converted into an angle (green func) and magnitude (yellow func) and the angle controls the base hinge.

  • Then, the (x,y,z) vector is converted into a length which informs the angle of the elbow joint (orange func). Imagining a triangle formed by the arm segments and the total length, we can use the law of cosines to find the angle we need:
    (2/pi)*acos((128-min(len(x,z),16)^2)/128)-1
    The value 16 in this example is the furthest the arm can reach, in this demo each arm segment is 8 blocks long so we cap our value here to avoid unsafe values.
    The value 128 in this example is a pre-computed value of 2d² where d is the length of an arm section (8).
    This optimisation only works if both arm-segment lengths are the same, use the full law of cosines identity otherwise!

  • Finally, the inverse of the elbow angle is applied to the shoulder joint plus the angle formed by (y,z) vector (red func).
1 Comments
Tajin 20 Jul, 2018 @ 12:41pm 
added to "Logic Examples & Knowhow" :) nice work