From:
Operating system: Windows XP
PHP version: 5.3.3
Package: Math related
Bug Type: Feature/Change Request
Bug description:Extend hypot() to three dimensions
Description:
------------
The existing hypot() function is limited to finding the hypotenuse of a
right-angled triangle in two dimensions ($h = hypot($x,$y)), when in fact
it is well-defined for higher dimensions as well as the length of the
diagonal of a (hyper)cuboid with edge lengths $x,$y,$z...; it's the square
root of the sum of the squares of the edge lengths.
For geometric purposes it would be helpful to have at least
hypot($x,$y,$z). The existing alternatives are sqrt($x*$x+$y*$y+$z*$z) or
hypot(hypot($x,$y),$z). The latter is (not surprisingly) markedly slower,
and also less accurate.
Test script:
---------------
function length($v1, $v2)
{
return hypot($v1[0]-$v2[0], $v1[1]-$v2[1], $v1[2]-$v2[2]);
}
$v1 = array(1, 1, 1);
$v2 = array(5, 6, 1);
echo length($v1, $v2);
Expected result:
----------------
6.4031242374328
Actual result:
--------------
A warning about hypot expecting exactly two parameters, and a NULL return
value.
--
Edit bug report at http://bugs.php.net/bug.php?id=52734&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52734&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52734&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52734&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52734&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52734&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52734&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52734&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52734&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52734&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52734&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52734&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52734&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52734&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52734&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52734&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52734&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52734&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52734&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52734&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52734&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52734&r=mysqlcfg