How to get a point within a circle
-
Hi, does anybody know the equation fo finding a point with in a cirlce(ellipse) given the degree of the point and the diameter? Thanks!:)
This should do it: a = angle r = radius x = cos a * r y = sin a * r
-
Hi, does anybody know the equation fo finding a point with in a cirlce(ellipse) given the degree of the point and the diameter? Thanks!:)
This is not even vaguely c#, but I'll reward bad behavior anyway: For a circle: d=diameter theta = angle x = (d/2) * cos (theta) y = (d/2) * sin (theta) Elipse is more complex...best bet: use the above to find the equation of the line through the origin at angle theta, then find the intersection of the line with the ellipse. Not hard...just a little algebra (hard enough that I don't feel like doing it for you though:-D) Bill
-
Hi, does anybody know the equation fo finding a point with in a cirlce(ellipse) given the degree of the point and the diameter? Thanks!:)
Not sure if this is what you are looking for, but I'm using this to do something similar in a project currently: public static PointF CircleLineIntersect(float startX, float startY, float angle, float circRadius) { double rad =0; float xx =0; float yy=0; float nx=0; float ny=0; rad = 6.28 / 360; //offset angle. 0 deg is top center angle=angle+90; double d = Convert.ToDouble(angle * rad); xx =(float)( Math.Cos(d) * circRadius); yy =(float)( Math.Sin(d) * circRadius); nx = (float)(startX - xx); ny = (float)( startY - yy); return new PointF(nx,ny); } Cheers, Simon sig ::
"Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards
"It'll be a cold day in Hell when I do VB.NET...", Chris Maunder -
Hi, does anybody know the equation fo finding a point with in a cirlce(ellipse) given the degree of the point and the diameter? Thanks!:)
Ok, I should explain my problem, I have a piechart(circle or ellipse), and I want to find the middle point of each pie where the percentage text goes. and given the middle point degree of each pie and diameter. Example piechart[^] Can you guys come up with a solution for me please. Thanks!!
-
Ok, I should explain my problem, I have a piechart(circle or ellipse), and I want to find the middle point of each pie where the percentage text goes. and given the middle point degree of each pie and diameter. Example piechart[^] Can you guys come up with a solution for me please. Thanks!!
I'm doing something very similar and used the function I posted. Cheers, Simon sig ::
"Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards
"It'll be a cold day in Hell when I do VB.NET...", Chris Maunder -
I'm doing something very similar and used the function I posted. Cheers, Simon sig ::
"Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards
"It'll be a cold day in Hell when I do VB.NET...", Chris Maunder -
-
It's a unit conversion. Math.Sin and Math.Cos take the angle in radians, not degrees. 360 degrees = 2*pi (or ~6.28) radians.
rad
is used in the call to these methods to convert the user supplies angle (in degrees) to the right units (radians).