Solved

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

Posted on 2005-03-15
Medium Priority
1,933 Views
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
Question by:FatNewbie
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions

LVL 23

Expert Comment

ID: 13550503
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

LVL 16

Accepted Solution

CodedK earned 500 total points
ID: 13550615
Hi...

Pythagorean theorem.

x,y are the coordinates.
OA is the radius.
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

LVL 23

Expert Comment

ID: 13550864
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

LVL 44

Expert Comment

ID: 13551205
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

LVL 86

Expert Comment

ID: 13551566
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
CAH:  Cos() = Adjacent/Hypotenuse
TOA:  Tan() = Opposite/Adjacent

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

LVL 3

Expert Comment

ID: 13555136
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

LVL 23

Expert Comment

ID: 13555455
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

LVL 86

Expert Comment

ID: 13556631
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 radius As Single
Dim angle As Single
angle = CSng(Text2.Text)

Dim x As Single
Dim y As Single

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

invalidInput:
MsgBox "Invalid Radius or Angle", vbCritical, "Bad Input"
End Sub

Private Function DegToRad(ByVal degrees As Single) As Single
DegToRad = degrees * PI / 180
End Function
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
###### Suggested Courses
Course of the Month8 days, 16 hours left to enroll

#### 764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.