CFLib.org – Common Function Library Project

CoMidpoint(x1, y1, x2, y2)

Last updated July 17, 2001

Version: 1 | Requires: ColdFusion 5 | Library: MathLib

 
Rated 0 time(s). Average Rating: 0

Description:
Returns the coordinates of the midpoint between two points on a line on the Cartesian coordinate system.

Return Values:
Returns a string

Example:

view plain print about
<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 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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson