CFLib.org – Common Function Library Project

CoDistance(x1, y1, x2, y2)

Last updated July 17, 2001

author

Rob Brooks-Bilson

Version: 1 | Requires: CF5 | Library: MathLib

Description:
Calculates the distance between two sets of coordinates on the Cartesian coordinate system

Return Values:
Returns a simple value

Example:

<CFSET x1=1>
  <CFSET y1=5>
  <CFSET x2=1>
  <CFSET y2=-5>
  <CFOUTPUT>
  Given:
  <UL>
  <LI>x1,y1 = (1,5)
  <LI>x2,y2 = (1,-5)
  </UL>
  The distance between (#x1#,#y1#) and (#x2#,#y2#) = #CoDistance(x1,y1,x2,y2)#
  </CFOUTPUT>

Parameters:

Name Description Required
x1 x position of the first point Yes
y1 y position of the first point Yes
x2 x position of the second point Yes
y2 y position of the second point Yes

Full UDF Source:

/**
 * Calculates the distance between two sets of coordinates.
 * 
 * @param x1 	 x position of the first point 
 * @param y1 	 y position of the first point 
 * @param x2 	 x position of the second point 
 * @param y2 	 y position of the second point 
 * @return Returns a simple value 
 * @author Rob Brooks-Bilson (rbils@amkor.com) 
 * @version 1.0, July 17, 2001 
 */
function CoDistance(x1,y1,x2,y2)
{
  Return SQR(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
}
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