# Circumference Points

In Category GeometryArticle published 29/09/2009 10:44:56pm

**Circumference Points**

Finding and plotting points on the circumference of a circle: This article explains how to write a simple function that provides cartesian co-ordinates for a point based on a circles centre co-ordinates, its radius, and the degree of rotation.

Finding a point on the circumference of a circle can be a pleasantly easy affair. To find any point, we will need the following information:

- The co-ordinates of the centre of the circle (
*nXpos,nYpos*) - The radius of the circle (
*nRadius*), and - The offset of the point, in degrees of rotation (
*dDegrees*)

*dDegrees*= (

*dDegrees*- 90 ) % 360;

*x,y*co-ordinates of the point we want using

*sine*and

*cosine*:

*x*=

*nRadius*x cos(

*dDegrees*x π / 180 );

*y*=

*nRadius*x sin(

*dDegrees*x π / 180 );

**Easy!**A quick example of this function written in Javascript would work as follows:

function GetPoint(nRadius,dDegrees,nXpos,nYpos) {

dDegrees = (dDegrees-90)%360; // Account for 90.deg. offset

x = nRadius*Math.cos(dDegrees*Math.PI/180);

y = nRadius*Math.sin(dDegrees*Math.PI/180);

x = Math.round(x);

y = Math.round(y);

return Array((x+nXpos),(y+nYpos));

}

dDegrees = (dDegrees-90)%360; // Account for 90.deg. offset

x = nRadius*Math.cos(dDegrees*Math.PI/180);

y = nRadius*Math.sin(dDegrees*Math.PI/180);

x = Math.round(x);

y = Math.round(y);

return Array((x+nXpos),(y+nYpos));

}