constraint - shortest line between two circles

constraint - shortest line between two circles

begerdesign
Enthusiast Enthusiast
1,537 Views
5 Replies
Message 1 of 6

constraint - shortest line between two circles

begerdesign
Enthusiast
Enthusiast

Hello, I have a question about constraints. Perhaps it's very easy but I have already tried with aim constraint, geometry constraint, closest point, ... but it does not work.

constraint.jpg
I have two circles connected by a line. The line is perpendicular to the curvature of the circles. So it describes the shortest distance between the circles.
Now I want to move the circles, but the line should always describe the shortest distance between the two circles. For this the end of the line must be able to move along the circles.

I want to animate both circles.

On the picture you can see what I mean. If I move the blue circle from position 2 to position 3 (red circle) the line between the circles will move as well as the line between the circles on the picture.

Does one of you have an idea?

Thanks for your help

Thomas

Translated with www.DeepL.com/Translator (free version)

1,538 Views
5 Replies
Replies (5)
Message 2 of 6

cavescholar
Advocate
Advocate

This does sound tricky, but after some thought I was thinking this is just like an arm joint chain. Shoulder would be circle 2, circle 1 would be the elbow, and circle 3 would be the hand. So maybe make a joint chain with 3 joints, then bind your lines and circles to the joint chain. When animated though, you won't see the joints rendered. Also, if you are using Nurb circles and lines, they will also not be rendered. That's why nurbs are used as animation controls, they don't show up in the final render. You could just do a playblast once you have it setup and choose what is shown or hidden through the SHOW menu from the viewport menu bar. 

 

Just an idea, good luck!

0 Likes
Message 3 of 6

begerdesign
Enthusiast
Enthusiast

Hello, thank you for your answer.
I guess I didn't explain it well.
Circle 2 should move to the position of circle 3. The line between the two circles (green line) should always look for the shortest and most direct connection between the circles. The circles will later be replaced by rings and the lines by cylinders. Even if the distance between the circles changes, the cylinders should always be long enough to reach exactly from one circle to the other. Finally I want to create a network of many such rings and lines. Like a cloud of circles and lines that move dynamically. 

Message 4 of 6

mcw0
Advisor
Advisor

Use joints.  And parent the straight section curves to your joints.  Create single chain IK handles and parent those to the appropriate circle.  Point constrain the root joint to one of the circles.  You know the radius of the circles so offset your curve along the longitudinal axis of the joint by that amount.  Then do the math to figure out how long the straight curve needs to be.  Get the distance between the 2 appropriate circles and subtract the diameter.  That will be your scale value for your straight curve.

 

I hope that made sense.  It's late.

Message 5 of 6

begerdesign
Enthusiast
Enthusiast

Thanks for your answer and sorry that I explained it so inaccurately.

I think your idea works fine in 2 dimensions, but I need 3 dimensions. It shall become a dynamic cloud of many moving circles connected by tubes. 

But I will give it a try.

 

Thanks

0 Likes
Message 6 of 6

mcw0
Advisor
Advisor

Ah, I see.  The orientation of 2 circles will not always be coplanar.  So you will need to use a "closestPointOnCurve" node ("cpc" for short and 2 per circle).  You say it will eventually be a dynamic cloud but the same circles are always connected, right?  So then it's just a straight forward connection to the cpc (translate to inPosition and worldSpace to inputCurve).

 

The cpc will give you the position on the circle that is closest to the other circle.  You can then connect the cpc.position to your straight curve's controlPoints attribute.  "controlPoints[0]" will be on one circle while "controlPoints[1]" will be on the other.  Always connected to their closest points.

 

To do this for your dynamic cloud, you will definitely need to script this.  Let me know if you need help with the scripting.

0 Likes