Attention

You are viewing PyUnity docs under the develop branch. As such, they are only applicable if you installed from source. Go to https://docs.pyunity.x10.bz/en/latest/ for the most recent release.

# pyunity.values.mathf module¶

pyunity.values.mathf.Acos(num)[source]

Returns the angle whose cosine is num. Return value is in radians.

Parameters

num (float) – Input number

pyunity.values.mathf.Asin(num)[source]

Returns the angle whose sine is num. Return value is in radians.

Parameters

num (float) – Input number

pyunity.values.mathf.Atan(num)[source]

Returns the angle whose tangent is num. Return value is in radians.

Parameters

num (float) – Input number

pyunity.values.mathf.Atan2(x, y)[source]

Returns the two-argument arctangent of x/y.

Parameters
pyunity.values.mathf.Ceil(num)[source]

Returns the smallest integer greater than or equal to num.

Parameters

num (float) – Input number

pyunity.values.mathf.Clamp(num, a, b)[source]

Returns a if num is smaller than or equal to a, b if num is greater than or equal to b, or num if it is between a and b.

Parameters
• num (float) – Input number

• a (float) – Lower bound

• b (float) – Upper bound

pyunity.values.mathf.Clamp01(num)[source]

Returns num clamped between 0 and 1.

Parameters

num (float) – Input number

pyunity.values.mathf.Cos(num)[source]

Returns the cosine of num. Must be passed in radians.

Parameters

num (float) – Input number

pyunity.values.mathf.DeltaAngle(a, b)[source]

Calculates the shortest difference between two given angles given in degrees.

Parameters
pyunity.values.mathf.Exp(num)[source]

Returns e raised to the power of num.

Parameters

num (float) – Exponent

pyunity.values.mathf.Floor(num)[source]

Returns the largest integer smaller than or equal to num.

Parameters

num (float) – Input number

pyunity.values.mathf.InverseLerp(num, a, b)[source]

Determines where num lies between two points a and b.

Parameters
• num (float) – Number to check

• a (float) – Lower bound

• b (float) – Upper bound

pyunity.values.mathf.Lerp(num, a, b)[source]

Linearly interpolates between a and b by num.

Parameters
• num (float) – Amount to interpolate by

• a (float) – Lower bound

• b (float) – Upper bound

pyunity.values.mathf.LerpUnclamped(num, a, b)[source]

Linearly interpolates between a and b by num with no limit for num.

Parameters
• num (float) – Amount to interpolate by

• a (float) – Lower bound

• b (float) – Upper bound

pyunity.values.mathf.Log(num)[source]

Returns the base 10 logarithm of num.

Parameters

num (float) – Input number

pyunity.values.mathf.Sign(num)[source]

Returns the sign of num (either -1 or 1, or 0 if num is 0).

Parameters

num (float) – Input number

pyunity.values.mathf.Sin(num)[source]

Returns the sine of num. Must be passed in radians.

Parameters

num (float) – Input number

pyunity.values.mathf.SmoothStep(num)[source]

Used in conjunction with Lerp() to smoothly interpolate between two numbers. This function takes a number between 0 and 1 and returns a number between 0 and 1, which has a steeper graph around 0.5 and a smoother graph near 0 and 1.

Parameters

num (float) – Input number (between 0 and 1)

Notes

This uses the mathematical equation f(x) = 3x^2 - 2x^3.

pyunity.values.mathf.Sqrt(num)[source]

Returns the square root of num.

Parameters

num (float) – Input number

pyunity.values.mathf.Tan(num)[source]

Returns the tangent of num. Must be passed in radians.

Parameters

num (float) – Input number

class pyunity.values.mathf.SmoothDamper[source]

Bases: object

SmoothDamp(current, target, smoothTime, dt)[source]
reset()[source]