Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of unity Mathf mathematical operations

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Mathf mathematical operation

Absolute value of Mathf.Abs

Calculates and returns the absolute value of the specified parameter f.

Mathf.Acos inverse cosine

Static function Acos (f: float): float

Calculates and returns the inverse cosine of the number specified in parameter f in radians.

Mathf.Approximately approximation

Static function Approximately (a: float, b: float): bool

Compare two floating point values to see if they are very close. Because floating point values are not accurate, it is not recommended to compare them with equals. For example, 1. 0 percent, 1. 0 percent, 10. 0 amp. 10. 0 may not return true.

Public class example: MonoBehaviour

{

Publicvoid Awake ()

{

If (Mathf.Approximately (1.0F, 10.0F / 10.0F))

Print ("same")

}

}

Mathf.Asin arc sine

Static function Asin (f: float): float

Calculates and returns the arcsine of the number specified in parameter f in radians.

Mathf.Atan2 inverse tangent

Static function Atan2 (y: float, x: float): float

Calculates and returns the arc tangent of y _ x in radians. The return value represents the diagonal opposite to the right triangle, where x is the length of the opposite side and y is the length of the opposite side.

The return value is the angle between the x-axis and a two-dimensional vector that starts at 0 and ends at (xPowery).

Public class example: MonoBehaviour {

PublicTransform target

VoidUpdate () {

Vector3relative = transform.InverseTransformPoint (target.position)

Floatangle = Mathf.Atan2 (relative.x, relative.z) * Mathf.Rad2Deg

Transform.Rotate (0th angle, 0)

}

}

Mathf.Atan inverse tangent

Static function Atan (f: float): float

Calculates and returns the arc tangent of the number specified in parameter f. The return value is between the pi of the negative half and the pi of the positive half.

Mathf.CeilToInt minimum integer

Static function CeilToInt (f: float): int

Returns the smallest integer greater than or equal to f.

Upper limit of Mathf.Ceil

Static function Ceil (f: float): float

Returns the upper limit of the specified number or expression. The upper limit of a number is the nearest integer greater than or equal to that number.

Mathf.Clamp01 limit 0q1

Static function Clamp01 (value: float): float

Limit value to between 0J1 and return value. If value is less than 0, 0 is returned. Returns 1 if value is greater than 1, otherwise returns value.

Mathf.Clamp restriction

Static function Clamp (value: float, min: float, max: float): float

Limit the value of value to between min and max, and return min if value is less than min. Returns max if value is greater than max, otherwise returns value

Static function Clamp (value: int, min: int, max: int): int

Limit the value of value to between min and max and return value.

Mathf.ClosestPowerOfTwo 's nearest quadratic power

Static function ClosestPowerOfTwo (value: int): int

Returns the power of 2 closest to value.

Mathf.Cos cosine

Static function Cos (f: float): float

Returns the cosine of the angle specified by parameter f (a value between-1.0 and 1.0).

Mathf.Deg2Rad degrees to radians

Static var Deg2Rad: float

The conversion constant from degrees to radians. (read only)

This is equal to (PI * 2) / 360.

Mathf.Mathf.Rad2Deg Radian rotation

Static var Rad2Deg: float

The conversion constant from radians to degrees. (read only)

This equals 360 / (PI * 2).

Mathf.DeltaAngle increment angle

Static function DeltaAngle (current: float, target: float): float

Calculates the shortest difference between two given angles.

/ / Prints 90

Debug.Log (Mathf.DeltaAngle (1080 and 90))

Mathf.Epsilon small positive number

Static var Epsilon: float

A very small floating point value. (read only)

The smallest floating point value, different from 0.

The following rules:

-anyValue + Epsilon = anyValue

-anyValue-Epsilon = anyValue

-0 + Epsilon = Epsilon

-0-Epsilon =-Epsilon

A value between any number and Epsilon will result in a truncation error in any number.

Public class example: MonoBehaviour {

BoolisEqual (float a, float b) {

If (a > = b-Mathf.Epsilon & & a

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report