# Determing t in a Cubic Bezier equation

• tabris556
In summary, the conversation discusses a problem with cubic bezier curves in a c# program for creating and editing curves. The issue arises when trying to export data along the curve and there is a discrepancy between the values calculated in the program and those displayed on the graph. The conversation goes on to discuss a concrete example of the problem and possible solutions, including solving for t and calculating y based on that value. The conversation ends with the acknowledgement that solving for t may involve solving a cubic equation.
tabris556
Hi Everyone, so I am having a small situation with cubic bezier curves and I must be missing something. I have generated a program in c# that allows a user to create curves over time and to edit them with control points as they see fit. I have gotten to the point where I am trying to export the data along the curve and this is where I am seeing problems now.

This is for animations and so the window that an individual sees is based on frames and an FPS that the user can set. The issue that I am seeing is what my graph displays and what I am seeing in code for the values that are being calculated. I will give an example.

Lets say I set up a curve that starts at Frame 0 and goes to Frame 10. At frame one along the curve in my graph I see that the value should be at 0.5, I am just making up these values to show my point. Now when I go into my code and use the cubic bezier equation
B(t) = (1-t)^3*P0 + 3*t(1-t)^2*P1 + 3*t^2*(1-t)*P2 + t^3*P3, I am trying to solve for what B should be at each frame. I assumed I just had to take each frame and convert it from total distance to fit into 0-1. So for frame 1 I am using 0.1. When I plug the value 0.1 in I see a noticeably different value. I have done some testing and see that I get the actual value for Frame 1 when t = approximately 0.1199. This has been bugging me for some time and so I have used several different equations to verify this including the Bezier equation above and De Casteljau's equation to solve at t. I am getting the same answer for everything.

I also know that the graph is drawing correctly because the values at the end points are in the correct location.

My question to everyone is what am I missing and where does that value come from? Thank you to all.

And let me give a concrete example of what I am seeing. The start point is at (0.0, 0.0). The end point is at (10, 0.88). The first control point is (2.5, 0.0) and the second is (7.5, 0.6387501), sorry about that. So at frame 1 I plug in t =0.1. THe graph show that the value there should be between 0.025 and 0.026 and I do not see that value until t=0.1199. Thanks againl.

tabris556 said:
And let me give a concrete example of what I am seeing. The start point is at (0.0, 0.0). The end point is at (10, 0.88). The first control point is (2.5, 0.0) and the second is (7.5, 0.6387501), sorry about that. So at frame 1 I plug in t =0.1. THe graph show that the value there should be between 0.025 and 0.026 and I do not see that value until t=0.1199. Thanks againl.

If I understand your post correctly:

P0 = (0,0)
P1 = (2.5,0)
P2 = (7.5, 0.6387501)
P3 = (10. 0.88)

With those control points, for t = 0.1, x = 0.82 and y = 0.018. When you say the value should be between 0.025 and 0.026, what do you mean? Value of what?

#### Attachments

• Bez.jpg
7.2 KB · Views: 393
So I think I have been thinking about this incorrectly. Hotvette you are correct with t = 0.1, x = 0.82 and y = 0.018. What I guess I need to figure out it a way to solve for y when x=1. I have been thinking about this incorrectly and trying to not use x correctly but I need that. So how would I be able to get y or t for a given x? In my situation x is actually a frame number and so I need to figure out the y value at a given frame.

If you know x and want the value of y, I believe you need to solve for t based on the given value of x, then calculate y based on t. To find t, though, you need to solve a cubic equation.

Last edited:
Yeah I think you are right. This just got a lot more interesting for me. Thanks for the help hotvette

## 1. What is a Cubic Bezier equation?

A Cubic Bezier equation is a mathematical formula used to create smooth, curved lines in graphics and animations. It is often used in computer graphics software to draw curves and shapes.

## 2. How is t determined in a Cubic Bezier equation?

t, or the parameter, in a Cubic Bezier equation represents the position of a point along the curve. It can range from 0 to 1, with 0 being the starting point and 1 being the ending point of the curve. It is determined by the equation and can be used to calculate the coordinates of any point on the curve.

## 3. What are the four control points in a Cubic Bezier equation?

The four control points in a Cubic Bezier equation are the starting point, two anchor points, and the ending point. These points determine the shape and direction of the curve. The anchor points control the slope and curvature of the curve, while the starting and ending points control the start and end positions, respectively.

## 4. How do you use a Cubic Bezier equation to create a curve?

To create a curve using a Cubic Bezier equation, you need to provide the coordinates of the four control points and use the equation to calculate the coordinates of points along the curve. By varying the values of the control points, you can create different curves and shapes.

## 5. What are the applications of Cubic Bezier equations?

Cubic Bezier equations are commonly used in computer graphics and animation to create smooth, curved lines and shapes. They are also used in vector graphics software, such as Adobe Illustrator, to draw and manipulate curves. Additionally, they can be used in web development to create interactive and dynamic animations on websites.

• General Math
Replies
4
Views
2K
• General Math
Replies
9
Views
2K
• General Math
Replies
3
Views
1K
• General Math
Replies
10
Views
2K
• General Math
Replies
11
Views
2K
• General Math
Replies
8
Views
4K
• General Math
Replies
2
Views
2K
• General Math
Replies
6
Views
1K
• General Math
Replies
1
Views
1K
• General Math
Replies
2
Views
2K