I have 2 bars on each side, position and sizes are dynamic, I need to build and arch on top of these bars joining like yellow highlightes in the picture below, I must go with dynamically provide slope in a function and the arch center will be the absolute center of the 2 side bars. I am stuck trying to make it work. can anyone please help me?
My suggestion would be to try to make the arch by yourself. As a hint, you can split the problem into two smaller problems:
- mathematics: if you have the coordinates of the beginning and end of the arch, and the angle, calculate the coordinates of the top middle joint
- graphics: having two points, draw a bar from the first point to the second point
If you solve these two problems, you have everything in order to make the arch.
thanks for the suggestions, I have the 2 points cordinates yes but I am unable to find the center point Y (YUP) based in an angle provide, say I am looking to set a 30 degree slope, how do I calculate the Y position (top point of the arch) basen on a 30 degree slope up from the side bars?
Here is the next hint. The mathematical problem can be illustrated with this picture:
The angle α is known (30° or any other degrees). The distance d can be calculated by the positions of the two vertical bars, so d is also known. However, h is unknown. Do you know how to calculate h with trigonometric functions?
that “h” is exactly I am looking for, I am not sure how to calculate h
The half arch is a right triangle. So, it is possible to use the tangent function:
tan(α) = h / (d/2)
h = tan(α)·d/2.