Log In  

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

P#38901 2017-03-31 01:45 ( Edited 2017-04-01 16:18)

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.

P#38902 2017-03-31 03:02 ( Edited 2017-03-31 07:03)

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!

P#38903 2017-03-31 03:08 ( Edited 2017-03-31 07:08)

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.

P#38904 2017-03-31 03:23 ( Edited 2017-03-31 07:23)

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

P#38906 2017-03-31 03:58 ( Edited 2017-03-31 07:58)

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.

P#38907 2017-03-31 04:41 ( Edited 2017-03-31 08:41)

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!!

P#38924 2017-03-31 17:29 ( Edited 2017-03-31 21:29)

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

P#38979 2017-04-01 12:18 ( Edited 2017-04-01 16:18)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-01 17:24:28 | 0.012s | Q:18