Hello!
As you can probably understand from the title, asking this here is my last resort. (Ok maybe not my absolutely last resort Razz )
What I need to do is rotate a point P around another point O. What i've used this far is the standard formula of:
x' = cos(θ) * (xP - xO) - sin(θ) * (yP - yO) + xO

y' = sin(θ) * (xP - xO) + cos(θ) * (yP - yO) + yO

But this obviously doesn't work because Ice doesn't support negative numbers. I've been banging my head against my table for the past 2 days trying to figure out a fix but haven't been able to come up with a formula that works.

Also sorry if there are any formatting errors in this post as this is my first post on this forum!
Thank you in advance! Smile
I had this problem too, here is how I did it:
note: Ice only crashes by dividing negative numbers; the cos numbers has a radius of 255 (because only integer) and it has only 256° instead of 360°
L is the length
n is the NEW number
A is the Angle

cos(A) * L / 255 (rule of three)
= (255 + cos(A)) * L / 255 - L
now cos is between 0 and 510 (not between -255 and 255)


for your therm this means:
(255+cos(A))→C
(255+sin(A))→S

C * (Xp - Xo) / 255 - (Xp - Xo)
//now it would work if Xp -Xo ≥ 0, so you have to write it a bit different
C * Xp / 255 - C * Xo / 255 - (Xp - Xo)


in fact:
(255+cos(A))→C
(255+sin(A))→S
(
C * Xp / 255 - C * Xo / 255 -Xp + Xo) - (S * Yp / 255 - S * Yo / 255 -Yp + Yo) + Xo→Xn
(S * Xp / 255 - S * Xo / 255 -Xp + Xo) + (C * Yp / 255 - C * Yo / 255 -Yp + Yo) + Yo→Yn





Thats a bit long, so You could write:
9000→Q (Q is only a huge number and higher than Xp-Xo and Yp-Yo)
(C * (Q + Xp - Xo) / 255 - (Q + Xp - Xo) ) ....


The 2nd variant:
9000→Q (Xp + Xo + Q must be greater than 0)
(255+cos(A))→C
(255+sin(A))→S
Q + Xp - Xo→dX (d instead of delta)
Q + Yp - Yo→dY

C * Q / 255 -Q→CQ (later you subtract CQ (cosQ) because you added it to dX)
S * Q / 255 -Q→SQ


(C * dX / 255 - dX - CQ) - (S * dY / 255 -dY - SQ) +Xo→Xn
(S * dX / 255 - dX - SQ) + (C * dY / 255 -dY - CQ) +Yo→Yn



I hope this can help you Cool
on my Calculator it worekd.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement