CoMidpoint(x1, y1, x2, y2)
Last updated July 17, 2001
Version: 1 | Requires: ColdFusion 5 | Library: MathLib
Description:
Returns the coordinates of the midpoint between two points on a line on the Cartesian coordinate system.
Return Values:
Returns a string
Example:
<CFSET y1=5>
<CFSET x2=1>
<CFSET y2=-5>
<CFOUTPUT>
Given:
<UL>
<LI>x1,y1 = (1,5)
<LI>x2,y2 = (1,-5)
</UL>
The midpoint between (#x1#,#y1#) and (#x2#,#y2#) = (#CoMidpoint(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:
<cfscript>
/**
* Returns the coordinates of the midpoint between two points on a line.
*
* @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 string
* @author Rob Brooks-Bilson (rbils@amkor.com)
* @version 1.0, July 17, 2001
*/
function CoMidpoint(x1,y1,x2,y2)
{
Return (x1+x2)/2 & ',' & (y1+y2)/2;
}
</cfscript>
Search CFLib.org
Latest Additions
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)