Ah, I see the issue. Instead of the segment lengths being passed in for a and b, the distance from the segment positions to the origin is passed in instead. The size of the part in the proper axis should be used as parameters a and b.
Would that just be this instead?
local a = v1.Size.Z
local b = v2.Size.Z
What would you use for dir
in this case? I feel like I’m improperly calculating dir
. A bit confused.
a and b should be the lengths of the arms, so yes in this case.
The dir is the direction you want the elbow to extend in. Research what orthogonality is (basically perpendicular in 3D). The dir must be orthogonal to the line from the start to the goal. This is because any euclidean space is made up multiple orthogonal directions, equal to the number of dimensions. We made a space in 2D with the direction from the start to the goal, and the given direction for the elbow and solved for the point of intersection in that space.