4
$\begingroup$

I am programming a semi-circle (and it can also be a circle) that animates to full and empty like so:

enter image description here

enter image description here

I am having a hard time calculating is the slant on the line. What I would like to do is have a bold line drawn that follows the tip of the circle and adapts to it curve like so:

enter image description here

I have done research on finding the point on a circle at any given angle. What I am struggling with is how to find the slope of the line at that point.

Can you suggest how I might calculate the slope of a line at a point in the circle?

Update

Slope was correct and as suggested by @S.C.B.

And the suggestion by @HenningMakholm lead me to the final solution. I originally asked about the slope and the answer provided is correct. Ultimately I wanted to draw a line along the slope and using an inner and outer radius to find the inner and outer points was the solution that worked best.

enter image description here enter image description here

  • 0
    Why do you need the _slope_ in particular? Will the coordinates of the two endpoints of the green/grey bounday not do? With most set of drawing primitives one would think that to be the case.2017-01-11
  • 0
    How do you represent the coordinates of the circle? If the center of the circle is the origin, and your green line has reached the point $(x,y)$ then the slope of your small red line is $y/x$ (note that $x = 0$ corresponds to a vertical line).2017-01-11
  • 0
    @HenningMakholm That is a good idea, I didn't consider that. However, (in the quick few seconds I ponder this) am not sure how I could calculate those two points. I believe the point I get is in the middle of the line.2017-01-11
  • 0
    @MeesdeVries Thanks I am going to be looking into this and seeing if I can draw the line with that formula!2017-01-11
  • 1
    @Aggressor: The two points are on circles with slightly smaller and larger radiuses, at the same number of degrees around the circle as the endpoint of the green arc. (This will make it easier to ensure the the _length_ of your red line is always the same, than working with slopes).2017-01-11
  • 0
    @HenningMakholm I now see what you are saying. I can calculate the point on the inner ark and the point on the outer arc and draw the line between those!2017-01-12

1 Answers 1

2

If you're trying to find the slope of the bold line, it's quite simple. Because your bold line will form a right angle with the tangent line at that point, it must pass through the center.

So, what you are looking for is just the slope of the line that passes through the center and a point on a circle.

In essence, if the center of the circle is the origin of the $xy$-plane then we can conclude that the slope will be $\frac{y}{x}$.

  • 0
    Interesting! I am going to try this out and get back to you how it appears. I am rusty on my highschool math so it might take me a bit to get back to you on the results2017-01-11