HP Forums
Bézier Curves (Bezier curves) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Bézier Curves (Bezier curves) (/thread-9954.html)

Bézier Curves (Bezier curves) - StephenG1CMZ - 01-16-2018 10:04 PM

A program for generating and drawing Bézier curves...

RE: Bezier Curves - StephenG1CMZ - 01-16-2018 10:08 PM

Bezier curves V0.1 allows the points on a Bezier curve to be generated and drawn.


 LOCAL CRID:="Bézier V0.1 StephenG1CMZ 2018";

 //LOCAL ImpSTEPSZ:=1/(10000-2);//Most Detailed-List Limit
 //! Android: Insufficient Memory may occur. 
 //These steps allow a spline along a diagonal
 //LOCAL GSTEPSZ:=1/(4406-2); //4K
 //LOCAL GSTEPSZ:=1/(2203-2); //HD
 //LOCAL GSTEPSZ:=1/(800-2);//VGA
 //0..1 ALSO IMP>0.001=10000 PTS

 //Generate a point along a Bezier Quadratic curve
 //PERCY AND II: 0..1

 //Generate Bezier Quadratic curve
  LOCAL PTS:={};
  PTS(0):=GBezierQUAD1(XX,YY,1); //(XX(3),YY(3));

 //Generate a point along a Bezier Cubic curve
 //PERCY AND II: 0..1



 //Generate Bezier Cubic curve
  LOCAL PTS:={};

   PTS(0):=GBezierCUBIC1(XX,YY,II); //X AND Y
  PTS(0):=GBezierCUBIC1(XX,YY,1); //(XX(4),YY(4));

 //CONN 0: POINTS 1 BY 1 


 EXPORT IsOnCurve(Points,Point,Rounding)
 //Is PT on curve described by PTS
 //Points:Points comprising curve
 //Point: Search Point (Complex XY)
 //Rounding: −12..12 allows inexact real matches 
 //NB if points change, conclusion may
 //Enhancements: Consider alternatives to rounding
  LOCAL RND:=Rounding;

 EXPORT BezierExample()
 DRAWC({(320/2,240/2)},COLR,CN);//TEST 1 PT
 TEXTOUT_P(SIZE(PTS)+" Points/Bézier",0,200);
 //PRINT("RESULT:POS is "+IsOnCurve({(1,2)},(1,2),0));


Quadratic Bezier and Cubic Bezier are implemented, but Polybeziers are not yet implemented.

RE: Bézier Curves (Bezier curves) - TheKaneB - 01-16-2018 11:13 PM

Oh memories!
I learned about Bezier curves about 10 years ago, I used them as a rough approximation of the catenary curve, to draw some wires in a game. Later on I used polybeziers and splines in other projects Smile

RE: Bézier Curves (Bezier curves) - StephenG1CMZ - 01-17-2018 03:14 PM

When I saw how quickly I got a reply, I was expecting to see "why didn't you use this built-in function?" but I didn't find one.
I know I studied Bezier and splines but I have forgotten most of that and I can't recall ever needing them.

RE: Bézier Curves (Bezier curves) - StephenG1CMZ - 03-16-2021 11:16 PM

This thread discusses plotting Bezier curves using the plotparam built-in and Parametric App (as
Possible alternative to using this PPL program).

Note: If my program gives a syntax error on a line containing "space)", just delete the space character.