Determing t in a Cubic Bezier equation

  • Context: Undergrad 
  • Thread starter Thread starter tabris556
  • Start date Start date
  • Tags Tags
    Cubic
Click For Summary
SUMMARY

This discussion focuses on the challenges of determining the parameter 't' in a cubic Bezier equation for animation purposes using C#. The cubic Bezier equation provided is B(t) = (1-t)^3*P0 + 3*t(1-t)^2*P1 + 3*t^2*(1-t)*P2 + t^3*P3, where control points P0, P1, P2, and P3 are defined. The user encounters discrepancies between the expected and calculated values at specific frames, particularly noting that the correct value for Frame 1 occurs at t = 0.1199 instead of the anticipated t = 0.1. The discussion highlights the need to solve for 't' based on the x-coordinate to accurately derive the corresponding y-value.

PREREQUISITES
  • Understanding of cubic Bezier curves and their mathematical representation.
  • Familiarity with C# programming for implementing animation algorithms.
  • Knowledge of solving cubic equations to find parameter values.
  • Experience with animation frame calculations and interpolation techniques.
NEXT STEPS
  • Research methods for solving cubic equations to find 't' for a given x in Bezier curves.
  • Explore the implementation of De Casteljau's algorithm for Bezier curve evaluation.
  • Learn about animation frame interpolation techniques in C#.
  • Investigate tools for visualizing Bezier curves and their control points for better understanding.
USEFUL FOR

Animators, game developers, and software engineers working with C# who need to implement and troubleshoot cubic Bezier curves in animations.

tabris556
Messages
4
Reaction score
0
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.
 
Mathematics news on Phys.org
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
    Bez.jpg
    7.2 KB · Views: 450
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
 

Similar threads

Replies
9
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
13K
  • · Replies 5 ·
Replies
5
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K