On 17/11/05 1:14 pm, "julian weaver" <[EMAIL PROTECTED]> wrote:

> the hypotenuse of a pair of coordinates
> e.g. [71,36] and [139,111] = 101
> 
> i want to expand the hypotenuse to 150 and update my coordinates
> accordingly.


on ScaleHypotenuse(aPoint1, aPoint2, aTarget) --------------------------
  -- INPUT: <aPoint1> and <aPoint2> should be points or two-item lists
  --         where both items are numbers
  --        <aTarget> should be a number
  -- ACTION: Calculates the hypotenuse of (distance between) the two
  --         points, then uses this to calculate a scale factor to
  --         place the points aTarget distance apart
  -- OUTPUT: Returns a property list with the format...
  --         [#width: <float>, #height: <float>]
  --         ... indicating the relative positions of the ends of a
  --         scaled line segment with the same slope as the input points
  --         or an error symbol.
  ----------------------------------------------------------------------

  if voidP(aPoint1) then
    aPoint1 =  [71,  36]
  end if

  if voidP(aPoint1) then
    aPoint2 = [139, 111]
  end if

  if ilk(aTarget, #number) then
  else
    aTarget = 150
  end if

  vWidth  = float(aPoint1[1] - aPoint1[1])
  vHeight = float(aPoint1[2] - aPoint1[2])

  vHypotenuse   = sqrt(vWidth * vWidth + vHeight * vHeight)

  if not vHypotenuse then
    return #identicalPoints
  end if

  vScale        = aTarget / vHypotenuse
  vTargetWidth  = vWidth * vScale
  vTargetHeight = vHeight * vScale

  return [#width: vTargetWidth, #height: vTargetHeight]

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[email protected]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to