# GH: Tricky 3D Rotation Angles

Hi all,

I’m trying to rotate a Universal Joint (produced entirely in GH) to its very maximum angles. The base geometry (the outer shell with its opening making contact with the axle at maximum angles) allows for a maximum 15 degree angle in two planes (15 degrees / plane).

When turning the ball to maximum angles in two planes simultaneously, the outer ball makes contact with the inner axle at Dot 1 and 3 in the clip. The Ball opening is wide enough to allow the combined planes to sum up into approximately 21 degrees at those contact points (1 & 3).

Anyway, when turning the ball in only one plane, (to max 15 degrees) there’s that gap at point 2.

That gap doesn’t actually pose any problem, except for the tricky math it takes if I want to close the gap while rotating the ball using the Multi Dimensional component shown in the clip. And I would like to know how to close that gap (while not colliding with the axle when both planes are turned to their respective maximum angles).

I’d like the inner edge of the Ball to make contact with the inner axle at all times, but how do I calculate the two (accelerating) angles to achieve that? See clip:

Fig 1. What formula keeps the gap at dot 2 closed all the way from dot 1 through dot 2 to dot 3 while dragging the controller up and down? :

The controller emits values -1 to 1 in both planes, which I multiply with the desired maximum angle (15 degrees in this case, plus allowance for combining this angle in two planes at the same time, which ends up at a maximum of ~21 degrees)

// Rolf

@RIL No illustrations or video visible.

on first look, i think you just rotate the red object around the axis which is the centerline of the red cylindrical part that’s poking out… doing that will make #3 arrive at point #1 without collisions.

likewise, using the same axis of rotation, keep the red stationary and rotate the green… point #1 arrives at #3 eventually.

axis = purple… rotate either the red or the green.

i mean, i can’t really see any other rotation possible that won’t cause a collision.
?

Hi Rolf

Here is my attempt as a simple Rhino file.
I have not the time to try in GH now … sorry

HTH regards.

rolf-joint.3dm (167.9 KB)

@jeff_hammond, I see your point, but unfortunately the green and red parts rotate strictly together. Should have said that since it’s not obvious from the video.

@emilio, yes, this indicates the movement pattern that is required. Producing the movement path with a trigonometric formula is trickier though… At first I thought I had solved this math already in basic school but not so, not so…

Edit: At first I tried something that looks entirely meaningless ( `ArcCos(Cos(v)) and definitely not yielding exact numbers, but surprisingly enough it comes “close” (which is not good enough of course). Look at the the clip below how the angles involved (15 and ~21) are Degrees and the output of ArcCos is Radians, which is then calculated together (15 degrees is the “Desired Turn Angle” in the clip and the “CompensatedAngle” is the ~21 maximum angle in the “corners”).

Fig 1. Here the number pad yields 15 x 15 degrees. (Edit: Updated video to H.264 encoding) :

// Rolf

OK, here’s a cheat formula which comes a bit closer (and doing so without confusing Radians and Degrees). But also this formula has a little glitch, although this time not at the quadrants (gap now closed at all the green pts 1, 2 and 3). This time a small gap occurs at the red pts A1 and A2 (although a smaller gap than at pt 3 in the previous example). See clip :

Edit: Updated video to H.264 encoding :

If anyone think that they can close this gap I’d be listening very carefully.

// Rolf

Hi again Rolf

Here is a candidate GH def with its Rhino test file.

(Assuming that I’m understanding the problem … )

joint.gh (11.8 KB)

rolf-joint-3.3dm (74.9 KB)

Cheers

Wow, that is just perfect!

So now I will spend the weekend trying to understand the math.

Thank you so very much!

Edit: I just gotta show the world how nicely @emilio’s formula follows the edges. One word - Perfetto! (blame the frame jumps on my screen-recorder) :

// Rolf

I just thought, after several trial and error loops …, that the problem might be considered as a mapping from a square to a quarter of a circle.

( Assuming that is a correct representation of this problem )

So I tried to get radius ® and angle (G) from X and Y.
Then we only have to get the joint angles from the target point.

Regards

1 Like

I was going to try to get a deeper understanding of this by breaking up the geometry, but now you present also that part so well.

Excellent!

All the best,
// Rolf

Hm. I’ve used .mp4 video clips in this thread. Is that a format that your browser have a problem with?

// Rolf

They don’t show up in Google Chrome, which is my primary browser, but are visible in Microsoft Edge. Probably something I need to change to see them in Chrome.

Works fine here in Safari on a mac. JSYK

I can’t see any of them either. Chrome on Win10.

I see the videos here on SeaMonkey

A Google search shows that mp4 videos not visible on Chrome on Windows has been a recurring problem, though the most recent posts I found were from 2013. I’ll put a post about it on the Meta sub-forum here.

Is this one visible? I post processed the last video using a H.264 encoder (keeping the mp4 extension) :

// Rolf

Yes, that is visible.

Fine. I’ll update the videos.

I used this tool, which is free:
http://www.h264encoder.com/

// Rolf

What did you do before which was different?