Jump to content

Rotating 2 Lines to meet at end points?


galagast

Recommended Posts

Hi, how do I rotate two lines to connect their endpoints without changing the lengths in VEX?

meet_two_lines.png

So far, I was able to somewhat get what I was after using other methods in SOPs. I'm curious if there's a way to do it in VEX/VOPs. Even just calculating the required angle of rotation.

I've attached a sample scene below.

meet_rotate_keep_length.hiplc

Link to comment
Share on other sites

think of it as 2 circles, each with center point 0 and radius = distance 0 to 1
calculate the intersection points and for both point 1 set their new coordinates to that point

note: you will get 2 intersection points, just disregard the one you don't want to have

Link to comment
Share on other sites

Thanks 3dome. On my sample scene above, I did a similar approach:
meet_two_lines_ss.png

  1. I created 2 circles centered at points 0 for both lines.
  2. Each circle also had a radius equal to the length of each line.
  3. I then used a boolean SOP to get the intersection and consequently, the point that I was after.
  4. Lastly, I calculated the angles from there using VEX for rotating the lines.

It works great, but I'm more after looking for ways to do all of those using VEX. I will dive more into the docs and see if I missed a function that I could use to calculate this :)

Edited by galagast
Link to comment
Share on other sites

  • 1 month later...

c is just the hypotenuse of the triangle formed between the center points. dist1 (or one could say "a". was kinda late when i wrote the code..:D) is x2 - x1, dist2 (or "b") is y2 - y1.

so a^2 + b^2 = c^2

c = sqrt(a^2 + b^2)

this can help http://mathworld.wolfram.com/Circle-CircleIntersection.html their "d" is more or less my "c"

Edited by 3dome
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...