Fengbin: JavaFX Instance (14) "Cubicbeziercurve"

Source: Internet
Author: User

This example shows a three-cubic Bezier curve,in theMathematicalof theNumerical analysisfield,Bezier Curve(English:Bézier curve ) isComputer graphic Scienceis of considerable importance inParametric curve. More HighDimension ofthe extensive Bezier curve is calledBezier surfaces, whereBezier Triangleis a special kind of example. The following are examples of Bezier curves:

linear Bezier Curve

Given the point p0,p1, the linear Bezier curve is just a straight line between two points. This line is given by the following formula:

    • 650) this.width=650; "Class=" Mwe-math-fallback-image-inline Tex "alt=" \mathbf{b} (T) =\mathbf{p}_0 + (\mathbf{P}_1-\ MATHBF{P}_0) t= (1-t) \mathbf{p}_0 + t\mathbf{p}_1 \mbox{,} t \in [0,1] "src=" http://upload.wikimedia.org/math/0/5/c/ 05c4210c69ffb1358ceb8eb83a1a06fe.png "style=" border:none;vertical-align:middle; "/>

And it is equivalent to linear interpolation.

two cubic Bezier curve

The path of the quadratic Bezier curve is traced by thefunction B(t) of the given point P 0, p 1, andP2:

    • 650) this.width=650; "Class=" Mwe-math-fallback-image-inline Tex "alt=" \mathbf{b} (t) = (1-T) ^{2}\mathbf{p}_0 + 2t (1-T) \ Mathbf{p}_1 + t^{2}\mathbf{p}_2 \mbox{,} t \in [0,1] "src=" http://upload.wikimedia.org/math/8/a/d/ 8adc5cc34ea9649d6e546043fce9c407.png "style=" border:none;vertical-align:middle; "/>.

The TrueType font uses two Bezier curves that are made of Bézier splines.


Three cubic Bezier curve

P0, P P 2, P 34 points in a planar or three-dimensional space define a three-cubic Bezier curve. The curve starts at P 0 toward P 1, and from P 2 's direction came to P 3. Generally do not go through p 1 or P P 0 and P P 3, go to P 2 direction "length how long".

The parameter form of the curve is:

    • 650) this.width=650; "Class=" Mwe-math-fallback-image-inline Tex "alt=" \mathbf{b} (t) =\mathbf{p}_0 (1-T) ^3+3\mathbf{P }_1T (1-t) ^2+3\mathbf{p}_2t^2 (1-t) +\mathbf{p}_3t^3 \mbox{,} t \in [0,1] "src=" HTTP://UPLOAD.WIKIMEDIA.ORG/MATH/5/9/7 /597ecc5022fa7ab65509d5edfa9c148c.png "style=" border:none;vertical-align:middle; "/>


The code for this example is as follows:

Import javafx.application.application;import javafx.scene.scene;import javafx.scene.layout.pane ; import javafx.scene.paint.color;import javafx.stage.stage;import javafx.scene.shape.*;p Ublic  class cubicbeziercurve extends application {  public void start ( Stage primarystage)  {    pane pane = new pane ();        cubiccurve cubiccurve = new cubiccurve ()  ;     cubiccurve.setstartx (    cubiccurve.setstarty);                                    CUBICCURVE.SETCONTROLX1 (; )    cubiccurve.setcontroly1 ( -25);              &nbsP;         CUBICCURVE.SETCONTROLX2 (;    ) Cubiccurve.setcontroly2 (175);                     cubiccurve.setendx (    cubiccurve.setendy); )  ;                                   Cubiccurve.setstroke (Color.Black);      cubiccurve.setstrokewidth (3);      cubiccurve.setfill (Color.White);     pane.getchildren (). Add (CubicCurve);     scene scene =new scene (pane,200,150);     Primarystage.settitle ("Cubicbeziercurve");     primarystage.setscene (Scene);     primarystage.show ();     }} 


The operation results are as follows

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/92/wKioL1RrS3uy26-TAABAfSaHW2w862.jpg "title=" Qq20141118210204.jpg "alt=" Wkiol1rrs3uy26-taabafsahw2w862.jpg "/>

This article is from the "Fengbin Technology blog" blog, make sure to keep this source http://fengbin8606.blog.51cto.com/8840305/1579316

Fengbin: JavaFX Instance (14) "Cubicbeziercurve"

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.