[Tutor] Using trigonometry to draw a circle
Phil
phillor9 at gmail.com
Tue May 18 20:10:56 EDT 2021
On 18/5/21 8:06 pm, David wrote:
>> wxPython's addArc function, for example, works well but I cannot see how
>> I can set points along the arc. If I plot individual points to generate
>> an arc then setting points along the arc is easy.
> Depending on why you are doing this, there are different approaches
> that might or might not be a good idea. So you will get better advice
> if you describe the bigger picture of what you are doing, not the details.
Thanks David,
At the moment I'm playing with wxPython and I'm reluctant to go too
deeply into wxPython code because this is not a wxPython list. I'm
trying to simulate an analogue meter and the current approach is to use
the path.AddArc function to draw the meter arc. Now I'd like to add
ticks along the arc; I cannot see how to do this.
So now I'm experimenting with drawing the arc with a for loop to
calculate each point and then setting the points on the frame. So far so
good, now to add the ticks. The ticks should be short lines centred on
the arc and extending a little on each side of the arc towards the
centre of the arc. As I see it, this requires more calculations to
determine the end points of the ticks. I have the x, y coordinates of
where the ticks should be centred on the arc, I know the length of the
ticks and I know the distance to the centre of the arc.
Another approach that I've considered is to draw the meter in a drawing
application, or use the Python pil library. Then I could display the
meter and rotate the needle about it's pivot point. I haven't looked
into the finer points of this approach but it would avoid lots of
calculations every time the meter has to be updated.
Your matplotlib code is very close to what I have in mind and I've saved it.
--
Regards,
Phil
More information about the Tutor
mailing list