// Copyright (C) 1996 Leena L�hteenm�ki, Finland // Copyright (C) 2012 PatternMaker Software // 2011/11/04 // Different Collars, female, male, children object marker_array[20]; double marker_count, loop; double x[300], y[300]; object group_obj[30]; double ang,ang2,vang,vdistance,rangle; object current_object; point current_point; selection current_selection; //MUUTTUJAT double kp; double metric, sv, nv; double model, point_model; double index, done, version; double language; main() { language=get_language(); if ( language != 0 ) { language = 0; } kp=40; nv=2; sv=1; index = 0; done = 0; //Start Options while (!done) { if (index == 0) { dialog_model(); } if (index == 1) { dialog_point(); } } //End Options //MEASUREMENT UNITS //==================== if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { kp=kp/2.54; nv=nv/2.54; sv=sv/2.54; } } else { if (language == 0) { metric=2*pop_up("Units","Inches","Centimeters"); } // 0 = inches, 2=cm if (metric<1) // If inches, convert cm to inches for dialog box { kp=kp/2.54; nv=nv/2.54; sv=sv/2.54; } } if(metric==0) { sv=0.39; } if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("Collars"); } if (language == 0) { add_picture_input("Garment neck circ.",kp, "w_meas_garment_neckcirc"); } if (language == 0) { add_picture_input("Button extension width", nv, "w_meas_button_ext_width"); } if (language == 0) { add_picture_input("Seam Allowance", sv, "meas_seamallow"); } run_picture_input(); } else { if (language == 0) { dialog_box("Collars", "Garment neck circ.",kp, "Button extension width", nv, "Seam Allowance", sv); } } // Actual measurement used is 1/2 kp kp = kp/2; //======== if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { kp=kp*2.54; nv=nv*2.54;// sv=sv*2.54; } } else { if (metric<1) // If inches, convert cm to inches for dialog box { kp=kp*2.54; nv=nv*2.54;// sv=sv*2.54; } } if(metric==2) { sv=sv/2.54; } if(nv==0) { nv=nv+.1; } x[0]=0; y[0]=0; //mock shirt collar //1 coord(0,0,1,3); //2 coord(1,2,-kp,-3); //3 coord(1,3,-kp/6,0); //4 coord(3,4,-kp/6,0); //6 coord(2,6,kp/6,0); //5 center(4,6,5); //7 coord(2,7,kp/6,0); //8 coord(2,8,-nv,0); //9 coord(8,9,0.5,2); //10 coord(2,10,0,2); //11 coord(10,11,-4,7); //12 cont(10,11,12,-2); //14 coord(1,14,0,7); //15 center(11,14,15); //13 cont(15,11,13,-2); //37 coord(14,37,-4,0); //Shirt collar //16) coord(0,16,0,0); //17) 16-> kaula-aukon mitattu pituus coord(16,17,-kp,0); //18) 17-> nappivara coord(17,18,-nv,0); //19) 17-> n. 4 cm=vakio coord(17,19,4,0); //20) 16-> 0.7 cm=vakio coord(16,20,0,0.7); //21) 20-> kaaren kulmapiste coord(20,21,-kp/3,0); //22) 18-> 0.5 cm=vakio coord(18,22,0,.5); //23) 22-> kaulurin korkeus edessa 2.5 cm coord(22,23,.5,2.5); //24) 20-> kaulurin korkeus takana 3-3.5 cm coord(20,24,0,3.5); //25) 21-> kaaren kulmapiste coord(21,25,0,3.5); //26) 23-> nappivara+1.2 coord(23,26,nv+0.2,0); //27) 24-> 1 cm=vakio coord(24,27,0,1); //28) 25-> kaaren kulmapiste coord(25,28,0,1); //29) 27-> kauluksen korkeus takana 4 cm coord(27,29,0,4); //30) 25-> kaaren kulmapiste coord(25,30,-kp/2,4); //31) 26-> kauluksen korkeus edessa 5-7 cm coord(26,31,-2,6); //32) 29->kauluksen suora osuus kt:sta coord(29,32,-kp/4,0); //round point cont(26,31,33,-2); cont(30,31,34,-2); cont(22,23,35,-1); cont(26,23,36,-1); //blouse collar //41 coord(1,41,0,2.5); //42 coord(41,42,-kp,-2.5); //43 coord(41,43,-kp/6,0); //44 coord(43,44,-kp/6,0); //45 coord(44,45,-kp/6,-1); //47 coord(42,47,kp/6,0); //46 center(45,47,46); //48 coord(42,48,-4,6); //49 cont(42,48,49,-2); //51 coord(41,51,0,5.5); //52 coord(51,52,-4,0); //53 coord(52,53,-dist(52,48)/2,0); //50 cont(53,48,50,-2); //convertible collar //61 coord(1,61,0,5); //62 coord(61,62,-kp,-5); //63 coord(61,63,-kp/4,0); //64 coord(63,64,-kp/4,0); //65 coord(64,65,-kp/4,-2.5); //66 coord(62,66,-6.5,5.5); //67 cont(62,66,67,-2); //70 coord(61,70,0,6.5); //71 coord(63,71,0,6.5); //72 coord(64,72,0,6.5); //73 coord(65,73,0,7.5); //68 cont(73,66,68,-2); //69 center(73,68,69); //MODEL if(model==0)//shirt collar { draw_shirt_collar(); run_command("zoomall"); } if(model==1)//mock shirt collar { draw_mock_shirt_collar(); run_command("zoomall"); } if(model==2)//convertible collar { draw_convertible_collar(); run_command("zoomall"); } if(model==3)//blouse collar { draw_blouse_collar(); run_command("zoomall"); } if(model==4)//chinese collar { draw_chinese_collar(); run_command("zoomall"); } //loppu } //debug(1); draw_shirt_collar() { //kauluri current_object=newobject("poly"); addpoint(x[20]/2.54, y[20]/2.54, "xarc_start"); addpoint(x[21]/2.54, y[21]/2.54, "xarc_corner"); addpoint(x[19]/2.54, y[19]/2.54, "line"); current_point=addpoint(x[17]/2.54, y[17]/2.54, "line"); notch_type(current_point,"NOTCH",0); if(point_model==0) { addpoint(x[22]/2.54, y[22]/2.54, "line"); addpoint(x[23]/2.54, y[23]/2.54, "line"); current_point=addpoint(x[26]/2.54, y[26]/2.54, "xarc_start"); notch_type(current_point,"NOTCH",0); } else { addpoint(x[22]/2.54, y[22]/2.54, "line"); addpoint(x[35]/2.54, y[35]/2.54, "xarc_start"); addpoint(x[23]/2.54, y[23]/2.54, "xarc_corner"); addpoint(x[36]/2.54, y[36]/2.54, "line"); current_point=addpoint(x[26]/2.54, y[26]/2.54, "xarc_start"); notch_type(current_point,"NOTCH",0); } addpoint(x[25]/2.54, y[25]/2.54, "xarc_corner"); addpoint(x[24]/2.54, y[24]/2.54, "line"); group_obj[1]=current_object; //teksti, CB if (language == 0) { current_object=newobject("text","Shirt Collar Stand. Cut 2 on fold. CB", 0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[16]-10)/2.54, (y[16]+2)/2.54, "line"); group_obj[2]=current_object; if(sv>0) { //teksti, cutting on fold if (language == 0) { current_object=newobject("text","Remove CB seam allowance", 0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[16]-10)/2.54, (y[16]+1)/2.54, "line"); group_obj[20]=current_object; } //teksti, CF if (language == 0) { current_object=newobject("text","CF",0.0,0.1,0.2,"SIMP.CHR"); } current_point=addpoint((x[17]+.2)/2.54, (y[17]+.2)/2.54, "line"); group_obj[3]=current_object; //Ryhmitys ja saumanvarat if(sv>0) { //saumanvara offset_mark(1); select(current_selection,group_obj[2]); select(current_selection,group_obj[20]); select(current_selection,group_obj[3]); group(current_selection); deselect(current_selection); } else { //ryhmitys ilman saumanvaroja mark(1); current_selection=newselection("OBJECT"); select(current_selection,group_obj[1]); select(current_selection,group_obj[2]); select(current_selection,group_obj[3]); group(current_selection); deselect(current_selection); } if (is_function("set_marker")==1) { set_marker(group_obj[1], 0); } //kaulus current_object=newobject("poly"); addpoint(x[27]/2.54, (y[27]+4)/2.54, "xarc_start"); addpoint(x[28]/2.54, (y[28]+4)/2.54, "xarc_corner"); if(point_model==0) { current_point=addpoint(x[26]/2.54, (y[26]+4)/2.54, "LINE"); notch_type(current_point,"NOTCH",0); addpoint(x[31]/2.54, (y[31]+4)/2.54, "line"); } else { current_point=addpoint(x[26]/2.54, (y[26]+4)/2.54, "line"); notch_type(current_point,"NOTCH",0); addpoint(x[33]/2.54, (y[33]+4)/2.54, "xarc_start"); addpoint(x[31]/2.54, (y[31]+4)/2.54, "xarc_corner"); addpoint(x[34]/2.54, (y[34]+4)/2.54, "line"); } // addpoint(x[30]/2.54, (y[30]+4)/2.54, "xarc_corner"); addpoint(x[32]/2.54, (y[32]+4)/2.54, "LINE"); addpoint(x[29]/2.54, (y[29]+4)/2.54, "LINE"); group_obj[4]=current_object; //teksti if (language == 0) { current_object=newobject("text","Upper Shirt Collar. Cut 1 on fold. CB",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[27]-10)/2.54, (y[27]+5.5)/2.54, "line"); group_obj[5]=current_object; if(sv>0) { //teksti, cutting on fold if (language == 0) { current_object=newobject("text","Remove CB seam allowance", 0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[27]-10)/2.54, (y[27]+4.5)/2.54, "line"); group_obj[20]=current_object; //Ryhmitys ja saumanvarat //saumanvara offset_mark(4); select(current_selection,group_obj[20]); select(current_selection,group_obj[5]); group(current_selection); deselect(current_selection); } else { //ryhmitys ilman saumanvaroja mark(4); current_selection=newselection("OBJECT"); select(current_selection,group_obj[4]); select(current_selection,group_obj[5]); group(current_selection); deselect(current_selection); } if (is_function("set_marker")==1) { set_marker(group_obj[1], 0); set_marker(group_obj[4], 0); } run_command("zoomall"); } //debug(2); draw_mock_shirt_collar() { current_object=newobject("poly"); addpoint((x[1])/2.54, (y[1])/2.54, "line"); addpoint((x[3])/2.54, (y[3])/2.54, "xarc_start"); addpoint((x[4])/2.54, (y[4])/2.54, "xarc_corner"); addpoint((x[5])/2.54, (y[5])/2.54, "xarc_start"); addpoint((x[6])/2.54, (y[6])/2.54, "xarc_corner"); current_point=addpoint((x[2])/2.54, (y[2])/2.54, "line"); notch_type(current_point,"NOTCH",0); if(point_model==0)//pointed { addpoint((x[8])/2.54, (y[8])/2.54, "line"); addpoint((x[9])/2.54, (y[9])/2.54, "line"); } else { addpoint((x[8])/2.54, (y[8])/2.54, "xarc_start"); addpoint((x[9])/2.54, (y[9])/2.54, "xarc_corner"); } addpoint((x[10])/2.54, (y[10])/2.54, "line"); if(point_model==0)//pointed { addpoint((x[12])/2.54, (y[12])/2.54, "line"); addpoint((x[11])/2.54, (y[11])/2.54, "xarc_start"); } else { addpoint((x[12])/2.54, (y[12])/2.54, "xarc_start"); addpoint((x[11])/2.54, (y[11])/2.54, "xarc_corner"); addpoint((x[13])/2.54, (y[13])/2.54, "xarc_start"); } addpoint((x[15])/2.54, (y[15])/2.54, "xarc_corner"); addpoint((x[37])/2.54, (y[37])/2.54, "line"); addpoint((x[14])/2.54, (y[14])/2.54, "line"); group_obj[7]=current_object; //debug(21); //teksti, CB if (language == 0) { current_object=newobject("text","Mock Shirt Collar. Cut 2 on fold. CB",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[4]-2)/2.54, (y[1]+3)/2.54, "line"); group_obj[8]=current_object; if(sv>0) { //teksti, cutting on fold if (language == 0) { current_object=newobject("text","Remove CB seam allowance", 0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[4]-2)/2.54, (y[1]+2)/2.54, "line"); group_obj[20]=current_object; } //debug(22); //teksti, CF if (language == 0) { current_object=newobject("text","CF",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[2]+.2)/2.54, (y[2]+.2)/2.54, "line"); group_obj[9]=current_object; //debug(23); //Ryhmitys ja saumanvarat if(sv>0) { //saumanvara offset_mark(7); select(current_selection,group_obj[8]); select(current_selection,group_obj[20]); //debug(25); select(current_selection,group_obj[9]); group(current_selection); deselect(current_selection); } else { mark(7); //ryhmitys ilman saumanvaroja current_selection=newselection("OBJECT"); select(current_selection,group_obj[7]); select(current_selection,group_obj[8]); select(current_selection,group_obj[9]); group(current_selection); deselect(current_selection); } if (is_function("set_marker")==1) { set_marker(group_obj[7], 0); } run_command("zoomall"); } //debug(3); draw_convertible_collar() { //istutussauman pituuden tarkistus convertible double seam_conv; seam_conv=arclength(61,63,64)+arclength(64,65,62); double ero_conv; ero_conv=kp-seam_conv; x[61]=x[61]+ero_conv; x[70]=x[70]+ero_conv; current_object=newobject("poly"); addpoint((x[61])/2.54, y[61]/2.54, "line"); addpoint((x[63])/2.54, y[63]/2.54, "xarc_start"); addpoint((x[64])/2.54, y[64]/2.54, "xarc_corner"); addpoint((x[65])/2.54, y[65]/2.54, "line"); addpoint((x[62])/2.54, y[62]/2.54, "line"); if(point_model==0) { addpoint((x[66])/2.54, y[66]/2.54, "line"); } else { addpoint((x[67])/2.54, y[67]/2.54, "xarc_start"); addpoint((x[66])/2.54, y[66]/2.54, "xarc_corner"); addpoint((x[68])/2.54, y[68]/2.54, "line"); } addpoint((x[69])/2.54, y[69]/2.54, "line"); addpoint((x[73])/2.54, y[73]/2.54, "xarc_start"); addpoint((x[72])/2.54, y[72]/2.54, "xarc_corner"); addpoint((x[71])/2.54, y[71]/2.54, "line"); addpoint((x[70])/2.54, y[70]/2.54, "line"); group_obj[10]=current_object; //teksti, CB if (language == 0) { current_object=newobject("text","Convertible Collar. Cut 2 on fold. CB",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[61]-10)/2.54, (y[61]+3.25)/2.54, "line"); group_obj[11]=current_object; if(sv>0) { //teksti, cutting on fold if (language == 0) { current_object=newobject("text","Remove CB seam allowance",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[61]-10)/2.54, (y[61]+2.25)/2.54, "line"); group_obj[20]=current_object; } //teksti, CF if (language == 0) { current_object=newobject("text","CF",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[62]+.2)/2.54, (y[62]+.2)/2.54, "line"); group_obj[12]=current_object; //Ryhmitys ja saumanvarat if(sv>0) { //saumanvara offset_mark(10); select(current_selection,group_obj[11]); select(current_selection,group_obj[20]); select(current_selection,group_obj[12]); group(current_selection); deselect(current_selection); } else { mark(10); //ryhmitys ilman saumanvaroja current_selection=newselection("OBJECT"); select(current_selection,group_obj[10]); select(current_selection,group_obj[11]); select(current_selection,group_obj[12]); group(current_selection); deselect(current_selection); } if (is_function("set_marker")==1) { set_marker(group_obj[10], 0); } run_command("zoomall"); } //debug(4); draw_blouse_collar() { current_object=newobject("poly"); addpoint(x[41]/2.54, y[41]/2.54, "line"); addpoint(x[43]/2.54, y[43]/2.54, "xarc_start"); addpoint(x[44]/2.54, y[44]/2.54, "xarc_corner"); addpoint(x[45]/2.54, y[45]/2.54, "line"); addpoint(x[46]/2.54, y[46]/2.54, "xarc_start"); addpoint(x[47]/2.54, y[47]/2.54, "xarc_corner"); addpoint(x[42]/2.54, y[42]/2.54, "line"); if(point_model==0) { addpoint(x[48]/2.54, y[48]/2.54, "xarc_start"); } else { addpoint(x[49]/2.54, y[49]/2.54, "xarc_start"); addpoint(x[48]/2.54, y[48]/2.54, "xarc_corner"); addpoint(x[50]/2.54, y[50]/2.54, "xarc_start"); } addpoint(x[53]/2.54, y[53]/2.54, "xarc_corner"); addpoint(x[52]/2.54, y[52]/2.54, "line"); addpoint(x[51]/2.54, y[51]/2.54, "line"); group_obj[13]=current_object; //teksti, CB if (language == 0) { current_object=newobject("text","Blouse Collar. Cut 2 on fold. CB",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[41]-8)/2.54, (y[41]+2.75)/2.54, "line"); group_obj[14]=current_object; if(sv>0) { //teksti, cutting on fold if (language == 0) { current_object=newobject("text","Remove CB seam allowance",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[41]-8)/2.54, (y[41]+1.75)/2.54, "line"); group_obj[20]=current_object; } //teksti, CF if (language == 0) { current_object=newobject("text","CF",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[42]+.2)/2.54, (y[42]+.2)/2.54, "line"); group_obj[15]=current_object; //Ryhmitys ja saumanvarat if(sv>0) { //saumanvara offset_mark(13); select(current_selection,group_obj[14]); select(current_selection,group_obj[15]); select(current_selection,group_obj[20]); group(current_selection); deselect(current_selection); } else { mark(13); //ryhmitys ilman saumanvaroja current_selection=newselection("OBJECT"); select(current_selection,group_obj[13]); select(current_selection,group_obj[14]); select(current_selection,group_obj[15]); group(current_selection); deselect(current_selection); } if (is_function("set_marker")==1) { set_marker(group_obj[13], 0); } run_command("zoomall"); } //debug(5); draw_chinese_collar() { //pystykaulus current_object=newobject("poly"); addpoint(x[20]/2.54, y[20]/2.54, "xarc_start"); addpoint(x[21]/2.54, y[21]/2.54, "xarc_corner"); addpoint(x[19]/2.54, y[19]/2.54, "line"); current_point=addpoint(x[17]/2.54, y[17]/2.54, "line"); notch_type(current_point,"NOTCH",0); if(point_model==0) { addpoint(x[22]/2.54, y[22]/2.54, "line"); addpoint(x[23]/2.54, y[23]/2.54, "line"); addpoint(x[26]/2.54, y[26]/2.54, "xarc_start"); } else { addpoint(x[22]/2.54, y[22]/2.54, "line"); addpoint(x[35]/2.54, y[35]/2.54, "xarc_start"); addpoint(x[23]/2.54, y[23]/2.54, "xarc_corner"); addpoint(x[36]/2.54, y[36]/2.54, "line"); addpoint(x[26]/2.54, y[26]/2.54, "xarc_start"); } addpoint(x[25]/2.54, y[25]/2.54, "xarc_corner"); addpoint(x[24]/2.54, y[24]/2.54, "line"); group_obj[16]=current_object; //teksti, CB if (language == 0) { current_object=newobject("text","Chinese Collar. Cut 2 on fold. CB",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[16]-10)/2.54, (y[16]+2)/2.54, "line"); group_obj[17]=current_object; if(sv>0) { //teksti, cutting on fold if (language == 0) { current_object=newobject("text","Remove CB seam allowance",0.0,0.1,0.2,"SIMP.CHR"); } addpoint((x[16]-10)/2.54, (y[16]+1)/2.54, "line"); group_obj[20]=current_object; } //teksti, CF if (language == 0) { current_object=newobject("text","CF",0.0,0.1,0.2,"SIMP.CHR"); } current_point=addpoint((x[17]+.2)/2.54, (y[17]+.2)/2.54, "line"); group_obj[18]=current_object; //Ryhmitys ja saumanvarat if(sv>0) { //saumanvara offset_mark(16); select(current_selection,group_obj[17]); select(current_selection,group_obj[18]); select(current_selection,group_obj[20]); group(current_selection); deselect(current_selection); } else { mark(16); //ryhmitys ilman saumanvaroja current_selection=newselection("OBJECT"); select(current_selection,group_obj[16]); select(current_selection,group_obj[17]); select(current_selection,group_obj[18]); group(current_selection); deselect(current_selection); } if (is_function("set_marker")==1) { set_marker(group_obj[16], 0); } run_command("zoomall"); } //Option pictures //debug(1); dialog_model() { if (language == 0) { start_pict_dialog("Collar model"); add_pict_item("Shirt collar","collar_shirt.jpg"); add_pict_item("Mock shirt collar","collar_mockshirt.jpg"); add_pict_item("Convertible collar","collar_convertible.jpg"); add_pict_item("Blouse collar","collar_blouse.jpg"); add_pict_item("Chinese collar","collar_chinese.jpg"); run_pict("Next"); model=get_pict_result(); Forward(); } } //debug(7); dialog_point() { if (language == 0) { start_pict_dialog("Collar shape"); add_pict_item("Pointed","collar_convertible.jpg"); add_pict_item("Round","collar_convertible_round.jpg"); if (run_pict("Back","Next")) { point_model=get_pict_result(); Forward(); } else { point_model=0; Backward(); } } } Forward() { index = index + 1; if (index == 2) { done = 1; } } Backward() { index = index - 1; } newobj_dot(double x, double y) { object temp; line("CENTER_LINE"); temp = NEWOBJECT ("POLY"); addpoint(x, y, "line"); line("SOLID_LINE"); return temp; } coord(double orig, double dest, double xxx, double yyy) { x[dest]=x[orig]+xxx; y[dest]=y[orig]+yyy; } center(double one, double two, double result) { x[result]=(x[one]+x[two])/2; y[result]=(y[one]+y[two])/2; } dist(double p1, double p2) { return distance(x[p1],y[p1],x[p2],y[p2]); } line_intersect(double start1, double end1, double start2, double end2, double dest) { double tempx; double tempy; intersect(x[start1],y[start1],x[end1],y[end1],x[start2],y[start2],x[end2],y[end2],0); x[dest]=getresultx(); y[dest]=getresulty(); } cont(double cstart, double cend, double cdest, double cvdistanceance) { double ang; ang=angle(x[cstart], y[cstart], x[cend], y[cend]); polar(x[cend], y[cend], ang, cvdistanceance); x[cdest]=getresultx(); y[cdest]=getresulty(); } shift(double orig, double xxx, double yyy) { x[orig]=x[orig]+xxx; y[orig]=y[orig]+yyy; } rotate(double rpoint,double rcenter, double rangle) { double vdistance, vang; vdistance=dist(rpoint, rcenter); vang=angle(x[rcenter],y[rcenter],x[rpoint],y[rpoint]); polar(x[rcenter],y[rcenter],vang+rangle,vdistance); x[rpoint]=getresultx(); y[rpoint]=getresulty(); } linecirc(double PA,double PB,double PC,double dradius,double which, double PD) { // PA = center of circle, PB and PC determine line, dradius is radius of // circle, "which" is 0 or 1 (which of 2 possible intersections) // PD is output point i.e. 4 means put results in Point 4. double mslope, dist0, dist1, dist2, xtemp; double tx, ty; //coordinates of Point T // Since we will use slope calculations, horizontal or vertical lines // have to be handled separately to avoid dividing by 0. xtemp = (x[PB]-x[PC])*(x[PB]-x[PC]); if (xtemp > 0) { // not vertical xtemp = (y[PB]-y[PC])*(y[PB]-y[PC]); if ( xtemp > 0) { // not horizontal mslope = (y[PC] - y[PB])/(x[PC] - x[PB]); // slope of line //plot a perpendicular line through pt. A // First, find any point on this line tx = x[PA] + 1; ty = y[PA] - 1/mslope; // Then intersection of the 2 lines (Point T) intersect(x[PA], y[PA], tx, ty, x[PB], y[PB], x[PC], y[PC], 0); tx = getresultx(); ty = getresulty(); dist1 = distance(x[PA], y[PA], tx, ty); // Here is a special function that calculates the third leg // of a right triangle. First two inputs give the two ends // of one short leg. The third input is the hypotenuse // (here, it equals the dradius of the circle) // Won't work if the line and circle don't intersect! dist2 = interceptline(0, dist1, dradius); // distance from T to // desired point P1 or P2 dist0 = sqrt(1+mslope*mslope); xtemp = dist2/dist0; if (which) { x[PD] = tx+xtemp; // first intersection point y[PD] = ty+ xtemp*mslope; } else { x[PD] = tx-xtemp; // second intersection point y[PD] = ty- xtemp*mslope; } } else // horizontal line { x[PD] = x[PD] = x[PB]; if (which) { y[PD] = y[PA] + interceptline(x[PA], x[PB], dradius); } else { y[PD] = y[PA] - interceptline(x[PA], x[PB], dradius); } } } else //vertical line { y[PD] = y[PD] = y[PB]; if (which) { x[PD] = x[PA] + interceptline(y[PA], y[PB], dradius); } else { x[PD] = x[PA] - interceptline(y[PA], y[PB], dradius); } } } //////////////////////////////////////////// // These 3 routines find the length of an xarc, given the array // numbers of the 3 points that // make it up. // These variables needed for routine fts double xar[13], yar[13]; double rx, ry; arclength(double start, double corner, double end) { double ct, last_x, last_y; double a_dist; last_x = x[start]; last_y = y[start]; a_dist=0; // For each of the segments that comprises the arc, find // the endpoints of the segment and add the segment length // to the total for (ct=1; ct < 12; ct = ct + 1) { fts(start, corner, end, ct); a_dist = a_dist + distance(rx, ry, last_x, last_y); last_x=rx; last_y=ry; } return a_dist; } ////////////////////////////////////// // These global variables are used by fts for repeated calls. double A1, A2, B1, B2; //transformation vectors double sx, sy, cx, cy, ex, ey; double t0[2], t1[2]; double ftc[2]; fts(double start, double corner, double end, double pos) { if (pos<1) { rx=x[start]; ry=y[start]; } else { if (pos<2) { sx = x[start]; sy = y[start]; cx = x[corner]; cy = y[corner]; ex = x[end]; ey = y[end]; A1=cx - sx; A2=cy - sy; B1=cx - ex; B2=cy - ey; A1=-A1; B1=-B1; A2=-A2; B2=-B2; t0[0]=A1; t0[1]=B1; t1[0]=A2; t1[1]=B2; ftc[0]= cx + (t0[0] + t0[1]); ftc[1]= cy + (t1[0] + t1[1]); rx = t0[0]*(xar[pos])+t0[1]*(yar[pos])+ ftc[0]; ry = t1[0]*(xar[pos])+t1[1]*(yar[pos])+ ftc[1]; } else { if (pos>10) { rx=x[end]; ry=y[end]; } else { rx = t0[0]*(xar[pos])+t0[1]*(yar[pos])+ ftc[0]; ry = t1[0]*(xar[pos])+t1[1]*(yar[pos])+ ftc[1]; } } } } /////////////////////////////////////// init_xarc_array() { // Must be called before calling fts(). This routine // sets the values in an array of sines and cosines. // You only need to call this routine once. double ang_start, ang_end, step, theta, ct; double XARC_PIECES; XARC_PIECES = 12; ang_start = -3.14159/2; ang_end= -3.14159; ct=0; step= (ang_end - ang_start)/(XARC_PIECES-1); for (theta=ang_start; ct < XARC_PIECES; theta = theta + step) { xar[ct] = cos(theta); yar[ct] = sin(theta); ct=ct+1; } //end init_xarc_array } max(double aa, double bb) { if (aa > bb) { return aa; } else { return bb; } } min(double aa, double bb) { if (aa < bb) { return aa; } else { return bb; } } mark(double pass_index) { group_obj[pass_index]=marker_piece(group_obj[pass_index],1); marker_array[marker_count] = group_obj[pass_index]; marker_count = marker_count + 1; } offset_mark(double pass_index) { point pnt, test; double save_x, save_y; current_selection=newselection("OBJECT"); select(current_selection,group_obj[pass_index]); sel_push(current_selection); var_push(sv); run_command("OFFSET"); deselect(current_selection); current_object=last_obj(); marker_array[marker_count] = marker_piece(current_object,1); current_selection=newselection("OBJECT"); select(current_selection, marker_array[marker_count]); select(current_selection, group_obj[pass_index]); marker_count = marker_count + 1; }