// Copyright (C) 2001 Leena L�hteenm�ki, Finland // Copyright (C) 2012 PatternMaker Software // 2012/08/14 double index, done; object marker_array[20]; double marker_count, loop; double result; double x[200], y[100]; object group_obj[100]; object current_object; point current_point; selection current_selection; double language; double vy,yly,aly,ylk,alk; double emlk,emls, tml,sml,pit; double malli,curvefrom,vekki; double waist,zipper,halkio,halkiok,halkiol,tasku; double eleveys,tleveys, epaikkak,epaikkas,tpaikka; double siirtox, siirtoy; double ang,ang2,ang3,rotaatio; double sv, f_sv[2]; double laskos_v, laskos_y, laskos_l, laskosvara_v, laskosvara_y, laskosvara_l; double metric; double ease, f_vy[3],f_yly[3],f_aly[3]; double vy_kellotus, sivun_kellotus; double korotus, model; main() { language=get_language(); if ( language != 0 ) { language = 0; } if (language == 0) { check_reg(0, "Leena","Maternity", "This macro needs to be properly installed before running it."); } vy=78; yly=95; aly=102; ylk=9; alk=19; zipper=20; halkiok=18; sv=1; pit=60; halkiol=5; malli=0; vy_kellotus=6; korotus=3; // index = 0; //Start Options while (!done) { if (index==0) { Popup1(); } if (index==1) { Popup2(); } } //End Options if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { vy=vy/2.54; yly=yly/2.54; aly=aly/2.54; ylk=ylk/2.54; alk=alk/2.54; pit=pit/2.54; zipper=zipper/2.54; halkiok=halkiok/2.54; korotus=korotus/2.54; vy_kellotus=vy_kellotus/2.54; sivun_kellotus=sivun_kellotus/2.54; sv=sv/2.54; } } else { if (language == 0) { metric=2*pop_up("Units","Inches","Centimeters"); } if (metric<1) { vy=vy/2.54; yly=yly/2.54; aly=aly/2.54; ylk=ylk/2.54; alk=alk/2.54; pit=pit/2.54; zipper=zipper/2.54; halkiok=halkiok/2.54; korotus=korotus/2.54; vy_kellotus=vy_kellotus/2.54; sivun_kellotus=sivun_kellotus/2.54; sv=sv/2.54; } } if(metric==0) { sv=0.39; } double read; read = 0; if (is_function("measure_table")==1) { if (measure_table("default_women")==1) { read = 1; } } if (read==0) { if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("JUNIORS' FITTING SHELL"); } if (language == 0) { add_picture_input("Abdomen Circ.",yly, "w_meas_abdmcirc"); } if (language == 0) { add_picture_input("Hip Circ.",aly, "w_meas_hipcirc"); } if (language == 0) { add_picture_input("Waist - Abdomen",ylk, "w_meas_waist-abdm"); } if (language == 0) { add_picture_input("Waist - Hip",alk, "w_meas_waist-hip"); } if (language == 0) { add_picture_input("Length from Waist",pit, "w_meas_waistht"); } if (language == 0) { add_picture_input("Zipper Length",zipper, "w_meas_zipper"); } run_picture_input(); } else { if (language == 0) { dialog_box( "MATERNITY SKIRT", "Abdomen Circ.",yly, "Hip Circ.",aly, "Waist - Abdomen",ylk, "Waist - Hip",alk, "Length from Waist",pit, "Zipper Length",zipper); } } } if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("JUNIORS' FITTING SHELL"); } if (language == 0) { add_picture_input("Back vent height",halkiok,""); } if (language == 0) { add_picture_input("Added Front height",korotus, ""); } if (language == 0) { add_picture_input("Added Front width",vy_kellotus, ""); } if (language == 0) { add_picture_input("Seam allowance", sv, "meas_seamallow"); } run_picture_input(); } else { if (language == 0) { dialog_box( "CUSTOM MEASUREMENTS", "Back vent height",halkiok, "Added Front height",korotus, "Added Front width",vy_kellotus, "Seam Allowance",sv); } } if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { vy=vy*2.54; yly=yly*2.54; aly=aly*2.54; ylk=ylk*2.54; alk=alk*2.54; pit=pit*2.54; zipper=zipper*2.54; halkiok=halkiok*2.54; korotus=korotus*2.54; vy_kellotus=vy_kellotus*2.54; sivun_kellotus=sivun_kellotus*2.54; } } else { if (metric<1) { vy=vy*2.54; yly=yly*2.54; aly=aly*2.54; ylk=ylk*2.54; alk=alk*2.54; pit=pit*2.54; zipper=zipper*2.54; halkiok=halkiok*2.54; korotus=korotus*2.54; vy_kellotus=vy_kellotus*2.54; sivun_kellotus=sivun_kellotus*2.54; } } if(metric==2) { sv=sv/2.54; } f_vy[0]=vy+2; f_yly[0]=yly+4; f_aly[0]=aly+4; f_vy[1]=vy+1; f_yly[1]=yly+2; f_aly[1]=aly+2; f_vy[2]=vy+3; f_yly[2]=yly+6; f_aly[2]=aly+6; vy=f_vy[ease]; yly=f_yly[ease]; aly=f_aly[ease]; eleveys=aly/4+1.5; tleveys=aly/4-1.5; vy=aly-2; double test; test=aly-vy; if (test>32) { emlk=2; emls=2; tml=2.5; sml=(aly/2-vy/2-emlk-emls-tml); epaikkas=eleveys-sml/2-4; epaikkak=eleveys-sml/2-4-emls-4; tpaikka=(tleveys-sml/2)/2+tml/2; } else { emlk=0; emls=2; tml=2.5; sml=(aly/2-vy/2-emlk-emls-tml); epaikkas=eleveys-sml/2-vy/10; tpaikka=(tleveys-sml/2)/2+tml/2; } if(waist==1) { emlk=0; emls=0; tml=0; sml=0; } x[0]=0; y[0]=0; coord(0,1,0,0); coord(1,2,0,-ylk); coord(1,3,0,-alk); coord(1,4,0,-pit); coord(4,5,eleveys-1,0); coord(3,6,eleveys,0); x[7]=x[6]; y[7]=y[2]; coord(1,8,eleveys-sml/2,1); coord(8,9,sml,0); x[10]=x[6]; y[10]=y[2]; coord(6,11,0,0); coord(11,12,+1,-(pit-alk)); coord(12,13,tleveys-1,0); coord(11,14,tleveys,0); coord(14,15,0,alk-ylk); coord(14,16,0,alk); coord(16,17,-tpaikka,0); coord(17,18,-tml/2,-ylk-(alk-ylk)/2); coord(17,19,-tml,0); coord(1,20,epaikkas,0); coord(20,21,-emls/2,-ylk); coord(20,22,-emls,0); coord(22,23,-4,0); coord(23,24,-emlk/2,-ylk); coord(23,25,-emlk,0); coord(13,26,halkiol,0); coord(26,27,0,halkiok); coord(27,28,-halkiol,0); coord(16,29,0,-zipper); coord(29,30,3,0); coord(16,31,3,0); cont(11,12,32,-halkiok); coord(32,33,-halkiol,0); coord(12,34,-halkiol,0); cont(6,5,35,-halkiok); coord(35,36,halkiol,0); coord(5,37,halkiol,0); cont(3,4,38,-halkiok); coord(38,39,-halkiol,0); coord(4,40,-halkiol,0); x[8]=x[8]-3; x[9]=x[9]+3; coord(1,50,10,korotus); coord(2,51,0,0); coord(1,52,0,korotus); rotate(50,3,vy_kellotus/dist(3,50)); rotate(51,3,vy_kellotus/dist(3,51)); rotate(52,3,vy_kellotus/dist(3,52)); y[52]=y[50]; y[20]=y[20]+korotus-2; x[53]=x[52]; y[53]=y[3]; center(20,50,54); x[41] = x[7]; y[41] = y[20]- interceptline(x[7],x[20],16.5); coord(16,55,0,3.5); coord(55,56,0,3.5); coord(17,57,0,7); coord(9,58,0,7); coord(9,59,0,3.5); coord(17,60,0,3.5); coord(8,61,0,3.5); coord(61,62,0,3.5); coord(20,63,0,7); coord(54,64,0,7); coord(54,65,0,3.5); coord(20,66,0,3.5); coord(8,67,-dist(52,50)-dist(50,54)-dist(54,20),0); coord(8,68,dist(52,50)+dist(50,54)+dist(54,20),0); coord(68,69,0,7); coord(8,70,0,7); coord(67,71,0,7); siirtox=-45; current_object=newobject("poly"); addpoint((x[20]+siirtox)/2.54, (y[20]+siirtoy)/2.54, "line"); addpoint((x[41]+siirtox)/2.54, (y[41]+siirtoy)/2.54, "open"); group_obj[1]=current_object; current_object=newobject("poly"); addpoint((x[6]+siirtox)/2.54, (y[6]+siirtoy)/2.54, "line"); addpoint((x[41]+siirtox)/2.54, (y[41]+siirtoy)/2.54, "line"); addpoint((x[8]+siirtox)/2.54, (y[8]+siirtoy)/2.54, "line"); current_point=addpoint((x[61]+siirtox)/2.54, (y[61]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[62]+siirtox)/2.54, (y[62]+siirtoy)/2.54, "line"); addpoint((x[63]+siirtox)/2.54, (y[63]+siirtoy)/2.54, "line"); addpoint((x[64]+siirtox)/2.54, (y[64]+siirtoy)/2.54, "line"); current_point=addpoint((x[65]+siirtox)/2.54, (y[65]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[54]+siirtox)/2.54, (y[54]+siirtoy)/2.54, "xarc_start"); addpoint((x[53]+siirtox)/2.54, (y[53]-5+siirtoy)/2.54, "xarc_corner"); group_obj[2]=current_object; current_object=newobject("poly"); addpoint((x[8]+siirtox)/2.54, (y[8]+siirtoy)/2.54, "line"); addpoint((x[20]+siirtox)/2.54, (y[20]+siirtoy)/2.54, "line"); addpoint((x[54]+siirtox)/2.54, (y[54]+siirtoy)/2.54, "open"); group_obj[3]=current_object; if (language == 0) { current_object=newobject("text","Pocket bag, cut 2",0.0,0.4,0.2,"SIMP.CHR"); } addpoint((x[54]+siirtox)/2.54, (y[7]+siirtoy)/2.54, "line"); group_obj[4]=current_object; if(sv>0) { offset_mark(2); select(current_selection,group_obj[1]); select(current_selection,group_obj[3]); select(current_selection,group_obj[4]); group(current_selection); deselect(current_selection); } else { mark(2); current_selection=newselection("OBJECT"); select(current_selection,group_obj[2]); select(current_selection,group_obj[1]); select(current_selection,group_obj[3]); select(current_selection,group_obj[4]); group(current_selection); deselect(current_selection); } siirtoy=-30; current_object=newobject("poly"); addpoint((x[20]+siirtox)/2.54, (y[20]+siirtoy)/2.54, "line"); addpoint((x[54]+siirtox)/2.54, (y[54]+siirtoy)/2.54, "xarc_start"); addpoint((x[53]+siirtox)/2.54, (y[53]-5+siirtoy)/2.54, "xarc_corner"); addpoint((x[6]+siirtox)/2.54, (y[6]+siirtoy)/2.54, "line"); addpoint((x[41]+siirtox)/2.54, (y[41]+siirtoy)/2.54, "line"); group_obj[5]=current_object; if (language == 0) { current_object=newobject("text","Pocket lining, cut 2",0.0,0.4,0.2,"SIMP.CHR"); } addpoint((x[54]-3+siirtox)/2.54, (y[41]+siirtoy)/2.54, "line"); group_obj[6]=current_object; if(sv>0) { offset_mark(5); select(current_selection,group_obj[6]); group(current_selection); deselect(current_selection); } else { mark(5); current_selection=newselection("OBJECT"); select(current_selection,group_obj[5]); select(current_selection,group_obj[6]); group(current_selection); deselect(current_selection); } siirtox=0; siirtoy=14; current_object=newobject("poly"); addpoint((x[67]+siirtox)/2.54, (y[67]+siirtoy)/2.54, "line"); current_point=addpoint((x[71]+siirtox)/2.54, (y[71]-3.5+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",0); addpoint((x[71]+siirtox)/2.54, (y[71]+siirtoy)/2.54, "line"); current_point=addpoint((x[70]+siirtox)/2.54, (y[70]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",0); addpoint((x[69]+siirtox)/2.54, (y[69]+siirtoy)/2.54, "line"); current_point=addpoint((x[69]+siirtox)/2.54, (y[69]-3.5+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",0); addpoint((x[68]+siirtox)/2.54, (y[68]+siirtoy)/2.54, "line"); current_point=addpoint((x[8]+siirtox)/2.54, (y[8]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",0); group_obj[7]=current_object; if (language == 0) { current_object=newobject("text","Waistband, front, cut 1",0.0,0.4,0.2,"SIMP.CHR"); } addpoint((x[71]+1+siirtox)/2.54, (y[71]-1+siirtoy)/2.54, "line"); group_obj[8]=current_object; if (language == 0) { current_object=newobject("text","CF",0.0,0.4,0.2,"SIMP.CHR"); } addpoint((x[8]+siirtox)/2.54, (y[8]+1+siirtoy)/2.54, "line"); group_obj[9]=current_object; if(sv>0) { offset_mark(7); select(current_selection,group_obj[8]); select(current_selection,group_obj[9]); group(current_selection); deselect(current_selection); } else { mark(7); 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); } siirtox=0; siirtoy=0; current_object=newobject("poly"); if(model==0) { addpoint((x[52]+siirtox)/2.54, (y[52]+siirtoy)/2.54, "xarc_start"); addpoint((x[53]+siirtox)/2.54, (y[53]+siirtoy)/2.54, "xarc_corner"); addpoint((x[4]+siirtox)/2.54, (y[4]+siirtoy)/2.54, "line"); addpoint((x[5]+siirtox)/2.54, (y[5]+siirtoy)/2.54, "line"); current_point=addpoint((x[6]+siirtox)/2.54, (y[6]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[41]+siirtox)/2.54, (y[41]+siirtoy)/2.54, "line"); addpoint((x[20]+siirtox)/2.54, (y[20]+siirtoy)/2.54, "line"); current_point=addpoint((x[54]+siirtox)/2.54, (y[54]+siirtoy)/2.54, "xarc_start"); notch_type(current_point,"NOTCH",1); addpoint((x[50]+siirtox)/2.54, (y[50]+siirtoy)/2.54, "xarc_corner"); } else { addpoint((x[4]+siirtox)/2.54, (y[4]+siirtoy)/2.54, "line"); addpoint((x[5]+siirtox)/2.54, (y[5]+siirtoy)/2.54, "line"); current_point=addpoint((x[6]+siirtox)/2.54, (y[6]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[41]+siirtox)/2.54, (y[41]+siirtoy)/2.54, "line"); addpoint((x[20]+siirtox)/2.54, (y[20]+siirtoy)/2.54, "xarc_start"); addpoint((x[20]+siirtox)/2.54, (y[53]+siirtoy)/2.54, "xarc_corner"); addpoint((x[53]+1.3+siirtox)/2.54, (y[53]+siirtoy)/2.54, "line"); } group_obj[10]=current_object; if (language == 0) { current_object=newobject("text","Front piece, CF, cut 2",-1.570796,0.4,0.2,"SIMP.CHR"); } addpoint((x[53]+4+siirtox)/2.54, (y[53]-2+siirtoy)/2.54, "line"); group_obj[11]=current_object; if(sv>0) { if (language == 0) { current_object=newobject("text","Check hem seam allowance",0.0,0.4,0.2,"SIMP.CHR"); } addpoint((x[4]+1+siirtox)/2.54, (y[4]+1+siirtoy)/2.54, "line"); group_obj[12]=current_object; } if(sv>0) { offset_mark(10); select(current_selection,group_obj[11]); select(current_selection,group_obj[12]); group(current_selection); deselect(current_selection); } else { mark(10); current_selection=newselection("OBJECT"); select(current_selection,group_obj[10]); select(current_selection,group_obj[11]); group(current_selection); deselect(current_selection); } siirtox=-6; siirtoy=6; if(model==1) { current_object=newobject("poly"); addpoint((x[20]+siirtox)/2.54, (y[20]+siirtoy)/2.54, "xarc_start"); addpoint((x[20]+siirtox)/2.54, (y[53]+siirtoy)/2.54, "xarc_corner"); addpoint((x[53]+1.3+siirtox)/2.54, (y[53]+siirtoy)/2.54, "line"); addpoint((x[52]+siirtox)/2.54, (y[52]+siirtoy)/2.54, "xarc_start"); addpoint((x[50]+siirtox)/2.54, (y[50]+siirtoy)/2.54, "xarc_corner"); addpoint((x[54]+siirtox)/2.54, (y[54]+siirtoy)/2.54, "line"); group_obj[18]=current_object; if (language == 0) { current_object=newobject("text","Embedded front piece, cut 2",0.0,0.4,0.2,"SIMP.CHR"); } addpoint((x[52]+1+siirtox)/2.54, (y[52]-6+siirtoy)/2.54, "line"); group_obj[19]=current_object; if(sv>0) { offset_mark(18); select(current_selection,group_obj[19]); group(current_selection); deselect(current_selection); } else { mark(18); current_selection=newselection("OBJECT"); select(current_selection,group_obj[18]); select(current_selection,group_obj[19]); group(current_selection); deselect(current_selection); } } siirtox=2*sv+2*halkiol; siirtoy=0; current_object=newobject("poly"); current_point=addpoint((x[55]+siirtox)/2.54, (y[55]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[56]+siirtox)/2.54, (y[56]+siirtoy)/2.54, "line"); addpoint((x[57]+siirtox)/2.54, (y[57]+siirtoy)/2.54, "line"); addpoint((x[58]+siirtox)/2.54, (y[58]+siirtoy)/2.54, "line"); current_point=addpoint((x[59]+siirtox)/2.54, (y[59]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[9]+siirtox)/2.54, (y[9]+siirtoy)/2.54, "xarc_start"); addpoint((x[10]+siirtox)/2.54, (y[10]+siirtoy)/2.54, "xarc_corner"); current_point=addpoint((x[11]+siirtox)/2.54, (y[11]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[12]+siirtox)/2.54, (y[12]+siirtoy)/2.54, "line"); current_point=addpoint((x[13]+siirtox)/2.54, (y[13]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[26]+siirtox)/2.54, (y[26]+siirtoy)/2.54, "line"); addpoint((x[27]+siirtox)/2.54, (y[27]+siirtoy)/2.54, "line"); addpoint((x[28]+siirtox)/2.54, (y[28]+siirtoy)/2.54, "line"); addpoint((x[14]+siirtox)/2.54, (y[14]+siirtoy)/2.54, "line"); addpoint((x[15]+siirtox)/2.54, (y[15]+siirtoy)/2.54, "line"); addpoint((x[16]+siirtox)/2.54, (y[16]+siirtoy)/2.54, "line"); group_obj[14]=current_object; current_object=newobject("poly"); current_point=addpoint((x[16]+siirtox)/2.54, (y[16]+siirtoy)/2.54, "xarc_start"); current_point=addpoint((x[17]+siirtox)/2.54, (y[17]+siirtoy)/2.54, "xarc_corner"); current_point=addpoint((x[9]+siirtox)/2.54, (y[9]+siirtoy)/2.54, "open"); group_obj[15]=current_object; if (language == 0) { current_object=newobject("text","Center Back Piece, Cut 2, CB",-1.570796,0.1,0.2,"SIMP.CHR"); } addpoint((x[16]-1+siirtox)/2.54, (y[2]+3+siirtoy)/2.54, "line"); group_obj[17]=current_object; if(sv>0) { if (language == 0) { current_object=newobject("text","Check hem seam allowance",0.0,0.4,0.2,"SIMP.CHR"); } addpoint((x[12]+1+siirtox)/2.54, (y[12]+1+siirtoy)/2.54, "line"); group_obj[18]=current_object; } if(sv>0) { offset_mark(14); select(current_selection,group_obj[15]); select(current_selection,group_obj[17]); select(current_selection,group_obj[18]); group(current_selection); deselect(current_selection); } else { mark(14); current_selection=newselection("OBJECT"); select(current_selection,group_obj[14]); select(current_selection,group_obj[15]); select(current_selection,group_obj[17]); group(current_selection); deselect(current_selection); } current_selection=newselection("OBJECT"); for (loop = 0; loop < 20; loop = loop + 1) { if (marker_array[loop] != 0) { select(current_selection, marker_array[loop]); } } check_overlap(current_selection); if (is_function("origin_arrange")==1) { origin_arrange(current_selection); } deselect(current_selection); if (is_function("set_marker")==1) { for (loop = 0; loop < 20; loop = loop + 1) { if (marker_array[loop] != 0) { set_marker(marker_array[loop], 0); } } } run_command("zoomall"); } newobj_dot(double x, double y) { object temp; line("CENTER_LINE"); temp = newobject("poly"); addpoint(x, y, "line"); line("SOLID_LINE"); return temp; } 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; } Forward() { index = index + 1; if (index == 2) { done = 1; } } Backward() { index = index - 1; } Popup1() { if (language == 0) { start_pict_dialog("HIP EASE"); add_pict_item("Normal (+1.5in/+4cm)","blank.jpg"); add_pict_item("Minimum (+0.75in/+2 cm)","blank.jpg"); add_pict_item("Maximum (+2.5in/+6 cm)","blank.jpg"); run_pict("Next"); ease=get_pict_result(); Forward(); } } Popup2() { if (language == 0) { start_pict_dialog("SKIRT MODEL"); add_pict_item("Plain front","mn_skirt_plain.jpg"); add_pict_item("Elastic panel","mn_skirt_panel.jpg"); if (run_pict("Back","Next")) { model=get_pict_result(); Forward(); } else { model=0; Backward(); } } } shift(double orig, double xxx, double yyy) { x[orig]=x[orig]+xxx; y[orig]=y[orig]+yyy; } 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(); } right_ang(double start, double end, double to_point, double dest) { double m,b; if (x[start]==x[end]) { x[dest]=x[end]; y[dest]=y[to_point]; } else { if (y[start]==y[end]) { x[dest]=x[to_point]; y[dest]=y[end]; } else { m=(y[start]-y[end])/(x[start]-x[end]); m=-1/m; b=y[to_point]-m*x[to_point]; intersect(x[start],y[start],x[end],y[end],x[to_point],y[to_point],0,b,0); x[dest]=getresultx(); y[dest]=getresulty(); } } } rect (double x1, double y1, double x2, double y2) { current_object=newobject("poly"); addpoint( x1/2.54,y1/2.54,"LINE"); addpoint( x2/2.54,y1/2.54,"LINE"); addpoint( x2/2.54,y2/2.54,"LINE"); addpoint( x1/2.54,y2/2.54,"LINE"); } dot (double x, double y) { current_object=newobject("poly"); addpoint( x/2.54,y/2.54,"LINE"); } 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) { double mslope, dist0, dist1, dist2, xtemp; double tx, ty; xtemp = (x[PB]-x[PC])*(x[PB]-x[PC]); if (xtemp > 0) { xtemp = (y[PB]-y[PC])*(y[PB]-y[PC]); if ( xtemp > 0) { mslope = (y[PC] - y[PB])/(x[PC] - x[PB]); tx = x[PA] + 1; ty = y[PA] - 1/mslope; 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); dist2 = interceptline(0, dist1, dradius); dist0 = sqrt(1+mslope*mslope); xtemp = dist2/dist0; if (which) { x[PD] = tx+xtemp; y[PD] = ty+ xtemp*mslope; } else { x[PD] = tx-xtemp; y[PD] = ty- xtemp*mslope; } } else { 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 { 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); } } } double xar[13], yar[13]; double save_rx, save_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 (ct=1; ct < 12; ct = ct + 1) { fts(start, corner, end, ct); a_dist = a_dist + distance(save_rx, save_ry, last_x, last_y); last_x=save_rx; last_y=save_ry; } return a_dist; } double A1, A2, B1, B2; 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) { save_rx=x[start]; save_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]); save_rx = t0[0]*(xar[pos])+t0[1]*(yar[pos])+ ftc[0]; save_ry = t1[0]*(xar[pos])+t1[1]*(yar[pos])+ ftc[1]; } else { if (pos>10) { save_rx=x[end]; save_ry=y[end]; } else { save_rx = t0[0]*(xar[pos])+t0[1]*(yar[pos])+ ftc[0]; save_ry = t1[0]*(xar[pos])+t1[1]*(yar[pos])+ ftc[1]; } } } } init_xarc_array() { 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; } } 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; } } normalizeangle(double aa) { double loop; loop=aa; for(; (0 > aa); aa = aa + 2*3.14159) { ; } for(; (2*3.14159 < aa); aa = aa - 2*3.14159) { ; } return(aa); }