Help with trigonometry problem (Kinematics?)

I am trying to make a “leg” with two segments (parts), with differents lenghts each (see picture)

I will make a ray from a part (start pos) and get an end position, and knowing the lenght of both segments, set the cframe of the two parts to make the “leg”

The problem is that i can not get the adyacent side, i could if both segments had the same lenght, making the adjacent side of the triangles be equal to distance/2 but is not the case, and i dont know how i can get it

Your description is a little confusing because you refer to seg 2 and say in orange “but starting from the end position and looking to the start position” but you didn’t specify if you were refering to the seg 1 start and end, or the seg 2 start and end.

Please edit your post so we can more easily understand what you mean. :slight_smile:

You are right, my bad

is better now?

Well forgot everithing i tryied, you should use the Law of Cosines, Law of Cosines, Finding Angles & Sides, SSS & SAS Triangles - Trigonometry - YouTube (jump to the 3 sides part)

                local a = s2.lenght
				local b = distance
				local c = s1.lenght
				local dir = math.acos(
					( (a*a) -(c*c) -(b*b) ) / ( -2 * c * b)
				) 
				warn(dir)
				local lookCframe = CFrame.lookAt(start,goal) * CFrame.Angles(dir,0,0)
				cf = lookCframe + lookCframe.LookVector * (s1.lenght/2)   

Sorry, I didn’t get to pass on that information on because I went to bed. :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.