|
 |
William F Pokorny <ano### [at] anonymous org> wrote:
> Adding the inbuilt functions: f_bezier_2d_linear()
> f_bezier_2d_quadratic() f_bezier_2d_cubic() f_bezier_2d_quartic() and
> f_bezier_2d_quintic() to the next yuqk release (R19).
>
> The functions take and return single float packed 2d vectors in a
> double's space for control points and return values. Calculations are at
> double float accuracy internal to each functions code. The t parameter
> is passed as a double.
Of use would also be a function that takes a t parameter and splits an extant
curve into 2 splines that are, over their combined lengths, equivalent to the
original Bezier curve.
I tested this in excel, and it works nicely.
#macro SplitBezier (P0, P1, P2, P3, t)
#local Q0 = P0 + t * (P1 - P0);
#local Q1 = P1 + t * (P2 - P1);
#local Q2 = P2 + t * (P3 - P2);
#local R0 = Q0 + t * (Q1 - Q0);
#local R1 = Q1 + t * (Q2 - Q1);
#local S = R0 + t * (R1 - R0);
// First segment: P0 to S
#declare Segment1 = array[4] {P0, Q0, R0, S};
// Second segment: S to P3
#declare Segment2 = array[4] {S, R1, Q2, P3};
Segment1, Segment2
#end
// Example usage
#declare P0 = <0, 0, 0>;
#declare P1 = <1, 2, 0>;
#declare P2 = <2, 2, 0>;
#declare P3 = <3, 0, 0>;
#declare t = 0.5;
#declare Segments = SplitBezier (P0, P1, P2, P3, t);
#declare Segment1 = Segments[0];
#declare Segment2 = Segments[1];
Post a reply to this message
|
 |