Example #1
0
 function HyperbolicArc($p, $a, $b, $t1, $t2 = 0.0, $n, $reflectx = FALSE, $reflecty = FALSE)
 {
     if (empty($n)) {
         $n = $this->N();
     }
     if (empty($t2)) {
         $t2 = $t1;
         $t1 = -$t2;
     }
     //Circles
     if (!is_array($r)) {
         $r = array($r, $r);
     }
     $dt = ($t2 - $t1) / (1.0 * ($n - 1));
     $factx = 1.0;
     if ($reflectx) {
         $factx = -1.0;
     }
     $facty = 1.0;
     if ($reflecty) {
         $facty = -1.0;
     }
     $ps = array();
     $t = $t1;
     for ($i = 0; $i < $n; $i++) {
         array_push($ps, array($p[0] + $factx * $a * cosh($t), $p[1] + $factx * $b * sinh($t)));
         $t += $dt;
     }
     return $ps;
 }
Example #2
0
 public function inverse($p)
 {
     $x = $p->x;
     $y = $p->y;
     $L = atan(Proj4php::$common . sinh(($x - $this->xs) / $this->n2) / cos(($y - $this->ys) / $this->n2));
     $lat1 = asin(sin(($y - $this->ys) / $this->n2) / Proj4php::$common . cosh(($x - $this->xs) / $this->n2));
     $LC = Proj4php::$common . latiso(0.0, $lat1, sin($lat1));
     $p->x = $this->lc + $L / $this->rs;
     $p->y = Proj4php::$common . invlatiso($this->e, ($LC - $this->cp) / $this->rs);
     return $p;
 }
Example #3
0
function wgs2u1992($lat, $lon)
{
    //double Brad , Lrad, Lorad ,k, C, firad, Xmer, Ymer, Xgk, Ygk;
    // stale
    $E = 0.0818191910428;
    $Pi = 3.141592653589793;
    $Pi_2 = 1.570796327;
    //3.141592653589793238462643 / 2  // Pi / 2
    $Pi_4 = 0.7853981634;
    // 3.141592653589793238462643 / 4  // Pi / 4
    $Pi__180 = 0.01745329252;
    // 3.141592653589793238462643 / 180
    $Ro = 6367449.14577;
    $a2 = 0.0008377318247344;
    $a4 = 7.608527788826E-7;
    $a6 = 1.197638019173E-9;
    $a8 = 2.44337624251E-12;
    // uklad UTM
    //#define mo  0.9996   //wspo#udnik skali na po#udniku #rodkowym
    //#define Lo  (double)((((int)(lon/6)) * 6) + 3) // po#udnik #rodkowy
    // zone = (int)(lon+180/6)+1
    //#define FE  500000   //False Easting
    //#define FN  0 //False Northing
    // uklad 1992
    $mo = 0.9993;
    //wspo#udnik #rodkowy
    $Lo = 19.0;
    $FE = 500000;
    //False Easting
    $FN = -5300000;
    //False Northing
    $Brad = $lat * $Pi / 180;
    //Pi / 180;
    $Lrad = $lon * $Pi / 180;
    // Pi / 180;
    $Lorad = $Lo * $Pi / 180;
    // Pi / 180;
    //k = ((1 - E * sin(Brad)) / (1 + E * sin(Brad))) ^ (E / 2); // pasc
    //k = pow(((1 - E * sin(Brad)) / (1 + E * sin(Brad))) , (E / 2)); // c
    $k = exp($E / 2 * log((1 - $E * sin($Brad)) / (1 + $E * sin($Brad))));
    $C = $k * tan($Brad / 2 + $Pi_4);
    $firad = 2 * atan($C) - $Pi_2;
    $Xmer = atan(sin($firad) / (cos($firad) * cos($Lrad - $Lorad)));
    $Ymer = 0.5 * log((1 + cos($firad) * sin($Lrad - $Lorad)) / (1 - cos($firad) * sin($Lrad - $Lorad)));
    $Xgk = $Ro * ($Xmer + $a2 * sin(2 * $Xmer) * cosh(2 * $Ymer) + $a4 * sin(4 * $Xmer) * cosh(4 * $Ymer) + $a6 * sin(6 * $Xmer) * cosh(6 * $Ymer) + $a8 * sin(8 * $Xmer) * cosh(8 * $Ymer));
    $Ygk = $Ro * ($Ymer + $a2 * cos(2 * $Xmer) * sinh(2 * $Ymer) + $a4 * cos(4 * $Xmer) * sinh(4 * $Ymer) + $a6 * cos(6 * $Xmer) * sinh(6 * $Ymer) + $a8 * cos(8 * $Xmer) * sinh(8 * $Ymer));
    $X = $mo * $Xgk + $FN;
    $Y = $mo * $Ygk + $FE;
    return array($X, $Y);
}
Example #4
0
 /**
  * Calculates the hyperbolic tangent of a complex number: z = tanh(c1)
  *
  * @param Math_Complex $c1
  * @return Math_Complex A valid Math_Complex number on success
  * @throws InvalidArgumentException
  */
 public static function tanh(Math_Complex $c1)
 {
     if (!Math_ComplexOp::isComplex($c1)) {
         throw new InvalidArgumentException('argument is not a Math_Complex object');
     }
     $r = $c1->getReal();
     $i = $c1->getIm();
     $d = cos($i) * cos($i) + sinh($r) * sinh($r);
     return new Math_Complex(sinh($r) * cosh($r) / $d, 0.5 * sin(2 * $i) / $d);
 }
Example #5
0
if (PHP_OS != 'WINNT') {
    echo "atanh\n";
    echo atanh(-2354) . " " . atanh("foo") . " " . atanh(0) . " " . atanh(5) . atanh(1.2345) . "\n";
}
echo "atan2\n";
echo atan2(-2354, 3) . " " . atan2("foo", 12) . " " . atan2(0, 3) . " " . atan2(5, 2.3) . atan2(1.2345, 3.22) . "\n";
echo "base_convert\n";
echo base_convert("-2354", 10, 2) . " " . base_convert("foo", 10, 10) . " " . base_convert(300, 4, 20) . " " . base_convert(5, 6, 7) . " " . base_convert(5, 4, 7) . " " . base_convert(1.2345, 8, 2) . "\n";
echo "bindec\n";
echo bindec("-2354") . " " . bindec("foo") . " " . bindec(0) . " " . bindec(5) . bindec("1.2345") . "\n";
echo "ceil\n";
echo ceil(-2354) . " " . ceil("foo") . " " . ceil(0) . " " . ceil(5) . ceil(1.2345) . "\n";
echo "cos\n";
echo cos(-2354) . " " . cos("foo") . " " . cos(0) . " " . cos(5) . cos(1.2345) . "\n";
echo "cosh\n";
echo cosh(-2354) . " " . cosh("foo") . " " . cosh(0) . " " . cosh(5) . cosh(1.2345) . "\n";
echo "decbin\n";
echo decbin(2354) . " " . decbin("foo") . " " . decbin(0) . " " . decbin("5") . decbin(1.2345) . "\n";
echo "dechex\n";
echo dechex("2354") . " " . dechex("foo") . " " . dechex(0) . " " . dechex(5) . dechex(1.2345) . "\n";
echo "decoct\n";
echo decoct(2354) . " " . decoct("foo") . " " . decoct(0) . " " . decoct(5) . decoct(1.2345) . "\n";
echo "deg2rad\n";
echo deg2rad(-2354) . " " . deg2rad("foo") . " " . deg2rad(0) . " " . deg2rad(5) . deg2rad(1.2345) . "\n";
echo "exp\n";
echo exp(-2354) . " " . exp("foo") . " " . exp(0) . " " . exp(5) . exp(1.2345) . "\n";
if (PHP_OS != 'WINNT') {
    echo "expm1\n";
    echo expm1(-2354) . " " . expm1("foo") . " " . expm1(0) . " " . expm1(5) . expm1(1.2345) . "\n";
}
echo "floor\n";
/**
 * Conversion from grid coordinates to geodetic coordinates.
 *
 * http://www.lantmateriet.se/templates/LMV_Page.aspx?id=5197
 * based on: http://mellifica.se/geodesi/gausskruger.js
 * "Gauss Conformal Projection (Transverse Mercator), Krügers Formulas"
 */
function grid_to_geodetic($x, $y)
{
    global $coords;
    //Prepare ellipsoid-based stuff
    $e2 = $coords['flattening'] * (2.0 - $coords['flattening']);
    $n = $coords['flattening'] / (2.0 - $coords['flattening']);
    $a_roof = $coords['axis'] / (1.0 + $n) * (1.0 + $n * $n / 4.0 + $n * $n * $n * $n / 64.0);
    $delta1 = $n / 2.0 - 2.0 * $n * $n / 3.0 + 37.0 * $n * $n * $n / 96.0 - $n * $n * $n * $n / 360.0;
    $delta2 = $n * $n / 48.0 + $n * $n * $n / 15.0 - 437.0 * $n * $n * $n * $n / 1440.0;
    $delta3 = 17.0 * $n * $n * $n / 480.0 - 37 * $n * $n * $n * $n / 840.0;
    $delta4 = 4397.0 * $n * $n * $n * $n / 161280.0;
    $Astar = $e2 + $e2 * $e2 + $e2 * $e2 * $e2 + $e2 * $e2 * $e2 * $e2;
    $Bstar = -(7.0 * $e2 * $e2 + 17.0 * $e2 * $e2 * $e2 + 30.0 * $e2 * $e2 * $e2 * $e2) / 6.0;
    $Cstar = (224.0 * $e2 * $e2 * $e2 + 889.0 * $e2 * $e2 * $e2 * $e2) / 120.0;
    $Dstar = -(4279.0 * $e2 * $e2 * $e2 * $e2) / 1260.0;
    //Convert
    $deg_to_rad = M_PI / 180;
    $lambda_zero = $coords['central_meridian'] * $deg_to_rad;
    $xi = ($x - $coords['false_northing']) / ($coords['scale'] * $a_roof);
    $eta = ($y - $coords['false_easting']) / ($coords['scale'] * $a_roof);
    $xi_prim = $xi - $delta1 * sin(2.0 * $xi) * cosh(2.0 * $eta) - $delta2 * sin(4.0 * $xi) * cosh(4.0 * $eta) - $delta3 * sin(6.0 * $xi) * cosh(6.0 * $eta) - $delta4 * sin(8.0 * $xi) * cosh(8.0 * $eta);
    $eta_prim = $eta - $delta1 * cos(2.0 * $xi) * sinh(2.0 * $eta) - $delta2 * cos(4.0 * $xi) * sinh(4.0 * $eta) - $delta3 * cos(6.0 * $xi) * sinh(6.0 * $eta) - $delta4 * cos(8.0 * $xi) * sinh(8.0 * $eta);
    $phi_star = asin(sin($xi_prim) / cosh($eta_prim));
    $delta_lambda = atan(sinh($eta_prim) / cos($xi_prim));
    $lon_radian = $lambda_zero + $delta_lambda;
    $lat_radian = $phi_star + sin($phi_star) * cos($phi_star) * ($Astar + $Bstar * pow(sin($phi_star), 2) + $Cstar * pow(sin($phi_star), 4) + $Dstar * pow(sin($phi_star), 6));
    $lat = $lat_radian * 180.0 / M_PI;
    $lon = $lon_radian * 180.0 / M_PI;
    return array($lat, $lon);
}
Example #7
0
function sech($x)
{
    return 1 / cosh($x);
}
Example #8
0
 function tanh($f)
 {
     return sinh($f) / cosh($f);
     // ok, that one makes sense again :)
 }
Example #9
0
 /**
  * Evaluate a FunctionNode
  *
  * Computes the value of a FunctionNode `f(x)`, where f is
  * an elementary function recognized by StdMathLexer and StdMathParser.
  *
  * @see \MathParser\Lexer\StdMathLexer StdMathLexer
  * @see \MathParser\StdMathParser StdMathParser
  * @throws UnknownFunctionException if the function respresented by the
  *      FunctionNode is *not* recognized.
  *
  * @param FunctionNode $node AST to be evaluated
  * @retval float
  */
 public function visitFunctionNode(FunctionNode $node)
 {
     $inner = $node->getOperand()->accept($this);
     switch ($node->getName()) {
         // Trigonometric functions
         case 'sin':
             return sin($inner);
         case 'cos':
             return cos($inner);
         case 'tan':
             return tan($inner);
         case 'cot':
             return 1 / tan($inner);
             // Inverse trigonometric functions
         // Inverse trigonometric functions
         case 'arcsin':
             return asin($inner);
         case 'arccos':
             return acos($inner);
         case 'arctan':
             return atan($inner);
         case 'arccot':
             return pi() / 2 - atan($inner);
             // Exponentials and logarithms
         // Exponentials and logarithms
         case 'exp':
             return exp($inner);
         case 'log':
             return log($inner);
         case 'lg':
             return log10($inner);
             // Powers
         // Powers
         case 'sqrt':
             return sqrt($inner);
             // Hyperbolic functions
         // Hyperbolic functions
         case 'sinh':
             return sinh($inner);
         case 'cosh':
             return cosh($inner);
         case 'tanh':
             return tanh($inner);
         case 'coth':
             return 1 / tanh($inner);
             // Inverse hyperbolic functions
         // Inverse hyperbolic functions
         case 'arsinh':
             return asinh($inner);
         case 'arcosh':
             return acosh($inner);
         case 'artanh':
             return atanh($inner);
         case 'arcoth':
             return atanh(1 / $inner);
         default:
             throw new UnknownFunctionException($node->getName());
     }
 }
Example #10
0
 private function _coth($num)
 {
     $num = (double) $num;
     if (0 == $num) {
         return NAN;
     }
     return cosh($num) / sinh($num);
 }
Example #11
0
<?php

echo (int) (cosh(1) * 1000000);
echo abs(-1);
echo "Done.";
/**
 * @param int|float $number
 *
 * @return float
 */
function hyperbolicCosine($number)
{
    return (double) \cosh($number);
}
 /**
  * {@inheritdoc}
  */
 public function cosh($angle)
 {
     return $this->withPrecision(cosh($angle));
 }
 protected function processSech()
 {
     $operands = $this->getOperands();
     $operand = $operands[0];
     if ($operand->getValue() == 0) {
         return null;
     }
     return new Float(1 / cosh($operand->getValue()));
 }
 /**
  * Calculates the hyperbolic secant of the parameter
  * 
  * @param float $x
  * @returns mixed A floating point on success, PEAR_Error object otherwise
  * @access public
  */
 function sech($x)
 {
     /*{{{*/
     $x = floatval($x);
     $cosh = cosh($x);
     if ($cosh == 0.0) {
         return PEAR::raiseError('Undefined operation, hyperbolic cosine of parameter is zero');
     } else {
         return 1 / $cosh;
     }
 }
Example #16
0
 public function getHiperbolicCossinOf()
 {
     $this->lastOutputValue = cosh($this->calcLeftNumber);
     return $this->lastOutputValue;
 }
Example #17
0
echo ltrim("\tExample string\n", "..");
echo rtrim("\t\tThese are a few words :) ... ");
echo rtrim("\t\tThese are a few words :) ... ", " \t.");
echo rtrim("\tExample string\n", "..");
echo chop("\t\tThese are a few words :) ... ");
echo chop("\t\tThese are a few words :) ... ", " \t.");
echo chop("\tExample string\n", "..");
echo acos(0.5);
echo acosh(0.5);
echo asin(0.5);
echo asinh(0.5);
echo atan(0.5);
echo atan2(0.5, 0.5);
echo atanh(0.5);
echo cos(0.5);
echo cosh(0.5);
echo sin(0.5);
echo sinh(0.5);
echo tan(0.5);
echo tanh(0.5);
echo exp(5.7);
echo exp(12);
echo log10(12);
echo log(12);
echo sqrt(2);
echo ceil(7.9);
echo floor(7.9);
echo fmod(5.7, 1.3);
echo ip2long("127.0.0.1");
echo long2ip(pow(2, 32) + 1024);
echo rad2deg(M_PI_4);
Example #18
0
 /**
  * @return $this
  * @desc 余弦。
  */
 public function cosh()
 {
     $this->current = cosh($this->toDouble());
     return $this;
 }
Example #19
0
<?php

define("MAX_64Bit", 9223372036854775807);
define("MAX_32Bit", 2147483647);
define("MIN_64Bit", -9223372036854775807 - 1);
define("MIN_32Bit", -2147483647 - 1);
$longVals = array(MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, MAX_32Bit * 2 + 1, MAX_32Bit * 2 - 1, MAX_64Bit - 1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1);
foreach ($longVals as $longVal) {
    echo "--- testing: {$longVal} ---\n";
    var_dump(cosh($longVal));
}
?>
===DONE===
Example #20
0
	/**
	 * IMSIN
	 *
	 * Returns the sine of a complex number in x + yi or x + yj text format.
	 *
	 * Excel Function:
	 *		IMSIN(complexNumber)
	 *
	 * @param	string		$complexNumber	The complex number for which you want the sine.
	 * @return	string|float
	 */
	public static function IMSIN($complexNumber) {
		$complexNumber	= PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);

		$parsedComplex = self::_parseComplex($complexNumber);

		if ($parsedComplex['imaginary'] == 0.0) {
			return sin($parsedComplex['real']);
		} else {
			return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']);
		}
	}	//	function IMSIN()
 /**
  * @param float $x A number
  * @return float The hyperbolic cosine of the given value
  */
 public function cosh($x)
 {
     return cosh($x);
 }
 public function coshHook(&$parser, $expr = '')
 {
     try {
         $res = $this->exprParser->doExpression($expr);
     } catch (ExprError $e) {
         return $e->getMessage();
     }
     $result = cosh($res);
     return $this->check($result);
 }
Example #23
0
 /**
  * Hyperbolic cosine.
  * @link http://php.net/manual/en/function.cosh.php
  * @param float $number <p>The argument to process</p>
  * @return float The hyperbolic cosine of <i>number</i>
  */
 public static function cosh($number)
 {
     return cosh($number);
 }
Example #24
0
 /**
  * This method returns the hyperbolic cosine of this object's value.
  *
  * @access public
  * @static
  * @param IReal\Type $x                                     the operand
  * @return IDouble\Type                                     the result
  */
 public static function cosh(IReal\Type $x) : IDouble\Type
 {
     return IDouble\Type::box(cosh($x->unbox()));
 }
Example #25
0
function XPReq($iLevel)
{
    // ; k* ( ln(cosh( (n-a)/b)) - ln(cosh( -a/b )) + n/c )
    $iLevel = intval($iLevel);
    $iMultiplicateur = 10000;
    $iVeteran = 600;
    $iDifference = 60;
    $iPente = 30;
    $iStep1 = log(cosh(($iLevel - $iVeteran) / $iDifference));
    $iStep2 = log(cosh(-$iVeteran / $iDifference));
    $iStep3 = $iLevel / $iPente;
    $iStep4 = $iStep1 - $iStep2 + $iStep3;
    $iXPReq = $iMultiplicateur * $iStep4;
    return intval($iXPReq);
}
Example #26
0
 public static function cosh($self, $a)
 {
     return cosh($a);
 }
 /**
  * Returns the hyperbolic cosine of the angle.
  *
  * @param  float $angle
  * @return float
  */
 public function cosh($angle)
 {
     return (double) cosh($angle);
 }
Example #28
0
 /**
  * Cosseno hiperbólico
  * @return Number
  */
 public function cosh()
 {
     $this->num = cosh($this->num);
     return $this;
 }
Example #29
0
 /**
  * IMSIN
  *
  * Returns the sine of a complex number in x + yi or x + yj text format.
  *
  * @param	string		$complexNumber
  * @return	string
  */
 public static function IMSIN($complexNumber)
 {
     $complexNumber = self::flattenSingleValue($complexNumber);
     $parsedComplex = self::_parseComplex($complexNumber);
     if (!is_array($parsedComplex)) {
         return $parsedComplex;
     }
     if ($parsedComplex['imaginary'] == 0.0) {
         return sin($parsedComplex['real']);
     } else {
         return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']), cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']), $parsedComplex['suffix']);
     }
 }
Example #30
0
<?php

/* 
 * proto float cosh(float number)
 * Function is implemented in ext/standard/math.c
*/
//Test cosh with a different input values
$values = array(23, -23, 23.45, -23.45, 0x17, 027, "23", "23.45", "2.345e1", "nonsense", "1000", "1000ABC", null, true, false);
for ($i = 0; $i < count($values); $i++) {
    $res = cosh($values[$i]);
    var_dump($res);
}