Fit 1/4 Circle with Sanche Besel curve

Source: Internet
Author: User

Sanche Besel curve Fitting 1/4 Circle


Based on the knowledge of the Bezier curve, we know that the parametric equation of the Sanche Besel curve is as follows, where a, B, C, D are four control point coordinates, and P (t) represents each point on the curve.



Because the 1/4 circle is to be simulated, the tangent direction of P (0) and P (1) should be placed in the position shown. Where AB is in the horizontal direction, DC is vertical and segment length | ab| = | dc| = h.

So this problem is actually converted to calculate a reasonable H value, so that the radius | oj| = 1, that is, the J point is just on the arc.


According to the symmetry of the Bezier curve, it is not difficult to think of the J Point at P (0.5), substituting the formula can be obtained:


The same conclusion can be inferred directly from the geometrical characteristics of the Bezier curve, namely:




So it is also possible to reconfirm that P (0.5) and J are the same point.


Substituting four control points coordinates a (0, 1), B (H, 1), C (1, h) and D (1, 0), you can solve the P (0.5) point coordinates as follows:


According to the definition of the circular equation, the following equation can be drawn:


The value of the H is then calculated as:


Therefore, the parametric equation P (t) of the Sanche Besel curve simulation 1/4 Circle can be finally defined as follows:


On the other hand, how much difference does the equation describe between the curve and the real 1/4 circle? The following is a numerical solution for this problem.

Use T = 0.0 to 1.0, step value 0.01, to solve the difference between the distance from each point to the origin and the radius 1.

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h>double bezier3 ( Double A, double b, double C, double D, double T) {double NT = 1.0-t;double Nt2 = NT * nt;double NT3 = NT * NT * NT;DOUBL E t2 = T * t;double t3 = t * t * T;return (A * nt3 + b * 3.0 * Nt2 * t + c * 3.0 * NT * t2 + d * T3);} int main () {        Double T, a;        Double D, e;        Dou ble max_e = 0.0, min_e = 1.0;        Double X, y;        Double h = (sqrt (2)-1.0 * 4.0/3.0;        for (t = 0.0; t < 1.01; t+=0.01)         {    &NB Sp           x = Bezier3 (0, H, 1, 1, t);                y = Bezier3 (1, 1, h, 0, T);                d = sqrt (x * x + y * y);    &nbsp ;           E = d-1.0;&nbsp                a = atan2 (y, x);                A = A * 180.0/3.1415926;                if (Max_e < e) Max_e = e;                if (Min_e > E) min_e = e;              &NBS P printf ("%4.1f,%f\n", A, E);       }        printf ("max_e =%f, min_e =%f\n", MA X_e, min_e); return 0;}

The output results are as follows:

90.0, 0.00000089.1, 0.00000388.1, 0.00001087.2, 0.00002286.2, 0.00003785.3, 0.00005484.4, 0.00007383.4, 0.00009282.5, 0.00011381.6, 0.00013380.7, 0.00015379.7, 0.00017278.8, 0.00019077.9, 0.00020677.0, 0.00022176.1, 0.00023475.2, 0.00024674.3, 0.00025573.4, 0.00026372.5, 0.00026871.6, 0.00027170.7, 0.00027369.8, 0.00027268.9, 0.00026968.0, 0.00026567.1, 0.00025966.2, 0.00025165.3, 0.00024264.4, 0.00023263.5, 0.00022062.6, 0.00020861.8, 0.00019460.9, 0.00018160.0, 0.00016659.1, 0.00015258.2, 0.00013757.3, 0.00012356.5, 0.00010855.6, 0.00009454.7, 0.00008153.8, 0.00006852.9, 0.00005652.0, 0.00004551.2, 0.00003550.3, 0.00002649.4, 0.00001848.5, 0.00001247.6, 0.00000746.8, 0.00000345.9, 0.00000145.0, 0.00000044.1, 0.00000143.2, 0.00000342.4, 0.00000741.5, 0.00001240.6, 0.00001839.7, 0.00002638.8, 0.00003538.0, 0.00004537.1, 0.00005636.2, 0.00006835.3, 0.00008134.4, 0.00009433.5, 0.00010832.7, 0.00012331.8, 0.00013730.9, 0.00015230.0, 0.00016629.1, 0.00018128.2, 0.00019427.4, 0.00020826.5,0.00022025.6, 0.00023224.7, 0.00024223.8, 0.00025122.9, 0.00025922.0, 0.00026521.1, 0.00026920.2, 0.00027219.3, 0.00027318.4, 0.00027117.5, 0.00026816.6, 0.00026315.7, 0.00025514.8, 0.00024613.9, 0.00023413.0, 0.00022112.1, 0.00020611.2, 0.00019010.3, 0.000172 9.3, 0.000153 8.4, 0.000133 7.5, 0.000113 6.6, 0.000092  5.6, 0.000073 4.7, 0.000054 3.8, 0.000037 2.8, 0.000022 1.9, 0.000010 0.9, 0.000003-0.0, 0.000000max_e = 0.000273, min_e = 0.000000

From the output analysis can be seen, the error is toward the arc outer convex, 0 degrees to 45 degrees, 45 degrees to 90 degrees.

At 0 degrees, 45 degrees and 90 degrees is the minimum error 0.000000, at 19.3 degrees and 70.7 degrees to achieve the maximum error of 0.000273, basically very close to 1/4 arc.


Above, that is, the Sanche Besel curve simulates the entire contents of the 1/4 arc.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Fit 1/4 Circle with Sanche Besel curve

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.