{"id":21467450,"url":"https://github.com/elusivecodes/fyremath","last_synced_at":"2025-07-15T05:31:32.405Z","repository":{"id":62508431,"uuid":"371942175","full_name":"elusivecodes/FyreMath","owner":"elusivecodes","description":"FyreMath is a free, open-source math library for PHP.","archived":false,"fork":false,"pushed_at":"2024-06-29T01:42:23.000Z","size":118,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-01T09:46:09.454Z","etag":null,"topics":["math","number","php","utility"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elusivecodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-29T10:22:12.000Z","updated_at":"2024-06-29T01:42:14.000Z","dependencies_parsed_at":"2024-06-29T02:39:38.803Z","dependency_job_id":"55ab3ac5-94bd-4ad5-acef-92d369a1625b","html_url":"https://github.com/elusivecodes/FyreMath","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreMath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreMath/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017602,"owners_count":17560544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["math","number","php","utility"],"created_at":"2024-11-23T08:18:08.256Z","updated_at":"2024-11-23T08:18:10.076Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreMath\r\n\r\n**FyreMath** is a free, open-source math library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Methods](#methods)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/math\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Utility\\Math;\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Abs**\r\n\r\nGet the absolute value of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$abs = Math::abs($number);\r\n```\r\n\r\n**Acos**\r\n\r\nGet the arc cosine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$acos = Math::acos($number);\r\n```\r\n\r\n**Acosh**\r\n\r\nGet the inverse hyperbolic cosine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$acosh = Math::acosh($number);\r\n```\r\n\r\n**Asin**\r\n\r\nGet the arc sine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$asin = Math::asin($number);\r\n```\r\n\r\n**Asinh**\r\n\r\nGet the inverse hyperbolic sine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$asinh = Math::asinh($number);\r\n```\r\n\r\n**Atan**\r\n\r\nGet the arc tangent of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$atan = Math::atan($number);\r\n```\r\n\r\n**Atan2**\r\n\r\nGet the arc tangent of 2 numbers.\r\n\r\n- `$x` is a number representing the dividend.\r\n- `$y` is a number representing the divisor.\r\n\r\n```php\r\n$atan2 = Math::atan2($x, $y);\r\n```\r\n\r\n**Atanh**\r\n\r\nGet the inverse hyperbolic tangent of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$atanh = Math::atanh($number);\r\n```\r\n\r\n**Binary To Decimal**\r\n\r\nConvert a binary number to decimal.\r\n\r\n- `$binaryString` is the binary string.\r\n\r\n```php\r\n$decimal = Math::binaryToDecimal($binaryString);\r\n```\r\n\r\n**Ceil**\r\n\r\nRound a number up.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$rounded = Math::ceil($number);\r\n```\r\n\r\n**Clamp**\r\n\r\nClamp a number between a min and max.\r\n\r\n- `$number` is the input number.\r\n- `$min` is a number representing the minimum of the clamped value, and will default to *0*.\r\n- `$max` is a number representing the maximum of the clamped value, and will default to *1*.\r\n\r\n```php\r\n$clamped = Math::clamp($number, $min, $max);\r\n```\r\n\r\n**Clamp Percent**\r\n\r\nClamp a number between 0 and 100.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$clamped = Math::clampPercent($number);\r\n```\r\n\r\n**Convert Base**\r\n\r\nConvert a number between bases.\r\n\r\n- `$number` is the input number.\r\n- `$fromBase` is a number representing the base of the number.\r\n- `$toBase` is a number representing the base to convert to.\r\n\r\n```php\r\n$newNumber = Math::convertBase($number, $fromBase, $toBase);\r\n```\r\n\r\n**Cos**\r\n\r\nGet the cosine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$cos = Math::cos($number);\r\n```\r\n\r\n**Cosh**\r\n\r\nGet the hyperbolic cosine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$cosh = Math::cosh($number);\r\n```\r\n\r\n**Decimal To Binary**\r\n\r\nConvert a decimal number to binary.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$binary = Math::decimalToBinary($number);\r\n```\r\n\r\n**Decimal To Hex**\r\n\r\nConvert a decimal number to hex.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$hex = Math::decimalToHex($number);\r\n```\r\n\r\n**Decimal To Octal**\r\n\r\nConvert a decimal number to octal.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$octal = Math::decimalToOctal($number);\r\n```\r\n\r\n**Degrees To Radians**\r\n\r\nConvert a number of degrees to radians.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$radians = Math::degreesToRadians($number);\r\n```\r\n\r\n**Distance**\r\n\r\nCalculate the distance between 2 points.\r\n\r\n- `$x1` is a number representing the first X co-ordinate.\r\n- `$y1` is a number representing the first Y co-ordinate.\r\n- `$x2` is a number representing the second X co-ordinate.\r\n- `$y2` is a number representing the second Y co-ordinate.\r\n\r\n```php\r\n$distance = Math::dist($x1, $y1, $x2, $y2);\r\n```\r\n\r\n**Exp**\r\n\r\nCalculate the exponent of `e`.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$exp = Math::exp($number);\r\n```\r\n\r\n**Exp Minus 1**\r\n\r\nCalculate the exponent of `e-1`.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$expMinus1 = Math::expMinus1($number);\r\n```\r\n\r\n**Floor**\r\n\r\nRound a number down.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$rounded = Math::floor($number);\r\n```\r\n\r\n**Fmod**\r\n\r\nCalculate the modulo of a number with a divisor.\r\n\r\n- `$number` is the input number.\r\n- `$divisor` is a number representing the divisor.\r\n\r\n```php\r\n$modulo = Math::fmod($number, $divisor);\r\n```\r\n\r\n**Hex To Decimal**\r\n\r\nConvert a hex number to decimal.\r\n\r\n- `$hexString` is the hex string.\r\n\r\n```php\r\n$decimal = Math::hexToDecimal($hexString);\r\n```\r\n\r\n**Hypot**\r\n\r\nCalculate the length of a point.\r\n\r\n- `$x` is a number representing the X co-ordinate.\r\n- `$y` is a number representing the Y co-ordinate.\r\n\r\n```php\r\n$length = Math::hypot($x, $y);\r\n```\r\n\r\n**Inverse Linear Interpolation**\r\n\r\nInverse linear interpolation from one value to another.\r\n\r\n- `$v1` is a number representing the minimum of the range.\r\n- `$v2` is a number representing the maximum of the range.\r\n- `$value` is a number representing the value to inverse interpolate.\r\n\r\n```php\r\n$amount = Math::inverseLerp($v1, $v2, $value);\r\n```\r\n\r\n**Is Numeric**\r\n\r\nDetermine if the value is numeric.\r\n\r\n- `$value` is the value to test.\r\n\r\n```php\r\n$isNumeric = Math::isNumeric($value);\r\n```\r\n\r\n**Linear Interpolation**\r\n\r\nLinear interpolation from one value to another.\r\n\r\n- `$v1` is a number representing the minimum of the range.\r\n- `$v2` is a number representing the maximum of the range.\r\n- `$amount` is a number representing the amount to interpolate.\r\n\r\n```php\r\n$value = Math::lerp($v1, $v2, $amount);\r\n```\r\n\r\n**Log**\r\n\r\nCalculate the logarithm.\r\n\r\n- `$number` is the input number.\r\n- `$base` is a number representing the logarithmic base, and will default to *E*.\r\n\r\n```php\r\n$log = Math::log($number, $base);\r\n```\r\n\r\n**Log 10**\r\n\r\nCalculate the base-10 logarithm.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$log = Math::log10($number);\r\n```\r\n\r\n**Log Plus 1**\r\n\r\nCalculate the logarithm of a number + 1.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$log = Math::logPlus1($number);\r\n```\r\n\r\n**Map**\r\n\r\nMap a value from one range to another.\r\n\r\n- `$number` is the input number.\r\n- `$fromMin` is a number representing the minimum value of the current range.\r\n- `$fromMax` is a number representing the maximum value of the current range.\r\n- `$toMin` is a number representing the minimum value of the target range.\r\n- `$toMax` is a number representing the maximum value of the target range.\r\n\r\n```php\r\n$mapped = Math::map($number, $fromMin, $fromMax, $toMin, $toMax);\r\n```\r\n\r\n**Max**\r\n\r\nFind the highest value.\r\n\r\nAll arguments supplied to this method will be compared.\r\n\r\n```php\r\n$highest = Math::max(...$numbers);\r\n```\r\n\r\n**Min**\r\n\r\nFind the lowest value.\r\n\r\nAll arguments supplied to this method will be compared.\r\n\r\n```php\r\n$lowest = Math::min(...$numbers);\r\n```\r\n\r\n**Octal To Decimal**\r\n\r\nConvert an octal number to decimal.\r\n\r\n- `$octalString` is the octal string.\r\n\r\n```php\r\n$decimal = Math::octalToDecimal($octalString);\r\n```\r\n\r\n**Pow**\r\n\r\nRaise a number to the power of exponent.\r\n\r\n- `$number` is the input number.\r\n- `$exponent` is a number representing the exponent.\r\n\r\n```php\r\n$pow = Math::pow($number, $exponent);\r\n```\r\n\r\n**Product**\r\n\r\nCalculate the product of values.\r\n\r\nAll arguments supplied to this method will be multiplied.\r\n\r\n```php\r\n$product = Math::product(...$numbers);\r\n```\r\n\r\n**Radians To Degrees**\r\n\r\nConvert a number of radians to degrees.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$degrees = Math::radiansToDegrees($number);\r\n```\r\n\r\n**Random**\r\n\r\nReturn a random floating-point number.\r\n\r\n- `$a` is a number representing the minimum value (inclusive).\r\n- `$b` is a number representing the maximum value (exclusive).\r\n\r\n```php\r\n$random = Math::random($a, $b);\r\n```\r\n\r\nIf `$b` is omitted, this function will return a random number between 0 (inclusive) and `$a` (exclusive).\r\n\r\nIf both arguments are omitted, this function will return a random number between 0 (inclusive) and 1 (exclusive).\r\n\r\n**Random Int**\r\n\r\nReturn a random integer.\r\n\r\n- `$a` is a number representing the minimum value (inclusive).\r\n- `$b` is a number representing the maximum value (exclusive).\r\n\r\n```php\r\n$randomInt = Math::randomInt($a, $b);\r\n```\r\n\r\nIf `$b` is omitted, this function will return a random number between 0 (inclusive) and `$a` (exclusive).\r\n\r\n**Round**\r\n\r\nRound a number.\r\n\r\n- `$number` is the input number.\r\n- `$precision` is a number representing the number of decimal digits to use, and will default to *0*.\r\n- `$mode` is a number representing the rounding mode to use, and will default to *Math::ROUND_HALF_UP*.\r\n\r\n```php\r\n$rounded = Math::round($number, $precision, $mode);\r\n```\r\n\r\n**Sin**\r\n\r\nGet the sine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$sin = Math::sin($number);\r\n```\r\n\r\n**Sinh**\r\n\r\nGet the hyperbolic sine of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$sinh = Math::sinh($number);\r\n```\r\n\r\n**Sqrt**\r\n\r\nGet the square root of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$sqrt = Math::sqrt($number);\r\n```\r\n\r\n**Sum**\r\n\r\nCalculate the sum of values.\r\n\r\nAll arguments supplied to this method will be added.\r\n\r\n```php\r\n$sum = Math::sum(...$numbers);\r\n```\r\n\r\n**Tan**\r\n\r\nGet the tangent of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$tan = Math::tan($number);\r\n```\r\n\r\n**Tanh**\r\n\r\nGet the hyperbolic tangent of a number.\r\n\r\n- `$number` is the input number.\r\n\r\n```php\r\n$tanh = Math::tanh($number);\r\n```\r\n\r\n**To Step**\r\n\r\nRound a number to a specified step-size.\r\n\r\n- `$number` is the input number.\r\n- `$step` is a number representing the minimum step-size, and will default to *0.01*.\r\n\r\n```php\r\n$toStep = Math::toStep($number, $step);\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyremath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyremath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyremath/lists"}