In the previous log I described how iPath was extended (with helper functions) to provide for functionality to complete the traincross.
This short log will display show how the train cross is realized:
tc.pts=[{x:3, y:0},{x:5,y:3},{fr:6}, {x:0, y:9},{fr:6}
, {x:tc.gutter/2-8, y:2}, {x:0, y: tc.boneLength-14}
, {x:(tc.width-tc.gutter)/2, y:0}
, {x:0, y:-tc.length}, {fr:tc.length*tc.filletratio}];
tc.path = arcPath(reflectPath(reflectPath(reflectPath(tc.pts
, {x:1, y:1}), {x:1,y:0}), {x:0,y:1}));
tc.rails = new iPath().move(0,tc.boneLength).move(tc.railsWidth/2,0)
.line(0,-tc.totalLength).move(-tc.railsWidth,0).line(0,tc.totalLength)
.move(tc.railsWidth/2-tc.length-tc.width/2
,-tc.railsWidth/2-tc.length-tc.width/2)
The variables tc.width, tc.boneLength etc must be declared upfront or can be made user-customizable. The {x:.., y:..} indicate relative points, they are connected with straight lines.. The {fr: ..} objects indicates the fillet, the arc between two lines. Note that the fillet will effectively modify (shorten) the surrounding lines. The arcPath function returns an iPath which can be materialized into an SVG path-d attribute or DXF file.
It would have been possible to concat the tc.path and tc.rails into one object. But when exporting to DXF one can only assign one layer per object. The rails are different from the outside boundary: the cutting depth is different. CNC operators normally want one layer per cutting action and this is possible by constructing 2 iPaths.
The complete jsvg file can be downloaded from this project's file section. The result can be viewed in StretchSketch
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.