The drag-knife process is detailed on an excellent video from DonekTools.com
http://www.youtube.com/watch?v=fOf_tCefl6Q#t=560
Drag-Knife Tool Variables - for creation of a new tool item in Gcodetools:
KnifeOffset: distance of the knife tip from the machine centerline - this is equivalent to the "wheelbase" of a bicycle for calculations between front and rear wheels.
CutDepth: this would be set to the material thickness to be cut, or possibly slightly larger if using a spring-loaded tool or cutting through the material into a waste board.
RetractDepth: a smaller depth used for retract/swivel move - tool retracts during swivel moves to reduce "mangling" of the corners - note the tool tip must remain in the material during swivels to orient it toward the next cut path since the knife is unpowered.
SwivelAngle: if the angle between two segments is larger than this angle, the tool retracts between segments - prevents "retract" move for shallow angles where a retract is not really necessary.
Feed: cutting speed
PenetrationFeed: speed for Z moves
SwivelFeed: speed for swivel moves
Drag-Knife Path Start Point:
Cutting will work either CW or CCW, however the start point location should be specified either manually or programmatically. The reason is that the knife is manually positioned toward the X-direction prior to the first cut, and if the starting point was at the bottom of a circle (6:00) with cut direction CW, the tool would need to swivel a full 180 degrees to start the first cut, and again a full 180 degrees at the end of the cut to position the tool to +X for the next path. This is an excessive move and could result in damage to the material at this point. An ideal start/end point of a circle would be the top of the circle (12:00) for CW or the bottom of the circle (6:00) and CCW.
Pseudocode for Start Point (SP) and Cut Direction (CD):
HUV = Horizontal Unit Vector = (0,0),(1,0)
Sequence through all segments in CCW direction
Check angle of tangents between P1 to HUV, and P2 to Huv
If angle P1 to HUV = 0, then set SP = P1 and set CD = CCW
If angle P2 to HUV = 0, then set SP = P2 and set CD = CCW
Repeat above sequence in CW direction and set CD = CW
Check curved segments, if curve has a point with slope = 0, set SP to this point (I can detail this later)
If no angles = 0, then select the smallest angle from previous checks and set SP and CD
Pseudocode for Generating Cut Path:
Sequence through each path segment in the direction set by CD
Calculate points C1 and C2 and Sweep based on "Bicycle Wheel" of original path.
If First Segment:
Place Point at SP+(Offset,0) @RetractDepth
Swivel Path to tangent of First Segment @SwivelFeed
Place Point C1 @CutDepth
Elif SwivelAngle >= Angle from previous segment:
Place Point C1 @CutDepth
Else:
Swivel from Previous C2 to C1 @RetractDepth
C1 @CutDepth
If Last Segment:
Place Point C2 @CutDepth
C2 @RetractDepth
Swivel to Horizontal
Else:
Place Point C2 @CutDepth
Curved Path Calculations:
These are fairly simple, and are based on the formulas provided on the "Bicycle Wheel" article link. Knowing the path that the knife must follow (rear wheel) we want to calculate the path of the front wheel (machine). Two factors added to the calculation account for the Offset distance and a sign for the direction.
For example, the CamBam script lines for this ended up being:
C2X = P2X+Offset/((1+(V2.Y/V2.X)**2)**.5)*Math.Sign(V2.X)
C2Y = P2Y+(Offset*V2.Y/V2.X)/((1+(V2.Y/V2.X)**2)**.5)*Math.Sign(V2.X)
As you see, pretty straightforward.
Most of the work would be to change the curve calculations from the CamBam "Bulge" to the Gcodetools Biarc segments (3 points?)
Cheers - BillT