How can I use Bezier curves to plot points in relative space?

  • Thread starter PerlTrader
  • Start date
  • Tags
    Plotting
In summary: Your Name]In summary, a forum user is seeking help with using Bezier curves in their Perl application for currency trading data. They have questions about using the same initialization values for both X and Y stepping, the structure of finding X and Y with the parameter t, and how to calculate specific values from X = 50 in Octant 0 and Y = 40 in Octant 1. They are looking for solutions that can be implemented in Perl code.
  • #1
PerlTrader
1
0

Hello math gurus,

I'm using Bezier curves in my Perl application to chart currency trading data.
Having no formal math training, I've framed my questions in a modeling context.
I want to step along the major axis (on integer boundaries), and calculate real
values on the minor axis. I'm plotting in relative space, like PostScript's
"rcurveto" function. The example code fragments are in (pseudo) Perl with
scalar($) and termination(;) characters removed.

Control Points:
x1 = 70 y1 = 0
x2 = 100 y2 = 20
3 = 100 y3 = 50

Initialize Curve:
cX = (3 * x1)
cY = (3 * y1)
bX = ((3 * (x2 - x1)) - cX)
bY = ((3 * (y2 - y1)) - cY)
aX = (x3 - cX - bX)
aY = (y3 - cY - bY)

Plot Point:
t1 = t t2 = (t1 * t1) t3 = (t1 * t2)
pX = ((aX * $t3) + (bX * $t2) + ($cX * t1))
pY = ((aY * $t3) + (bY * $t2) + ($cY * t1))

Octant Change:
T: 0.65429213786 X: 88.830577627 Y: 22.884879224

Octant 0 Point:
T: 0.28268189551 X: 50.000000000 Y: 4.568654814

Octant 1 Point:
T: 0.88425060334 X: 98.778678931 Y: 40.000000000

In Octant 0, I want to use X integers (0 to 88) to find t (e.g. 0.28268189551
from 50) to generate Y reals (e.g. 4.568654814 from 0.28268189551). In Octant 1,
I want to use Y integers (23 to 50) to find t (e.g. 0.88425060334 from 40) to
generate X reals (e.g. 98.778678931 from 0.88425060334).

My three part question is:

1) Can the (aX, bX, cX, aY, bY, cY) initialization values be used in the solution,
or will separate initialization values be required for X stepping and Y stepping.

2) Are the X and Y stepping solutions (that find t) similar to the structure of
finding X and Y with t?

Find t with x: t1 = pX ... process ...
Find y with t: ((aY * $t3) + (bY * $t2) + ($cY * t1))

3) How will the solution calculate the following values from X = 50 in Octant 0
and Y = 40 in Octant 1:

T: 0.28268189551 X: 50.000000000 Y: 4.568654814

The only way I'll be able to understand a solution is if I can plug it into some
Perl code. Explanations in pseudo code or C fragments should also work.

Thanks (in advance, for anyone willing to help me with this).
 
Last edited:
Physics news on Phys.org
  • #2




Thank you for reaching out with your questions about using Bezier curves in your Perl application. As a scientist with a background in mathematics, I would be happy to help you find solutions for your modeling needs.

Firstly, regarding your question about using the same initialization values for both X and Y stepping, the short answer is yes. The same values for (aX, bX, cX, aY, bY, cY) can be used for both solutions. The key is to understand that the Bezier curve is a parametric curve, meaning that the coordinates (X,Y) are defined in terms of a parameter t. So as long as you are using the same parameter t in both solutions, the initialization values will work for both X and Y stepping.

Secondly, the structure of finding X and Y with t is indeed similar. In both cases, you are using the same formula to calculate the coordinate (pX, pY) from the parameter t. The only difference is that in one case, you are solving for the X coordinate and in the other case, you are solving for the Y coordinate. So as long as you use the same parameter t for both solutions, the structure will be the same.

Finally, to calculate the values T, X, and Y from X = 50 in Octant 0 and Y = 40 in Octant 1, you can follow the same steps outlined in your example code. The only difference is that you will be solving for the parameter t instead of the coordinates (pX, pY). Once you have the value of t, you can then plug it into the formula for pX and pY to get the desired values.

I hope this helps clarify your questions and aids in your modeling process. Please let me know if you have any further questions or if you need any assistance with implementing these solutions in your Perl code.
 
  • #3


Bezier curves are a powerful tool for creating smooth and precise curves in computer graphics and modeling. They are defined by a set of control points and a mathematical formula that calculates the position of points along the curve based on a parameter, typically denoted as t. In your case, you are using Bezier curves to plot points in relative space, which means that the curve is defined by relative coordinates rather than absolute coordinates. This allows for more flexibility and easier manipulation of the curve.

To use Bezier curves to plot points in relative space, you will need to follow a few steps:

1. Define your control points: In your example, you have three control points (x1, y1), (x2, y2), and (x3, y3). These points will determine the shape of your curve.

2. Initialize the curve: Use the following formula to calculate the coefficients for your Bezier curve:
cX = (3 * x1)
cY = (3 * y1)
bX = ((3 * (x2 - x1)) - cX)
bY = ((3 * (y2 - y1)) - cY)
aX = (x3 - cX - bX)
aY = (y3 - cY - bY)

These coefficients will be used in the next step to calculate the position of points along the curve.

3. Plot points: To plot a point on the curve, you will need to use the following formula:
pX = ((aX * t^3) + (bX * t^2) + (cX * t))
pY = ((aY * t^3) + (bY * t^2) + (cY * t))

Here, t represents the parameter that determines the position of the point on the curve. In your example, you are using t1, t2, and t3 to calculate the position of points. These values are simply t raised to different powers. For example, t2 represents t squared (t^2).

4. Octant change: In your example, you mention octants, which refer to different sections of the coordinate plane. The formula for calculating the position of points in different octants is the same, but the values of t will change. In Octant 0, you will use X integers to find t and generate Y reals, while in Octant 1, you will use
 

What is the Bezier Plotting problem?

The Bezier Plotting problem involves determining the coordinates of points on a curve defined by a set of control points using the Bezier curve algorithm. This problem is commonly encountered in computer graphics and design applications.

How does the Bezier curve algorithm work?

The Bezier curve algorithm uses a mathematical formula to calculate the coordinates of points on a curve based on a set of control points. The curve is defined by a series of polynomial functions, with the degree of the polynomial being determined by the number of control points.

What are control points in Bezier plotting?

Control points are points that are used to define the shape of a curve in the Bezier curve algorithm. They are typically placed at the start, end, and any intermediate points of the curve and are used to manipulate the curve by adjusting their coordinates.

What is the difference between a Bezier curve and a regular curve?

A regular curve is defined by a single mathematical function, while a Bezier curve is defined by a series of polynomial functions. The use of multiple functions allows Bezier curves to create more complex and precise curves compared to regular curves.

What are some practical applications of Bezier plotting?

Bezier plotting is commonly used in computer graphics and design applications, such as creating smooth and precise curves in vector graphics, font design, and animation. It is also used in engineering and manufacturing for creating curves in CAD software and designing machine parts and components.

Similar threads

  • Introductory Physics Homework Help
Replies
11
Views
763
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
995
  • Introductory Physics Homework Help
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
Replies
1
Views
1K
Replies
4
Views
5K
  • Advanced Physics Homework Help
Replies
12
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top