Description: The MATHF class mainly provides functions and constants for mathematical calculations, including functions needed for all mathematical calculations. So it is necessary to master the member variables and the member functions inside the MATHF class.
Use MATHF: Typically, if you use a member variable or a member function in a class, you first need to define a class object and then use the properties and functions inside the class object. However, if you use MATHF member variables and member functions, you can access them directly using the MATHF class. If you use PI, you can use Mathf.pi. The reason is that in the MATHF class, all of its member variables and member functions are public static.
Class variables:
Class Variablesclass Variables
- Value of pi (π) 3.14159265358979323846
- Infinity means positive infinity +∞
- NegativeInfinity means negative infinity-∞
- Conversion constants of Deg2rad degrees to radians.
- Rad2deg the conversion constant of radians to degrees.
- Epsilon a very small floating-point value.
Class Functionsclass Functions
- Sin calculates and returns the sinusoidal value of the angle f specified in radians.
- The Cos returns the cosine of the angle specified by the parameter F (a value between 1.0 and 1.0).
- Tan calculates and returns the tangent of the angle specified in radians.
- Asin calculates and returns the inverse chord value of the number specified in Parameter F in radians.
- Acos calculates and returns the inverse cosine of the number specified in Parameter F, in radians.
- Atan calculates and returns the inverse tangent of the number specified in Parameter F. The return value is between the pi of negative two points and the Pi of positive two.
- Atan2 calculates and returns the inverse tangent of the y/x in radians. The return value represents a diagonal angle relative to right triangle, where x is the edge length and y is the edge length.
- SQRT calculates and returns the square root of F.
- Abs calculates and returns the absolute value of the specified parameter F.
- Min Returns the smallest value in two or more values.
- Max returns the largest value in two or more values.
- The Pow calculates and returns the P-second side of F.
- EXP returns the value of the power sub-party of E.
- Log returns the logarithm of the parameter F.
- LOG10 returns the logarithm of F, with a base of 10.
- Ceil returns f Specifies the upper value of the number or expression. The upper value of the number is the nearest integer greater than or equal to the number.
- Floor returns the lower value of the number or expression specified in parameter F. The lower value is the nearest integer less than or equal to the specified number or expression.
- Round returns the floating-point number F to rounding the nearest integer.
- Ceiltoint returns the smallest integer greater than or equal to F.
- Floortoint returns the largest integer, less than or equal to F.
- Roundtoint returns the value specified by F rounded to the nearest integer.
- Sign returns the symbol F. When F is positive or 0 returns 1, negative returns-1.
- Clamp limits value between Min and Max, and returns min if value is less than min. Returns max if value is greater than max, otherwise returns value
- CLAMP01 limits value between 0 and 1 if value is less than 0 and returns 0. If value is greater than 1, returns 1, otherwise returns value.
- Lerp returns the interpolation between A and b based on the floating-point number T, which is limited to 0~1.
- Lerpangle and lerp the same principle, when they surround 360 degrees to ensure that the interpolation is correct. A and B are representative degrees.
- Movetowards change a current value closer to the target value.
- Movetowardsangle like Movetowards, but when they surround 360 degrees, make sure the interpolation is correct.
- Smoothstep and Lerp are similar, interpolated between the minimum and maximum values, and gradually fade out at the limit.
- Approximately compares two floating-point values to see if they are very close to each other.
- Smoothdamp gradually changes a value to expectations over time.
- Smoothdampangle gradually changes a given angle to the desired angle over time.
- Repeat loop value t,0 to length. The T value will never be greater than the value of length and will never be less than 0.
- Pingpong allows the value T to round-trip between 0 and length. The T value will never be greater than the value of length and will never be less than 0.
- INVERSELERP calculates the LERP parameter between two values. That is, value in the ratio between from and to.
- Ispoweroftwo returns True if the value is a power of 2.
- Nextpoweroftwo returns the power value of the next 2.
- Closestpoweroftwo returns the number of the nearest 2 from value.
- The deltaangle calculates the shortest difference between a given two corners.
Unity's MATHF class