# CFLib.org – Common Function Library Project

## isPointInCircle(pointX, pointY, circleX, circleY, circleRadius)

##### Last updated April 20, 2006

Version: 1 | Requires: CF5 | Library: MathLib

Description:
Calculates whether the point pointX,pointY lies in or on the circumfrence of the circle at centre circleX,circleY of radius circleRadius.

Return Values:
Returns a boolean.

Example:

``````<cfif isPointInCircle(10, 10, 15, 15, 5)>
<cfoutput>Point is in circle</cfoutput>
<cfelse>
<cfoutput>Point is NOT in circle.</cfoutput>
</cfif>``````

Parameters:

Name Description Required
pointX X value of point. Yes
pointY Y value of point. Yes
circleX X value of center of circle. Yes
circleY Y value of center of circle. Yes

Full UDF Source:

``````/**
* Determines if a point lies within a circle.
*
* @param pointX 	 X value of point. (Required)
* @param pointY 	 Y value of point. (Required)
* @param circleX 	 X value of center of circle. (Required)
* @param circleY 	 Y value of center of circle. (Required)
* @return Returns a boolean.
* @author Keith Westcott (kaw4@york.ac.uk)
* @version 1, April 20, 2006
*/
function isPointInCircle (pointX, pointY, circleX, circleY, circleRadius) {
var dx = (circleX - pointX);
var dy = (circleY - pointY);
return (dx * dx + dy * dy) LTE circleRadius * circleRadius;
}``````

date2ExcelDate
May 5, 2016

CapFirst
April 25, 2016