// Copyright (C) 2001 Leena L�hteenm�ki, Finland // Copyright (C) 2012 PatternMaker Software // 2011/11/04 // 2018/10/23 Edited to FB ENG //nvl lis�tty 1.11. //saumanvarat //ryhmittely double version; double index, done; double x[100], y[100]; object current_object; point current_point; selection current_selection; object group_obj[200]; //VARIABLES double ang,ang2,vang,vdistance,rangle; double sv; double siirtox, siirtoy; double language; double ry, vy, ktk, vk, ky, sl, pit, hp, kay, ray, ktl; double ktpe, ktpt, ktp; double metric; double ease, f_ry[9], f_vy[9], f_ky[9],f_sl[9]; double f_ktk[9]; double f_kay[9],f_ray[9],f_hp[9]; double ktle, ktlt, nvl; double pts, pts_lis, ptl, ptl_lis; main() { init_xarc_array(); language=get_language(); if ( language != 0 ) { language = 0; } //Default measurements ry=100; vy=86; ktk=24.4; vk=44.6; ky=40; sl=40; pit=35; hp=65.4; kay=40; ray=17.6; nvl=0; sv=0; pts_lis=0; ptl_lis=0; //Start Options while (!done) { if (index == 0) { StyleEase(); } } //End Options //MEASUREMENT UNITS //==================== if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { pts_lis=pts_lis/2.54; ptl_lis=ptl_lis/2.54; nvl=nvl/2.54; ry=ry/2.54; vy=vy/2.54; ktk=ktk/2.54; vk=vk/2.54; ky=ky/2.54; sl=sl/2.54; hp=hp/2.54; kay=kay/2.54; ray=ray/2.54; pit=pit/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 { pts_lis=pts_lis/2.54; ptl_lis=ptl_lis/2.54; nvl=nvl/2.54; ry=ry/2.54; vy=vy/2.54; ktk=ktk/2.54; vk=vk/2.54; ky=ky/2.54; sl=sl/2.54; hp=hp/2.54; kay=kay/2.54; ray=ray/2.54; pit=pit/2.54; sv=sv/2.54; } } if(metric==0) { sv=0.39; } //Measurements table double read; read = 0; if (is_function("measure_table")==1) { if (measure_table("default_men")==1) { read = 1; } } if (read==0) { if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("BODICE FOR MEN"); } if (language == 0) { add_picture_input("Chest circumference",ry, "m_chest_circumference"); } if (language == 0) { add_picture_input("Waist circumference",vy, "m_waist_circumference_shirt"); } if (language == 0) { add_picture_input("Back length",vk, "m_back_length"); } if (language == 0) { add_picture_input("Neck circumference",ky, "m_neck_circumference"); } if (language == 0) { add_picture_input("Back width",sl, "m_back_width"); } if (language == 0) { add_picture_input("Overarm length",hp, "m_arm_length"); } if (language == 0) { add_picture_input("Biceps circumference",kay, "m_meas_biceps"); } if (language == 0) { add_picture_input("Cuff circumference",ray, "m_cuff_circumference_jacket"); } run_picture_input(); } else { //MEASUREMENTS DIALOG BOX if (language == 0) { dialog_box( "MENS' BODICE", "Chest circumference",ry, "Waist circumference",vy, "Back length",vk, "Neck circumference",ky, "Back width",sl, "Overarm length",hp, "Biceps circumference", kay, "Cuff circumference", ray); } } } if (is_function("start_picture_input")) { ; /* if (language == 0) { start_picture_input("MENS' BODICE"); } if (language == 0) { add_picture_input("Button extension width",nvl, ); } if (language == 0) { add_picture_input("Length from waist",pit, ; } run_picture_input(); */ } else { if (language == 0) { dialog_box("MENS' BODICE", "Button extension width",nvl, "Length from waist",pit); } } if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { pts_lis=pts_lis*2.54; ptl_lis=ptl_lis*2.54; nvl=nvl*2.54; ry=ry*2.54; vy=vy*2.54; ktk=ktk*2.54; vk=vk*2.54; ky=ky*2.54; sl=sl*2.54; hp=hp*2.54; kay=kay*2.54; ray=ray*2.54; pit=pit*2.54; sv=sv*2.54; } } else { if (metric<1) // If inches, convert cm to inches for dialog box { pts_lis=pts_lis*2.54; ptl_lis=ptl_lis*2.54; nvl=nvl*2.54; ry=ry*2.54; vy=vy*2.54; ktk=ktk*2.54; vk=vk*2.54; ky=ky*2.54; sl=sl*2.54; hp=hp*2.54; kay=kay*2.54; ray=ray*2.54; pit=pit*2.54; sv=sv*2.54; } } if(metric==2) { sv=sv/2.54; } if (ry < 92) { ktk=22; } else { if (ry < 96) { ktk=22.8; } else { if (ry < 100) { ktk=23.6; } else { if (ry < 104) { ktk=24.4; } else { if (ry < 108) { ktk=25.3; } else { if (ry < 112) { ktk=26.4; } else { if (ry < 116) { ktk=26.8; } else { if (ry < 120) { ktk=27.2; } else { if (ry < 124) { ktk=27.6; } else { if (ry < 128) { ktk=28; } else { if (ry < 132) { ktk=28.4; } else { ktk=28.8; } } } } } } } } } } } //EASE / +8 f_ry[2]=ry+8; f_vy[2]=vy+6; f_ky[2]=ky; f_sl[2]=sl+1.6; f_ktk[2]=ktk; f_kay[2]=kay+6; f_ray[2]=ray+6; f_hp[2]=hp; ry=f_ry[ease]; vy=f_vy[ease]; ky=f_ky[ease]; sl=f_sl[ease]; ktk=f_ktk[ease]; kay=f_kay[ease]; ray=f_ray[ease]; pts=pts+pts_lis; ptl=ptl+ptl_lis; //op=op-ptl_lis; x[0]=0; y[0]=0; //1 coord(0,1,0,-ktk-3); //2 coord(0,2,0,-vk-1); //3 coord(2,3,0,-pit-1); //4 coord(2,4,0,-21); //5 coord(0,5,0,-ktk/2-1); //6 coord(0,6,0,-dist(0,5)/2); //7 coord(0,7,ky/4-1.5,0); //8 coord(7,8,0,2); //9 coord(1,9,sl/2+2,0); //10 x[10]=x[9]; y[10]=y[5]; //11 x[11]=x[9]; y[11]=y[6]; //12 coord(11,12,0,2); //13 coord(12,13,2,0); //14 coord(10,14,0,-1.5); //15 coord(9,15,0,dist(9,10)/2); //16 coord(15,16,.5,0); //17 coord(9,17,-2.5,0); //18 x[18]=x[17]; y[18]=y[3]; //19 coord(1,19,ry/2+7.5,0); //20 x[20]=x[19]; y[20]=y[0]; //21 x[21]=x[19]; y[21]=y[2]; //22 x[22]=x[19]; y[22]=y[3]; //23 coord(22,23,0,-2); //24 coord(1,24,ry/3+1,0); //25 coord(24,25,-dist(9,24)/2-1,0); //26 x[26]=x[25]-1; y[26]=y[3]; //27 coord(24,27,0,2.5); //28 coord(20,28,-(ky/4-2),0); //29 coord(20,29,0,-(ky/5+1)); //30 cont(11,28,30,-(dist(8,13)-0.7)); //31 coord(30,31,0,-1.75); //32 coord(31,32,0,-2*dist(31,27)/3); //etuhiha-aukon pisteit� //33 coord(32,33,2,0); //34 center(33,31,34); x[34]=x[33]; //35 cont(34,33,35,50); line_intersect(25,19,34,35,35); //takahiha-aukon pisteit� //36 center(14,13,36); x[36]=x[14]; //39 center(14,15,39); //etuhelman piste //37 center(23,26,37); y[37]=y[23]; //sivuvy�t�r�piste //38 x[38]=x[26]; y[38]=y[2]; //saumanvaran poisto x[8]=x[8]+1; x[7]=x[7]+1; x[13]=x[13]-1.3; x[36]=x[36]-1; x[39]=x[39]-1; x[9]=x[9]-1; x[31]=x[31]+1.3; x[34]=x[34]+1; x[33]=x[33]+1; x[35]=x[35]+1; x[28]=x[28]-1; y[0]=y[0]-1; y[8]=y[8]-1.5; y[7]=y[7]-1; y[13]=y[13]-.5; y[9]=y[9]-1; y[25]=y[25]-1; y[35]=y[35]-1; y[31]=y[31]-.6; y[28]=y[28]-1.5; y[29]=y[29]-1; //etukappaleen vy�t�r� ja helma //40 coord(38,40,2,0); //41 coord(26,41,2,0); ktpt=arclength(25,9,39)+arclength(39,36,13); ktlt=dist(9,25); //debug(1); //takakappale current_object=newobject("poly"); addpoint((x[0]+siirtox)/2.54, (y[0]+siirtoy)/2.54, "xarc_start"); addpoint((x[7]+siirtox)/2.54, (y[7]+siirtoy)/2.54, "xarc_corner"); addpoint((x[8]+siirtox)/2.54, (y[8]+siirtoy)/2.54, "line"); addpoint((x[13]+siirtox)/2.54, (y[13]+siirtoy)/2.54, "xarc_start"); addpoint((x[36]+siirtox)/2.54, (y[36]+siirtoy)/2.54, "xarc_corner"); addpoint((x[39]+siirtox)/2.54, (y[39]+siirtoy)/2.54, "xarc_start"); addpoint((x[9]+siirtox)/2.54, (y[9]+siirtoy)/2.54, "xarc_corner"); addpoint((x[25]+siirtox)/2.54, (y[25]+siirtoy)/2.54, "line"); current_point=addpoint((x[38]+siirtox)/2.54, (y[38]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",0); addpoint((x[26]+siirtox)/2.54, (y[26]+siirtoy)/2.54, "line"); addpoint((x[3]+siirtox)/2.54, (y[3]+siirtoy)/2.54, "line"); addpoint((x[4]+siirtox)/2.54, (y[4]+siirtoy)/2.54, "line"); current_point=addpoint((x[2]+siirtox)/2.54, (y[2]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",0); current_point=addpoint((x[1]+siirtox)/2.54, (y[1]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",0); group_obj[0]=current_object; //saumanvara if (language == 0) { current_object=newobject("text","Patterns are without seam allowance",-1.570796,0.3,0.2,"SIMP.CHR"); } addpoint((x[0]+1+1+siirtox)/2.54, (y[0]-3)/2.54, "line"); group_obj[1]=current_object; //kt-teksti if (language == 0) { current_object=newobject("text","Center Back",-1.570796,0.2,0.2,"SIMP.CHR"); } addpoint((x[0]+1+siirtox)/2.54, (y[0]-3)/2.54, "line"); group_obj[2]=current_object; ktpe=arclength(25,35,33)+arclength(33,34,31); ktp=ktpt+ktpe; ktle=dist(25,24); //etukappale //debug(2); siirtox=4; current_object=newobject("poly"); addpoint((x[29]+siirtox)/2.54, (y[29]+siirtoy)/2.54, "xarc_start"); addpoint((x[28]+siirtox)/2.54, (y[29]+siirtoy)/2.54, "xarc_corner"); addpoint((x[28]+siirtox)/2.54, (y[28]+siirtoy)/2.54, "line"); addpoint((x[31]+siirtox)/2.54, (y[31]+siirtoy)/2.54, "xarc_start"); addpoint((x[34]+siirtox)/2.54, (y[34]+siirtoy)/2.54, "xarc_corner"); addpoint((x[33]+siirtox)/2.54, (y[33]+siirtoy)/2.54, "xarc_start"); addpoint((x[35]+siirtox)/2.54, (y[35]+siirtoy)/2.54, "xarc_corner"); addpoint((x[25]+siirtox)/2.54, (y[25]+siirtoy)/2.54, "line"); current_point=addpoint((x[40]+siirtox)/2.54, (y[40]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[41]+siirtox)/2.54, (y[41]+siirtoy)/2.54, "xarc_start"); addpoint((x[37]+siirtox)/2.54, (y[37]+siirtoy)/2.54, "xarc_corner"); addpoint((x[23]+siirtox)/2.54, (y[23]+siirtoy)/2.54, "line"); current_point=addpoint((x[21]+siirtox)/2.54, (y[21]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); current_point=addpoint((x[19]+siirtox)/2.54, (y[19]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); group_obj[3]=current_object; //napivara if(nvl>0) { current_object=newobject("poly"); addpoint((x[23]+siirtox)/2.54, (y[23]+siirtoy)/2.54, "line"); addpoint((x[23]+nvl+siirtox)/2.54, (y[23]+siirtoy)/2.54, "line"); current_point=addpoint((x[21]+nvl+siirtox)/2.54, (y[21]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); current_point=addpoint((x[19]+nvl+siirtox)/2.54, (y[19]+siirtoy)/2.54, "line"); notch_type(current_point,"NOTCH",1); addpoint((x[29]+nvl+siirtox)/2.54, (y[29]+siirtoy)/2.54, "line"); addpoint((x[29]+siirtox)/2.54, (y[29]+siirtoy)/2.54, "open"); group_obj[4]=current_object; } //KE-teksti if (language == 0) { current_object=newobject("text","Center Front",-1.570796,0.2,0.2,"SIMP.CHR"); } addpoint((x[29]-1+siirtox)/2.54, (y[29]-3)/2.54, "line"); group_obj[5]=current_object; siirtox=0; //HIHA ktl=dist(9,24)/2; double pk; pk=ktp/3; //**** korjaus hihanpy�ri� double pyorion_pituus_etu, pyorion_pituus_taka; pyorion_pituus_taka=arclength(9,23,26)+dist(26,25)+arclength(25,24,1); pyorion_pituus_etu=arclength(8,19,22)+dist(22,21)+arclength(21,20,1); x[8]=x[8]+(pyorion_pituus_etu-(ktpe+2)); x[9]=x[9]-(pyorion_pituus_taka-(ktpt+2)); //korj2 (muotolaskos) x[33]=x[33]-(pyorion_pituus_taka-(ktpt+2)); x[31]=x[31]-(pyorion_pituus_taka-(ktpt+2)); x[32]=x[32]-(pyorion_pituus_taka-(ktpt+2)); //1 coord(0,1,kay/2+4,0); //2 coord(1,2,0,-pk/3); //3 coord(2,3,0,-pk/3); //4 coord(3,4,0,-pk/3); //5 coord(1,5,0,-hp); //6 center(5,1,6); y[6]=y[6]-4; //7 coord(5,7,0,-3); coord(4,8,-kay/2,0); coord(4,9,kay/2,0); //lisays=sy�tt�varaa //coord(4,8,-sqrt(ktpe*ktpe-pk*pk)-.5,0); //coord(4,9,sqrt(ktpe*ktpe-pk*pk)+1,0); coord(5,10,-(kay/2)+2,0); coord(5,11,+(kay/2)-2,0); center(8,10,12); y[12]=y[6]; center(9,11,13); y[13]=y[6]; //14 //cont(12,10,14,1.5); //15 //center(5,10,15); //16 //center(5,7,16); //17 //coord(7,17,+(kay/4-2),0); //18 //cont(13,11,18,1.5); coord(8,19,ktl/2,0); coord(1,20,-5,0); //19 cont(19,20,21,-dist(19,20)/3); coord(8,19,ktle-2,0); //cont(20,19,22,-dist(19,20)/3); center(19,21,22); //23 coord(9,23,-ktl/4,0); //coord(9,23,-ktlt,0); coord(1,24,5,0); cont(23,24,25,-dist(23,24)/3); cont(24,23,26,-dist(23,24)/3); //24 coord(1,24,5,0); //25 cont(23,24,25,-dist(23,24)/3); //26 cont(24,23,26,-dist(23,24)/3); //27 //coord(5,27,-2,0); coord(5,27,0,0); //28 coord(6,28,0,0); rotate (28,27,-angle(x[6],y[6],x[27]+90*3.14159/180,y[27])); cont(28,27,28,-(ray/2-1)); //29 cont(28,27,29,+(ray/2+1)); //30 coord(12,30,2.5,0); //31 coord(13,31,.5,0); cont(30,28,28,.5); cont(13,29,29,.5); //32 coord(6,32,dist(12,13)/4+1,0); //33 coord(31,33,0,-2); cont(33,32,33,-dist(31,32)); //28 coord(27,28,-ray/2,0); //29 coord(27,29,ray/2,0); siirtox=kay+sl/2; current_object=newobject("poly"); addpoint((x[1]+siirtox)/2.54, (y[1]+siirtoy)/2.54, "xarc_start"); addpoint((x[20]+siirtox)/2.54, (y[20]+siirtoy)/2.54, "xarc_corner"); addpoint((x[21]+siirtox)/2.54, (y[21]+siirtoy)/2.54, "line"); addpoint((x[22]+siirtox)/2.54, (y[22]+siirtoy)/2.54, "xarc_start"); addpoint((x[19]+siirtox)/2.54, (y[19]+siirtoy)/2.54, "xarc_corner"); addpoint((x[8]+siirtox)/2.54, (y[8]+siirtoy)/2.54, "line"); //addpoint((x[30]+siirtox)/2.54, (y[30]+siirtoy)/2.54, "xarc_corner"); addpoint((x[28]+siirtox)/2.54, (y[28]+siirtoy)/2.54, "line"); addpoint((x[27]+siirtox)/2.54, (y[27]+siirtoy)/2.54, "line"); addpoint((x[29]+siirtox)/2.54, (y[29]+siirtoy)/2.54, "line"); //addpoint((x[33]+siirtox)/2.54, (y[33]+siirtoy)/2.54, "line"); //addpoint((x[32]+siirtox)/2.54, (y[32]+siirtoy)/2.54, "line"); //addpoint((x[31]+siirtox)/2.54, (y[31]+siirtoy)/2.54, "line"); addpoint((x[9]+siirtox)/2.54, (y[9]+siirtoy)/2.54, "xarc_start"); addpoint((x[23]+siirtox)/2.54, (y[23]+siirtoy)/2.54, "xarc_corner"); addpoint((x[26]+siirtox)/2.54, (y[26]+siirtoy)/2.54, "line"); addpoint((x[25]+siirtox)/2.54, (y[25]+siirtoy)/2.54, "xarc_start"); addpoint((x[24]+siirtox)/2.54, (y[24]+siirtoy)/2.54, "xarc_corner"); group_obj[6]=current_object; //keskiviiva current_object=newobject("poly"); addpoint((x[6]+siirtox)/2.54, (y[6]-10+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[1]+siirtox)/2.54, (y[1]+siirtoy)/2.54, "open"); group_obj[7]=current_object; //teksti if (language == 0) { current_object=newobject("text","Sleeve Front",0.0,0.2,0.2,"SIMP.CHR"); } addpoint((x[19]+3+siirtox)/2.54, (y[19]+2+siirtoy)/2.54, "line"); group_obj[8]=current_object; //teksti if (language == 0) { current_object=newobject("text","Sleeve Back",0.0,0.2,0.2,"SIMP.CHR"); } addpoint((x[26]-3+siirtox)/2.54, (y[19]+2+siirtoy)/2.54, "line"); group_obj[9]=current_object; //teksti if (language == 0) { current_object=newobject("text","Sleeve Shoulder",-1.570796,0.2,0.2,"SIMP.CHR"); } addpoint((x[1]+siirtox)/2.54, (y[1]-1+siirtoy)/2.54, "line"); group_obj[10]=current_object; group_obj[0]=marker_piece(group_obj[0],1); current_selection=newselection("OBJECT"); select(current_selection,group_obj[0]); select(current_selection,group_obj[1]); select(current_selection,group_obj[2]); group(current_selection); deselect(current_selection); group_obj[3]=marker_piece(group_obj[3],1); current_selection=newselection("OBJECT"); select(current_selection,group_obj[3]); if (group_obj[4] != 0) { select(current_selection,group_obj[4]); } select(current_selection,group_obj[5]); group(current_selection); deselect(current_selection); group_obj[6]=marker_piece(group_obj[6],1); current_selection=newselection("OBJECT"); select(current_selection,group_obj[6]); select(current_selection,group_obj[7]); select(current_selection,group_obj[8]); select(current_selection,group_obj[9]); select(current_selection,group_obj[10]); group(current_selection); deselect(current_selection); current_selection=newselection("OBJECT"); select(current_selection,group_obj[0]); select(current_selection,group_obj[3]); select(current_selection,group_obj[6]); check_overlap(current_selection); if (is_function("origin_arrange")==1) { origin_arrange(current_selection); } deselect(current_selection); set_marker(group_obj[0], 0); set_marker(group_obj[3], 0); set_marker(group_obj[6], 0); run_command("zoomall"); //LOPPU } StyleEase() { if (language == 0) { start_pict_dialog("CHEST EASE"); add_pict_item("8cm / 3 inch","Fitting bodice for men.jpg"); run_pict("Next"); // ease=get_pict_result(); ease=2; Forward(); } } Forward() { index = index + 1; 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 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() { // 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; } }