POV-Ray : Newsgroups : povray.pov4.discussion.general : Suggest v4.0 f_bezier_2d_...() functions. (yuqk R19 v0.6.13.0) : Re: Suggest v4.0 f_bezier_2d_...() functions. (yuqk R19 v0.6.13.0) Server Time
14 Mar 2025 07:12:42 EDT (-0400)
  Re: Suggest v4.0 f_bezier_2d_...() functions. (yuqk R19 v0.6.13.0)  
From: Bald Eagle
Date: 27 Feb 2025 09:25:00
Message: <web.67c074d76d1e536f4cc51b5c25979125@news.povray.org>
(and heck, while we're at it, why not just throw in 2 functions to degree
elevate and degree reduce a Bezier spline)

untested, not generalized (but I think you can see the pattern):

#macro DegreeElevateBezier(P0, P1, P2, P3)

  #local Q0 = P0;
  #local Q1 = (1/4)*P0 + (3/4)*P1;
  #local Q2 = (1/2)*P1 + (1/2)*P2;
  #local Q3 = (3/4)*P2 + (1/4)*P3;
  #local Q4 = P3;

  // Return the new control points
  array[5] {Q0, Q1, Q2, Q3, Q4}
#end

#macro DegreeReduceBezier(Q0, Q1, Q2, Q3, Q4)

  #local P0 = Q0;
  #local P1 = (4/3)*Q1 - (1/3)*Q0;
  #local P2 = (4/3)*Q3 - (1/3)*Q4;
  #local P3 = Q4;

  // Return the new control points
  array[4] {P0, P1, P2, P3}
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.