Log In  


Cart #38900 | 2017-03-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

7


I use those polar coordinates all the way in my Leap of Faith project.
Did you notice that when calculating point position it is a little off with the draw_circle figure? Like it goes one pixel extra at the left side and one pixel off at the right?
I think this happens due to round-ups. I've found that making pi a better accuracy provides better results, but you don't seem to use pi.
I am not sure there is Math library available in pico? Since I wasn't able to use that Math.Pi I decalred my own.


Hey! Yeah I noticed thta about draw circle, and I suspect it is using something different other than sin and cos.. check out http://www.helixsoft.nl/articles/circle/sincos.htm - and read the "another way to draw a circle"

As for Math.PI, no there isnt one as far as I can tell, you can make PI but I dont think it is that accurate because the precision is only down to the 0.0000s - unless there is a different way to have more precise numbers!


Thanks! I ll check it out
Also I believe here

x = center_x + radius * cos(a)
y = center_y + radius * sin(a)

should be

y = center_y + radius * sin([b]-a[/b])

But your point seems at the right place on the demo so maybe you fix it later, sorry I didn't drill too deep.


Thanks for digging in my code :) Appreciate the feedback too.

I'm not sure why, but sin(-a) was not working as I thought it would (i know the docs say that it is opposite, but idk lol maybe I'm doing something weird here!)

Maybe its not inversed anymore?? or perhaps I did something wrong :P


You're welcome! I am glad I could discuss something similar I've been figuring out lately.
I think it is still inverted as I tested it but you seem to eliminate the minus here

return sqrt(delta_x*delta_x + delta_y*delta_y)

Good that works but just mind if going to reuse it somewhere.


That function is only for finding the angle again but via a different calculation purely for educational purposes. It's not being used for finding x and y. Maybe the Arcosine is just making it go counter clockwise instead???? Correct me if I'm wrong, I haven't taken trig!!


I put together a tutorial on moving things on a circle
https://www.lexaloffle.com/bbs/?tid=29094



[Please log in to post a comment]