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 |
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;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016