Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quadratic Bezier Curve: Calculate Tangent

Tags:

bezier

I have a quadratic bezier curve and I want to calculate the slope of the tangent in a given point. For example, let it be the middlepoint of the quadratic bezier curve, therefore t=0.5 (please see the link below for a picture of this). I've calculated the first derivative of the formula for the quadratic bezier curve; however I get 400 as value for the slope, though it should be 0. Maybe I'm using the first derivative in a wrong way? I know I could also calculate the tangents using trigonometric functions; however I'd like to do it using the first derivative, shouldn't this be possible? Thanks for any hint!

For clarification / please note: I'm interested in a general way to get the slope in a arbitrary given point on a quadratic bezier curve, not only to get the tangent in the start- and end point.

A picture of my problem including the text above: http://cid-0432ee4cfe9c26a0.skydrive.live.com/self.aspx/%c3%96ffentlich/Quadratic%20Bezier%20Curve.pdf

Thank you very much for any hint!

like image 479
stefan.at.wpf Avatar asked Apr 02 '10 22:04

stefan.at.wpf


People also ask

How to calculate tangent of Bézier curve?

Bézier Curves Are Tangent to Their First and Last Legs Letting u = 0 and u = 1 gives C'(0) = n (P1 - P0) and C'(1) = n (Pn - Pn-1) The first means that the tangent vector at u = 0 is in the direction of P1 - P0 multiplied by n. Therefore, the first leg in the indicated direction is tangent to the Bézier curve.

How to Find control points of Bézier curve?

As a refresher, the formula for finding the midpoint of two points is a follows: M = (P0 + P1) / 2 . The calculation first determines the midpoint of the start point Z0 and the first control point C0, which gives us M0. It then finds the midpoint of both control points C0 and C1, which gives us M1.

What are quadratic Bezier curves?

Quadratic Bézier curves A quadratic Bézier curve is a curve created using three points. The first and the third point define the start and the end of the curve. The intermediate point influences the curvature of the line, and is most of the time not on the curve.

What is a cubic Bézier curve?

A Cubic Bezier curve is defined by four points P0, P1, P2, and P3. P0 and P3 are the start and the end of the curve and, in CSS these points are fixed as the coordinates are ratios. P0 is (0, 0) and represents the initial time and the initial state, P3 is (1, 1) and represents the final time and the final state.


1 Answers

Using your formula for B'(t), evaluated at t=1/2, we get

B'(1/2) = -P0 + P2

From the look of your graph, P0 = (0,0) and P2 = (400,0). So

B'(1/2) = (400,0).

This is the "velocity" of a point traveling along B(t) at t=1/2.

(400,0) is a horizontal vector, with magnitude 400.

So all is as it should be. Since B'(t) is horizontal, it does have "slope" 0.

like image 102
unutbu Avatar answered Sep 28 '22 05:09

unutbu