# math(ロブロックス ライブラリ) > 計算のためのライブラリです。ランダムな数・切り捨て・最大最小・角度の変換などが使えます。 - URL:https://roblox.minecraft-okinawa.com/reference/libraries/math/ - 公式:https://create.roblox.com/docs/reference/engine/libraries/math ## 使用例:クリックで色が変わるパーツ (Script/置く場所:パーツの中) ```lua local part = script.Parent :: BasePart local clickDetector = Instance.new("ClickDetector") clickDetector.Parent = part clickDetector.MouseClick:Connect(function() part.Color = Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255)) end) ``` ## プロパティ - `math.e: number`:The value of Euler's number, e. - `math.huge: number`:Returns a value larger than or equal to any other numerical value (about 21024). - `math.nan: number`:A NaN value, as defined by the IEEE 754 standard. - `math.phi: number`:The value of the golden ratio. - `math.pi: number`:円周率。 - `math.sqrt2: number`:The value of the square root of 2. - `math.tau: number`:The value of tau, which is defined as 2 * math.pi. ## 関数 - `math.abs(x: number): number`:絶対値を返します。 - `math.acos(x: number): number`:Returns the arc cosine of x. - `math.asin(x: number): number`:Returns the arc sine of x. - `math.atan(x: number): number`:Returns the arc tangent of x in radians. - `math.atan2(y: number, x: number): number`:Returns the arc tangent of y/x (in radians) while using the signs of both parameters to find the quadrant of the result. - `math.ceil(x: number): int`:小数点以下を切り上げます。 - `math.clamp(x: number, min: number, max: number): number`:値を指定した範囲におさめます。 - `math.cos(x: number): number`:Returns the cosine of x, assumed to be in radians. - `math.cosh(x: number): number`:Returns the hyperbolic cosine of x. - `math.deg(x: number): number`:Returns the angle x (given in radians) in degrees. - `math.exp(x: number): number`:Returns the value e^x. - `math.floor(x: number): int`:小数点以下を切り捨てます。 - `math.fmod(x: number, y: number): number`:Returns the remainder of the division of x by y that rounds the quotient towards zero. - `math.frexp(x: number): number, int`:Returns m and e such that x = m\*2^e. - `math.isfinite(x: number): boolean`:Returns true if x is a finite number. - `math.isinf(x: number): boolean`:Returns true if x is positive or negative infinity and false otherwise. - `math.isnan(x: number): boolean`:Returns true if x is not a number (NaN) and false otherwise. - `math.ldexp(x: number, e: int): number`:Returns x\*2^e (e should be an integer). - `math.lerp(a: number, b: number, t: number): number`:Returns the linear interpolation between a and b. - `math.log(x: number, base: number): number`:Returns the logarithm of x using the given base. - `math.log10(x: number): number`:Returns the base-10 logarithm of x. - `math.map(x: number, inmin: number, inmax: number, outmin: number, outmax: number): number`:Returns the value of x mapped from one range to another. - `math.max(x: number, ...: number): number`:いちばん大きい値を返します。 - `math.min(x: number, ...: number): number`:いちばん小さい値を返します。 - `math.modf(x: number): number, number`:Returns two numbers: the integral part of x and the fractional part of x. - `math.noise(x: number, y: number, z: number): number`:Returns a Perlin noise value. - `math.pow(x: number, y: number): number`:Returns x^y. - `math.rad(x: number): number`:角度(度)をラジアンに変換します。CFrame.Anglesで使います。 - `math.random(m: number, n: number): number`:ランダムな数を返します。math.random(1, 6) で1〜6の整数。 - `math.randomseed(x: number): ()`:Sets x as the seed for the pseudo-random generator. - `math.round(x: number): number`:四捨五入します。 - `math.sign(x: number): int`:Returns -1 if x is less than 0, 0 if x equals 0, or 1 if x is greater than 0. - `math.sin(x: number): number`:Returns the sine of x, assumed to be in radians. - `math.sinh(x: number): number`:Returns the hyperbolic sine of x. - `math.sqrt(x: number): number`:平方根。 - `math.tan(x: number): number`:Returns the tangent of x, assumed to be in radians. - `math.tanh(x: number): number`:Returns the hyperbolic tangent of x. 英語の説明とメンバー一覧:Roblox Creator Documentation(CC BY 4.0)。日本語の解説はこのサイト独自のものです。 執筆:鈴木孝昌(現役プロジェクトマネージャー/プログラミング講師)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)