Location: PHPKode > scripts > Trigonometric tools > trigonometric-tools/class.trigonometric.php
```<?php

/**

By Mohammed Cherkaoui El Maghribi (THE-PHP-LOVER)

http://dev-station.net/vb/index.php

*/

Class Math
{

var \$Sin;

var \$Cos;

var \$Tg;

var \$errors;

function SetSin(\$Sin)
{
\$this->Sin = \$Sin;
}

function SetCos(\$Cos)
{
\$this->Cos = \$Cos;
}

function SetTg(\$Tg)
{
\$this->Tg = \$Tg;
}

/* sin² + cos² = 1
sow:
sin² = 1 - cos²;
*/

private function CheckCos()
{
if(\$this->Cos > 1 || \$this->Cos < -1)
{
return false;
} else
{
return true;
}
}

function GetSinFromCos()
{
if(is_numeric(\$this->Cos)  && \$this->CheckCos())
{
return sqrt(1 - \$this->Cos * \$this->Cos);
} else
{
return false;
\$this->errors[] = 'the cos is not a numeric value';
}
}

private function CheckSin()
{
if(\$this->Sin > 1 || \$this->Sin < -1)
{
return false;
} else
{
return true;
}
}

function GetCosFromSin()
{
if(is_numeric(\$this->Sin) && \$this->CheckSin())
{
return sqrt(1 - \$this->Sin * \$this->Sin);
} else
{
return false;
\$this->errors[] = '"&#1575;&#1604;&#1587;&#1610;&#1606;" &#1594;&#1610;&#1585; &#1585;&#1602;&#1605;&#1610;';
}
}

/*
Cos²x : 1 / 1 + tg²
*/

function GetCosFromTg()
{
if(is_numeric(\$this->Tg) == false)
{
return false;
\$this->errors[] = 'tg &#1594;&#1610;&#1585; &#1585;&#1602;&#1605;&#1610;';
} else
{
return sqrt(1 / 1 + (\$this->Tg * \$this->Tg));
}
}

/*
sin²x : tg² / 1 + tg²
*/
function GetSinFromTg()
{
if(is_numeric(\$this->Tg) == false)
{
return false;
\$this->errors[] = 'tg &#1594;&#1610;&#1585; &#1585;&#1602;&#1605;&#1610;';
} else
{
return sqrt(\$this->Tg * \$this->Tg / 1 + (\$this->Tg * \$this->Tg));
}
}

function ShowErrros()
{
// print_r(\$this->errors);
foreach(\$this->errors as \$error)
{
echo \$error . '<br />';
}

}

}

?>```