OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 01 Aug 2017 18:34:57 -0500Finding a point on a circle?http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/Hey guys,
I am trying to create a code that will draw a line for every nth degree around the center point of a circle (like a clock). Does anyone know how to go about doing this?
Thanks!Wed, 09 Jul 2014 08:15:43 -0500http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/Comment by sturkmen for <p>Hey guys,</p>
<p>I am trying to create a code that will draw a line for every nth degree around the center point of a circle (like a clock). Does anyone know how to go about doing this? </p>
<p>Thanks!</p>
http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?comment=170480#post-id-170480http://harismoonamkunnu.blogspot.in/2013/05/clock-using-opencv-here-is-simple-code.htmlTue, 01 Aug 2017 18:34:57 -0500http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?comment=170480#post-id-170480Answer by Balaji R for <p>Hey guys,</p>
<p>I am trying to create a code that will draw a line for every nth degree around the center point of a circle (like a clock). Does anyone know how to go about doing this? </p>
<p>Thanks!</p>
http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?answer=36706#post-id-36706Hi @brycemh!
You can calculate a Point on a Circle as follows:
public static PointF PointOnCircle(float radius, float angleInDegrees, Point origin)
{
//radius -> Radius of Circle & Origin -> Circle Centre.
// Convert from degrees to radians via multiplication by PI/180
float x = (float)(radius * Math.Cos(angleInDegrees * Math.PI / 180F)) + origin.X;
float y = (float)(radius * Math.Sin(angleInDegrees * Math.PI / 180F)) + origin.Y;
return new PointF(x, y);
}
![image description](/upfiles/14049129025078438.png)
Wed, 09 Jul 2014 08:36:23 -0500http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?answer=36706#post-id-36706Comment by brycemh for <p>Hi <a href="/users/8049/brycemh/">@brycemh</a>!
You can calculate a Point on a Circle as follows:</p>
<pre><code>public static PointF PointOnCircle(float radius, float angleInDegrees, Point origin)
{
//radius -> Radius of Circle & Origin -> Circle Centre.
// Convert from degrees to radians via multiplication by PI/180
float x = (float)(radius * Math.Cos(angleInDegrees * Math.PI / 180F)) + origin.X;
float y = (float)(radius * Math.Sin(angleInDegrees * Math.PI / 180F)) + origin.Y;
return new PointF(x, y);
}
</code></pre>
<p><img alt="image description" src="/upfiles/14049129025078438.png"></p>
http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?comment=36893#post-id-36893@BalajiRenganathan I tried using the answer you gave, but it didn't work, it gave me a few error messages after I changed some of the values. Fri, 11 Jul 2014 06:11:57 -0500http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?comment=36893#post-id-36893Comment by brycemh for <p>Hi <a href="/users/8049/brycemh/">@brycemh</a>!
You can calculate a Point on a Circle as follows:</p>
<pre><code>public static PointF PointOnCircle(float radius, float angleInDegrees, Point origin)
{
//radius -> Radius of Circle & Origin -> Circle Centre.
// Convert from degrees to radians via multiplication by PI/180
float x = (float)(radius * Math.Cos(angleInDegrees * Math.PI / 180F)) + origin.X;
float y = (float)(radius * Math.Sin(angleInDegrees * Math.PI / 180F)) + origin.Y;
return new PointF(x, y);
}
</code></pre>
<p><img alt="image description" src="/upfiles/14049129025078438.png"></p>
http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?comment=36899#post-id-36899@BalajiRenganathan I figured it out, but I have a question; how will I use this point to create a loop that will draw a line from the center to the edge of a circle? example: I have the radius (150), the point on the circle (242.7,176.3) , and the degree (36), how can I draw a line for every 36th degree?Fri, 11 Jul 2014 06:45:27 -0500http://answers.opencv.org/question/36704/finding-a-point-on-a-circle/?comment=36899#post-id-36899