Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1957

# Calculating the coordinates of a point on the Circumference of a circle, rotation and Radius known (X and Y Unknown)

Calculating the coordinates of a point on the Circumference of a circle, rotation and Radius known (X and Y Unknown)

This question is for all those who love maths out there :P

Ok, so i don't have to go into all the workings of my mini game, i'll just tell you it with all everything strip of, to make it as understandable as possible, not that i doubt your intelligence, just my ability to type sence at 00:11

ok, there is a circle on a graph.
the center of the circle, is the Origin of the graph, eg. point 0,0.
We know the radius of the circle.
We known the angle of the line to the point (if a vertical line upwards is 0(degrees).
We need the equation for calculateing the Coordinates of a point on the circuference of the circle.

0
FatNewbie
1 Solution

Commented:
you could use the form mouse down and just use the x and y co ordinates of the form lol. Not sure if thats what your after , you prolly wanted something more complex lol
0

Commented:
Hi...

Pythagorean theorem.

x,y are the coordinates.
z is the angle of the line.

Sine(z)=X/OA            --------------> You now know x
Tangent(z)=X/Y         ---------------> You now know y

------------------------------------------------------------------
OA*OA=(x*x) +(y*y) ====> Sqrt(OA)=Sqrt(x+y)

OA known.
z known so Sine(z) known and Tangent(z) known
0

Commented:
I did pythagoras theorem with regards to right angled triangles but never did anything like that. Any chance you or some else could explain the math and how it works, if that is possible. Prolly a stupid question to ask but its not as stupid as not asking :P As I was always taught the only question that is stupid is the one you dont ask :D
0

Commented:
also, you can use (R = Radius, z= angle measured in RADIANS)

X = -R * Sin(z)
Y = R * Cos(z)

assuming the positive angle z in measured CounterClockwise.

If angle measured in Degrees, then z = Angle*Pi/180

pi = 3.1415926

most computer languages provide a built in sin and cos function, where the angles are provided in RADIANS, not degrees.

AW

0

Middle School Assistant TeacherCommented:
Gecko,

/
/ |
C  /   |  A
/     |
/       |
--------
B

So the bottom left of the triangle is at the origin of your circle.  The top point will be on the circumference of the circle so in this case C is the radius (referred to as R in AWs example).  Then angle made by B and C (referred to as Z in AWs example) is the one in question usually moving counterclockwise from the X-axis.

Remember SOHCAHTOA?

SOH:  Sin() = Opposite/Hypotenuse

If the we are sitting in the vertice made by B and C then the "opposite" side is A.  The "adjacent" side is B and of course the Hypotenuse is C.

So for a known angle Z and a known radius R we can use SOH to solve for the "opposite" side giving us the Y coordinate and then we can use CAH to solve for the "adjacent" side giving us the X coordinate.

X = Sin(z)*R
Y = Cos(z)*R

which is what AW has given already...and remembering to convert our angles from Degress to Radians if necessary.
0

Commented:
Dear FN,

I am concerned that the previous solutions might not get you in the quadrant you want to be in.   Here is a more general solution.

Suppose the radius is given as r, and the angle as theta.  If you want the point to be in the hemicircle above the x-axis, your solution is
x coordinate = r * SIN(theta)
y coordinate = r * COS(theta)

If you want the point to be in the hemicircle below the x-axis, your solution is
x coordinate = - r * SIN(theta)
y coordinate = - r * COS(theta)

If your angle is alpha, given in radians, rather than degrees, you can convert it as follows:
theta = alpha * PI / 180.0

Let me know if anything is unclear.

mathbiol
0

Commented:
Thanks Idle Mind, now that you correlated the SOHCAHTOA and Pythagoras with regards to the right angled triangle in relation to the circle question, it is clear :)

I can see clearly now the rain has gone ( Sings ) LOL J/K Anyway thanks IM :) Maybe I need a more advanced math class and correlate / intergrate that into a programming course :D
0

Middle School Assistant TeacherCommented:
Actually, the whole quadrant issue is really relative to how your coordinate system is setup and where you want to measure the angle from....

The SOHCAHTOA example I gave assumes the origin is at the center of the circle and we are using a cartesian coordiante system where positive x values are to the right of the origin and positive y values are above the origin.  So with respect to the center of the circle, the point (5,5) would be somewhere above and to the right.

In VisualBasic and Windows APIs, however, the coordinate system is NOT the same.  Here, instead of the origin being at the bottom left of our screen, it is intead at the top left.  On the screen then, positive y values would be going down from the top with positive x values still going to the right of the "origin".

If I modify my definition of where the angle is measured from then the formulas will hold true for any angle.  Instead of measuring counter-clockwise from the x-axis, we will measure counter-clockwise from the y-axis with the point on the circle directly BELOW the origin at zero degrees.  So at 45 degrees we are pointing at the bottom right of the circle and at 90 degrees we are pointing at the point directly to the right of the origin, etc...

With this in mind, here is a very simple VB app that consists of two TextBoxes and a PictureBox.  The radius (in pixels) is entered into the first box and the angle (in degrees) is entered into the second box.  When the button is pushed the circle along with a line going from the origin to the point on the circle is drawn.  (The circle is centered in the PictureBox) This correctly draws the line in the correct quadrant for any angle:

Option Explicit

Private Const PI = 3.1415926
Private originX As Single
Private originY As Single

Picture1.ScaleMode = vbPixels
originX = Picture1.ScaleWidth / 2
originY = Picture1.ScaleHeight / 2
End Sub

Private Sub Command1_Click()
On Error GoTo invalidInput

Dim angle As Single
angle = CSng(Text2.Text)

Dim x As Single
Dim y As Single

Picture1.Cls
Picture1.Line (originX, originY)-(originX + x, originY + y), vbBlack
Exit Sub

invalidInput: