CFLib.org – Common Function Library Project

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

Last updated April 20, 2006

author

Keith Westcott

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
circleRadius Radius 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)
 * @param circleRadius 	 Radius 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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson