Skip to main content
gamedev.net
🔒 Locked

Plotting Polar Coordinates

Started by luridcortex Oct 17, 2003 at 9:34 PM 7 replies 500+ views
Original Post
luridcortex
luridcortex
Whats up Ive been reading about polar coordinates in lamothes 3D tricks book and dont understand how to plot them. I get the conversions and all, they are simple equations. But plotting them is relatively glossed over, and i checked a bunch of other online sources as well. No one seems to cover how to plot a polar coordinate. I guess its sposed to be trivial ;P Anyway, ehre is what i make of it: youve got a point p(r,O) r - the distance from the origin. How is it measured, you draw a ray from the pole, but how do you know which quadrant? And is dist mesaure on the y or x axis? O - and the angle of course. this i have no idea what to do with? to you draw the angle and where it intersects the ray is your point? lol, so by now you should be able to tell i completely dont understand this at all ;P please help
Deyja
Deyja
Google for ''polar coordinates''.

You have completly mis-interpreted the meaning ''Radius'' and ''Theta''. Do you understand vectors? Theta is the angle of the vector from the x-axis, and radius is the magnitude of the vector. Regular cartesian coordinates? Place a point at (Radius,Zero). Rotate it theta degrees around the origin.
luridcortex
luridcortex
I think i may be beginning to see the light ;P

If youve got a polar coordinate such as p(10, 30*) to plot it you would:

1. Move 10 on the x axis.
2. Rotate 30* counterclockwise until you intersect a ray from the origin (or pole).

is this correct?
Pseudo
Pseudo
technically when using polar coordinates, you dont have an x or a y axis, so it''s sorta misleading to say that theta is the angle from the x axis.

so, in conclusion, Theta is the angle that a line from the point to the origin would make with some reference point. (which is sometimes where the x-axis WOULD be in cartasian (sp?) space, but not always...boat headings for example are clockwise from what WOULD be the y-axis)

r is just the distance from that point to the origin.
Deyja
Deyja
x = cos(theta)*radius
y = sin(theta)*radius

This will, unfortunatly, not always give you the correct quadrant.

in degrees:


if (theta > 90 && theta < 270) x = -x
if (theta > 180) y = -y
ivquatch
ivquatch
Yup,

Once you get the hang of plotting polar coordinates, you can check your work by converting to cartesian coords using these equations.

x = r*cos(theta)
y = r*sin(theta)

Practice plotting the point [root(2),45] (where the radius is root(2) and the angle is 45) in polar coordinates on a piece of graph paper with a compass. You can check your plot by converting the point to cartesian coords like this:

x = root(2) * cos(45) = 1
y = root(2) * cos(45) = 1



Atheist
Atheist
Skip the "does not give you the correct quadrant" and the c-code and above is correct. Also I don´t really understand what pseudo meant by "you don´t have an x- and y-axis" because you need an axis to which your angle refers and a direction it initially increases.

So as mentioned in the previous post:
x = cos(angle)*radius
y = sin(angle)*radius

you can derive that quite easily for yourself which is what I´d advice you to do if you want to understand it:

Draw a orthonormal coordinate system. Take any point P=(x,y)(preferrably in the 1st quadrant since that´s easiest to see). Draw the connecting line from the origin to that point. Draw the angle a from the positive x-axis to that line. Think of how you´d calculate x and y from radius r and angle a and maybe how to get (r,a) from (x,y).
If you still don´t know how to get above equations you´re probably missing the geometrical definitions of sin and cos that are:
sin(a) = y/r
cos(a) = x/r
(note that you can draw a rectangular triangle with the points (0,0), (x, 0) and (x,y)).

Uh, and rereading your initial post:
the distance r is the distance from the origin. The question how to draw your ray is not only a question of "which quadrant?" but more precisely "which direction?". This is the information that is stored in the angle.
Scheermesje
Scheermesje
quote:
Original post by Atheist
Skip the "does not give you the correct quadrant" and the c-code and above is correct. Also I don´t really understand what pseudo meant by "you don´t have an x- and y-axis" because you need an axis to which your angle refers and a direction it initially increases.



He meant that you''re using polar coordinates, not cartesian. In cartesian you''ve got x and y axes. So he is correct by saying you don''t have an x axis in polar coordinates although it is useful to draw one so you have a point rotate your angle around


luridcortex: go to page 246 of your book Look at the page on top of that page and there is your answer.. P1(10,30) 10 is the distance from (0,0) and you rotated 30 degrees from the x axis.

P2(6,150) means rotate 150 degrees and travell 6 points along the line to your point.

On page 247 he''s explaining how to convert them to normal cartesian coordinates, it''s not that difficult Just draw it out for yourself instead of looking at the page and wondering where he''s talking about

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.