9.1.4 Bezier curves |
The MARK_BEZIER_xxx commands may be used to define quadratic or cubic Bezier curves as (parts of) the path that the laser beam should follow over the target surface during marking operations.
Here are some details of the way these commands and their parameters are implemented and handled on the SP-ICE-3 Card.
From an arbitrary starting point S we may describe a quadratic Bezier curve b, with control point C and end point E. |
Similarly, from an arbitrary starting point S we may describe a cubic Bezier curve b, with control points C1, C2 and end point E. |
When the card executes MARK_BEZIER_xxx, it calculates the length of the curve from the given parameters, and hence the number of micro-steps required, taking into account the specified marking velocity.
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendBezierAbs(Point2D, Point2D) | |
AppendBezierRel(Point2D, Point2D) |
Note |
---|
Boilerplate code is omitted from this example for brevity: please refer to 12.3 Example Code in this Manual. |
using ( ClientAPI client = new ClientAPI() ) { try { client.Connect( CardIP ); client.System.ResetToDefaults(); // // For this example, we choose to make the curve extend // over a large part of the available diagonal distance // across the marking field. // // Note how we use the (pre-)configured size of the marking field ... double sizeX = ( 7 * client.Scanner.GetConfig().FieldSize.X ) / 8; double sizeY = ( 7 * client.Scanner.GetConfig().FieldSize.Y ) / 8; // ... and the place the extrema of the curve symmetrically about the origin. double maxX = 0.5 * sizeX; double minX = -0.5 * sizeX; double maxY = 0.5 * sizeY; double minY = -0.5 * sizeY; // define the starting point S Point2D S = new Point2D( minX, minY ); // define the end point E Point2D E = new Point2D( maxX, maxY ); // define the first control point C1 Point2D C1 = new Point2D( minX, maxY ); // define the second control point C2 Point2D C2 = new Point2D( maxX, minY ); double jumpSpeed = 1.0; double markSpeed = 0.1; CommandList list = new CommandList(); // Append process parameter values to the List: list.AppendJumpSpeed( jumpSpeed ); list.AppendMarkSpeed( markSpeed ); // Append vectors to the List: // // move to the start of the curve at S list.AppendJumpAbs( S ); // // draw cubic Bezier curve to E list.AppendCubicBezierAbs( E, C1, C2 ); // // now draw a quadratic Bezier curve from E back to S using only C1 list.AppendQuadraticBezierAbs( S, C1 ); int listID = 0; client.List.Set( listID, list ); client.Laser.ArmLaser( true ); client.List.Execute( listID ); // obviously, the timeout has to be appropriate for the marking speed, etc. int timeoutMs = 1000; int? doneID; if ( !client.List.WaitForListDone( out doneID, timeoutMs ) ) { throw new ListException( "Timed out waiting for ListDone." ); } if ( doneID != listID ) { throw new ListException( "Got ListDone for wrong listID!" ); } } catch ( Exception ex ) { // // TODO: // Define suitable error handling for your application. // Console.WriteLine( "Uhhh, Houston? We've had a problem...{0}", ex.ToString() ); } }