Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Math Question - Polar Coordinates

Status
Not open for further replies.

merhaka

New Member
I've run into an issue with polar coordinates.

Lets say I have the following polar coordinates (5.656, 45°)

A little bit of math, and the cartesian representation would be (4,4)

I understand the conversions quite well, though I can't figure out how to calculate X & Y for a change in angle (theta). For example, I want to rotate the cartesian coordinate (4,4) by 90° At a glance I know the result should be (4,-4) but how can I calculate the result?
 
Last edited:
It's imaginary multiplication. Learn how to calculate with imagy numbers, then you'll see this is pretty easy.
 
It's imaginary multiplication. Learn how to calculate with imagy numbers, then you'll see this is pretty easy.
Sorry? I'm not sure where your going with that. I've left out the conversions for ease of explanation. My problem is not related to them, and there would have been no value adding them to the post.

I have managed to get to this equation:
Code:
Y2 = X * Cos(t) - Y * Sin(t)
X2 = X * Sin(t) + Y * Cos(t)

It assumes your working in radians (decimal to radians conversion: t = t * Pi / 180. It only appears to work with theta of 0,90,180,270,360 (increments of 90°).

Anyone able to spot where I'm going wrong here?
 
Sorry? I'm not sure where your going with that. I've left out the conversions for ease of explanation. My problem is not related to them, and there would have been no value adding them to the post.

I have managed to get to this equation:
Code:
Y2 = X * Cos(t) - Y * Sin(t)
X2 = X * Sin(t) + Y * Cos(t)
It assumes your working in radians (decimal to radians conversion: t = t * Pi / 180. It only appears to work with theta of 0,90,180,270,360 (increments of 90°).



Anyone able to spot where I'm going wrong here?


Hi,


What makes you say it only works with increments of 90 degrees? It works with any angle.
Try pi/4 (45 degrees) and see that the point (4,4) rotates to lie on an axis.
 
What makes you say it only works with increments of 90 degrees? It works with any angle.
Try pi/4 (45 degrees) and see that the point (4,4) rotates to lie on an axis.

I must be doing something wrong here...


EDIT: Spotted my error
 
Last edited:
Actually, I'm still a little lost.

Lets walk through an example: Rotate the coordinate (4,4) by 45 degrees.

Find current theta
t = Atn(Y / X)
t = Atn(4,4)
t = 0.785

Find delta theta
dt = 45 * Pi / 180
dt = 0.785

Therefore, our new theta (t) = dt + t = 1.57

Working with the new theta,
Y2 = X * Cos(t) - Y * Sin(t)
Y2 = 4 * Cos(1.57) - 4 * Sin(1.57)
Y2 = 4 + 0
Y2 = 4

X2 = X * Sin(t) + Y * Cos(t)
X2 = 4 * Sin(1.57) - 4 * Cos(1.57)
X2 = 0 - 4
X2 = -4

With the above workflow, the resulting coordinate is (-4,4) but that is a 90 degree rotation. I was expecting the coordinate (0,4) for 45 degrees.
 
You should only be using dt,

Y2 = 4*cos(PI/4) - 4*sin(PI/4) = 0

X2 = 4*sin(PI/4) + 4*cos(PI/4) = 5.657

Mike.
 
Thanks Mike :)

Another thought - the radius won't decrease, it is fixed at 5.657! I'll never see the coordinate (0,4) ! Glad to get that sorted
 
Hello again,


Yes, you only use the angle of rotation, not the beginning angle too.

If you rotate the point (4,4) by 45 degrees clockwise you should get the new point (sqrt(32),0), not (0,4).
If you rotate the point (4,4) by 45 degrees counter clockwise, you should get the new point (0,sqrt(32)).
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top