承接 fyre/math 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fyre/math

Composer 安装命令:

composer require fyre/math

包简介

A math utility library.

README 文档

README

FyreMath is a free, open-source math library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/math

In PHP:

use Fyre\Utility\Math;

Methods

Abs

Get the absolute value of a number.

  • $number is the input number.
$abs = Math::abs($number);

Acos

Get the arc cosine of a number.

  • $number is the input number.
$acos = Math::acos($number);

Acosh

Get the inverse hyperbolic cosine of a number.

  • $number is the input number.
$acosh = Math::acosh($number);

Asin

Get the arc sine of a number.

  • $number is the input number.
$asin = Math::asin($number);

Asinh

Get the inverse hyperbolic sine of a number.

  • $number is the input number.
$asinh = Math::asinh($number);

Atan

Get the arc tangent of a number.

  • $number is the input number.
$atan = Math::atan($number);

Atan2

Get the arc tangent of 2 numbers.

  • $x is a number representing the dividend.
  • $y is a number representing the divisor.
$atan2 = Math::atan2($x, $y);

Atanh

Get the inverse hyperbolic tangent of a number.

  • $number is the input number.
$atanh = Math::atanh($number);

Binary To Decimal

Convert a binary number to decimal.

  • $binaryString is the binary string.
$decimal = Math::binaryToDecimal($binaryString);

Ceil

Round a number up.

  • $number is the input number.
$rounded = Math::ceil($number);

Clamp

Clamp a number between a min and max.

  • $number is the input number.
  • $min is a number representing the minimum of the clamped value, and will default to 0.
  • $max is a number representing the maximum of the clamped value, and will default to 1.
$clamped = Math::clamp($number, $min, $max);

Clamp Percent

Clamp a number between 0 and 100.

  • $number is the input number.
$clamped = Math::clampPercent($number);

Convert Base

Convert a number between bases.

  • $number is the input number.
  • $fromBase is a number representing the base of the number.
  • $toBase is a number representing the base to convert to.
$newNumber = Math::convertBase($number, $fromBase, $toBase);

Cos

Get the cosine of a number.

  • $number is the input number.
$cos = Math::cos($number);

Cosh

Get the hyperbolic cosine of a number.

  • $number is the input number.
$cosh = Math::cosh($number);

Decimal To Binary

Convert a decimal number to binary.

  • $number is the input number.
$binary = Math::decimalToBinary($number);

Decimal To Hex

Convert a decimal number to hex.

  • $number is the input number.
$hex = Math::decimalToHex($number);

Decimal To Octal

Convert a decimal number to octal.

  • $number is the input number.
$octal = Math::decimalToOctal($number);

Degrees To Radians

Convert a number of degrees to radians.

  • $number is the input number.
$radians = Math::degreesToRadians($number);

Distance

Calculate the distance between 2 points.

  • $x1 is a number representing the first X co-ordinate.
  • $y1 is a number representing the first Y co-ordinate.
  • $x2 is a number representing the second X co-ordinate.
  • $y2 is a number representing the second Y co-ordinate.
$distance = Math::dist($x1, $y1, $x2, $y2);

Exp

Calculate the exponent of e.

  • $number is the input number.
$exp = Math::exp($number);

Exp Minus 1

Calculate the exponent of e-1.

  • $number is the input number.
$expMinus1 = Math::expMinus1($number);

Floor

Round a number down.

  • $number is the input number.
$rounded = Math::floor($number);

Fmod

Calculate the modulo of a number with a divisor.

  • $number is the input number.
  • $divisor is a number representing the divisor.
$modulo = Math::fmod($number, $divisor);

Hex To Decimal

Convert a hex number to decimal.

  • $hexString is the hex string.
$decimal = Math::hexToDecimal($hexString);

Hypot

Calculate the length of a point.

  • $x is a number representing the X co-ordinate.
  • $y is a number representing the Y co-ordinate.
$length = Math::hypot($x, $y);

Inverse Linear Interpolation

Inverse linear interpolation from one value to another.

  • $v1 is a number representing the minimum of the range.
  • $v2 is a number representing the maximum of the range.
  • $value is a number representing the value to inverse interpolate.
$amount = Math::inverseLerp($v1, $v2, $value);

Is Numeric

Determine if the value is numeric.

  • $value is the value to test.
$isNumeric = Math::isNumeric($value);

Linear Interpolation

Linear interpolation from one value to another.

  • $v1 is a number representing the minimum of the range.
  • $v2 is a number representing the maximum of the range.
  • $amount is a number representing the amount to interpolate.
$value = Math::lerp($v1, $v2, $amount);

Log

Calculate the logarithm.

  • $number is the input number.
  • $base is a number representing the logarithmic base, and will default to E.
$log = Math::log($number, $base);

Log 10

Calculate the base-10 logarithm.

  • $number is the input number.
$log = Math::log10($number);

Log Plus 1

Calculate the logarithm of a number + 1.

  • $number is the input number.
$log = Math::logPlus1($number);

Map

Map a value from one range to another.

  • $number is the input number.
  • $fromMin is a number representing the minimum value of the current range.
  • $fromMax is a number representing the maximum value of the current range.
  • $toMin is a number representing the minimum value of the target range.
  • $toMax is a number representing the maximum value of the target range.
$mapped = Math::map($number, $fromMin, $fromMax, $toMin, $toMax);

Max

Find the highest value.

All arguments supplied to this method will be compared.

$highest = Math::max(...$numbers);

Min

Find the lowest value.

All arguments supplied to this method will be compared.

$lowest = Math::min(...$numbers);

Octal To Decimal

Convert an octal number to decimal.

  • $octalString is the octal string.
$decimal = Math::octalToDecimal($octalString);

Pow

Raise a number to the power of exponent.

  • $number is the input number.
  • $exponent is a number representing the exponent.
$pow = Math::pow($number, $exponent);

Product

Calculate the product of values.

All arguments supplied to this method will be multiplied.

$product = Math::product(...$numbers);

Radians To Degrees

Convert a number of radians to degrees.

  • $number is the input number.
$degrees = Math::radiansToDegrees($number);

Random

Return a random floating-point number.

  • $a is a number representing the minimum value (inclusive).
  • $b is a number representing the maximum value (exclusive).
$random = Math::random($a, $b);

If $b is omitted, this function will return a random number between 0 (inclusive) and $a (exclusive).

If both arguments are omitted, this function will return a random number between 0 (inclusive) and 1 (exclusive).

Random Int

Return a random integer.

  • $a is a number representing the minimum value (inclusive).
  • $b is a number representing the maximum value (exclusive).
$randomInt = Math::randomInt($a, $b);

If $b is omitted, this function will return a random number between 0 (inclusive) and $a (exclusive).

Round

Round a number.

  • $number is the input number.
  • $precision is a number representing the number of decimal digits to use, and will default to 0.
  • $mode is a number representing the rounding mode to use, and will default to Math::ROUND_HALF_UP.
$rounded = Math::round($number, $precision, $mode);

Sin

Get the sine of a number.

  • $number is the input number.
$sin = Math::sin($number);

Sinh

Get the hyperbolic sine of a number.

  • $number is the input number.
$sinh = Math::sinh($number);

Sqrt

Get the square root of a number.

  • $number is the input number.
$sqrt = Math::sqrt($number);

Sum

Calculate the sum of values.

All arguments supplied to this method will be added.

$sum = Math::sum(...$numbers);

Tan

Get the tangent of a number.

  • $number is the input number.
$tan = Math::tan($number);

Tanh

Get the hyperbolic tangent of a number.

  • $number is the input number.
$tanh = Math::tanh($number);

To Step

Round a number to a specified step-size.

  • $number is the input number.
  • $step is a number representing the minimum step-size, and will default to 0.01.
$toStep = Math::toStep($number, $step);

fyre/math 适用场景与选型建议

fyre/math 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 05 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 fyre/math 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fyre/math 我们能提供哪些服务?
定制开发 / 二次开发

基于 fyre/math 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-29