In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "Unity Bezier curve implementation method". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Bezier curve of first order
A first-order Bezier curve is just a line, and we can easily find the location of t from t.
P(t)=P0+(P1-P0)*t =(1-t)*P0+ tP1; t[ 0,1] , and it is equivalent to linear interpolation.
Bezier curve of second order
Take three points in the plane that are not collinear, AB:AC=CD:CE, and BD is a straight line at this time, and linear interpolation can be performed according to the first-order Bessel equation.
P(B)=(1-t)*P0+tP1 ;
P(D)=(1-t)P1+tP2 ;
P(t)=(1-t)*P(B)+tP(D)
=(1-t)*((1-t)*P0+tP1)+t((1-t)P1+tP2 )
=(1-t)² *P0+2t*(1-t)*P1+t²*P2 ;t[0,1];
Code:
public LineRenderer line_b;public LineRenderer line_a;public LineRenderer line_c; public Transform start;public Transform end;public Transform c; void Start() { } void Update() { line_a.SetPosition(0, start.position); line_a.SetPosition(1, c.position); line_c.SetPosition(0, end.position); line_c.SetPosition(1, c.position); // float distance = Vector3.Distance(start.position, end.position); Vector3 controlPoint = c.position; //start.position + (start.position+ c.position).normalized * distance / 1.6f; Vector3[] bcList = GetBeizerPathPointList(start.position, controlPoint, end.position, 50); line_b.positionCount = bcList.Length + 1; line_b.SetPosition(0, start.position); for (int i = 0; i < bcList.Length; i++) { Vector3 v = bcList[i]; line_b.SetPosition(i + 1, v); } } public static Vector3[] GetBeizerPathPointList(Vector3 startPoint, Vector3 controlPoint, Vector3 endPoint, int pointNum) { Vector3[] BeizerPathPointList = new Vector3[pointNum]; for (int i = 1; i
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.