Small white _unity engine _MATHF

Source: Internet
Author: User

Ceil

1         // value up, to a large value 2         Debug.Log (Mathf.ceil (0.1f/13         Debug.Log (Mathf.ceil (0.9f));   14         Debug.Log (Mathf.ceil (-0.1f));   05         Debug.Log (Mathf.ceil (-0.9f));   0

Floor

1         // to take a value down to a small value 2         Debug.Log (Mathf.floor (0.1f//03         Debug.Log (Mathf.floor (0.9f) ); // 0 4         Debug.Log (Mathf.floor (-0.1f)); // -1 5         Debug.Log (Mathf.floor (-0.9f)); // -1

Round rounding

1         //Rounding2Debug.Log (Mathf.round (0.1f));//03Debug.Log (Mathf.round (0.9f));//14Debug.Log (Mathf.round (-0.1f));//05Debug.Log (Mathf.round (-0.9f));//-16 7         //If you encounter 0.5, it will be different, the result looks at the previous8         ///positive even--" -0.59         ///negative number even---"+0.5Ten         ///positive number---"+0.5 One         ///negative number odd--" -0.5 ADebug.Log (Mathf.round (0.5f));//1 -Debug.Log (Mathf.round (1.5f));//2 -Debug.Log (Mathf.round (-0.5f));//0 theDebug.Log (Mathf.round (-1.5f));//-2

Camp Restrictions

1         //Camp (value, Min, max)2         //limit: Limit value between min and Max, if value is less than min, return min. 3         //if value is greater than Max, return Max, return Max, or return value4Debug.Log (Mathf.clamp ( A,Ten, -));// A5Debug.Log (Mathf.clamp (5,Ten, -));//Ten6Debug.Log (Mathf.clamp ( -,Ten, -));// -7         //limit 0-1, if less than 0 returns 0, if greater than 1 returns 1, otherwise returns value8Debug.Log (MATHF.CLAMP01 (0.1f));//0.19Debug.Log (MATHF.CLAMP01 (-0.1f));//0TenDebug.Log (MATHF.CLAMP01 (2f));//1

Interpolated values

1         //interpolated Values2         //The third parameter T: Represents a percentage, 0-1, if t= 0.5f, then the return value starts from 50%3         //1. If the third parameter is a fixed value, the return value is a fixed value that varies according to the parameter size4         //2. The third parameter must be between 0-1 if <= 0, return the first parameter value, if the parameter >= 1 returns the 2nd parameter5         //Mathf.lerp (A, B, c)6         //principle return value = (b-a) *c + A;7Debug.Log (Mathf.lerp (1, -, Time.time));8Debug.Log (Mathf.lerp (1, -,0.5f));9         //Object Uniform MotionTenObj.transform.position =NewVector3 (Mathf.lerp (0, the, Time.time),0,0); One  A         //Mathf.lerpangle (ten, time.time); -Obj.transform.eulerAngles =NewVector3 (0, Mathf.lerpangle (Ten, -, Time.time),0);

Anti-interpolation values

Small white _unity engine _MATHF

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.