// Copyright (C) 1996 Leena L�hteenm�ki, Finland // Copyright (C) 2012 PatternMaker Software // 2011/11/04 double version; double index, done; double language; double x[300], y[300]; point current_point; object current_object, group_obj[11]; double size; double ease; double metric; double sv; selection current_selection; //hihan lankasuora main() { language=get_language(); if ( language != 0 ) { language = 0; } if (language == 0) { check_reg(0, "Leena","BB_macros", "This macro needs to be properly installed before running it."); } //VARIABLES double ry, vy, ly, ky, ktk, sp, lk, pp, sl, ktl, op, ptkt, ptke, ptl, ptse, okt, oke, rke; double hp, pk, hl, ray, sip, jsp, ik; double f_ry[3],f_vy[3],f_ly[3],f_ky[3],f_ktk[3]; double f_sp[3],f_sl[3], f_op[3], f_ray[3],f_hp[3]; double t_ry[7]; double t_vy[7]; double t_ly[7]; double t_ky[7]; double t_sp[7]; double t_op[7]; double t_sl[7]; double t_ptke[7]; double t_hp[7]; double t_ray[7]; double t_sip[7]; double t_jsp[7]; double siirtox, siirtoy, nvl; double ptse, ptst, ptl; index = 0; done = 0; //Start Options while (!done) { if (index == 0) { StyleSize(); } if (index == 1) { StyleEase(); } } //End Options nvl=0; t_vy[0]=48; t_vy[1]=49; t_vy[2]=50; t_vy[3]=51; t_vy[4]=52; t_vy[5]=53; t_vy[6]=54; t_ry[0]=46; t_ry[1]=47.5; t_ry[2]=49; t_ry[3]=50.5; t_ry[4]=52; t_ry[5]=54; t_ry[6]=56; t_ly[0]=53; t_ly[1]=54; t_ly[2]=55; t_ly[3]=56; t_ly[4]=57; t_ly[5]=58; t_ly[6]=60; t_ky[0]=25; t_ky[1]=25.5; t_ky[2]=26; t_ky[3]=26.5; t_ky[4]=27; t_ky[5]=27.5; t_ky[6]=28; t_op[0]=6; t_op[1]=6.4; t_op[2]=6.8; t_op[3]=7.2; t_op[4]=7.6; t_op[5]=8; t_op[6]=8.4; t_sl[0]=2*10.4-3; t_sl[1]=2*10.7-3; t_sl[2]=2*11-3; t_sl[3]=2*11.3-3; t_sl[4]=2*11.6-3; t_sl[5]=2*12-3; t_sl[6]=2*12.4-3; t_hp[0]=20; t_hp[1]=24; t_hp[2]=26; t_hp[3]=28; t_hp[4]=30; t_hp[5]=32; t_hp[6]=34; t_ray[0]=10.5; t_ray[1]=11; t_ray[2]=11; t_ray[3]=11.5; t_ray[4]=11.5; t_ray[5]=12; t_ray[6]=12; t_sp[0]=18; t_sp[1]=19; t_sp[2]=20; t_sp[3]=21; t_sp[4]=22; t_sp[5]=23; t_sp[6]=24; t_sip[0]=37.5; t_sip[1]=41; t_sip[2]=44.5; t_sip[3]=48; t_sip[4]=52; t_sip[5]=56; t_sip[6]=60; t_jsp[0]=19; t_jsp[1]=22; t_jsp[2]=25; t_jsp[3]=28; t_jsp[4]=31.5; t_jsp[5]=35; t_jsp[6]=38.5; t_ptke[0]=1.5; t_ptke[1]=1.5; t_ptke[2]=1.5; t_ptke[3]=1.75; t_ptke[4]=1.75; t_ptke[5]=2.25; t_ptke[6]=2.25; ry= t_ry[size]; vy= t_vy[size]; ly= t_ly[size]; ky= t_ky[size]; op= t_op[size]; sp= t_sp[size]; hp= t_hp[size]; ray= t_ray[size]; op= t_op[size]; sl= t_sl[size]; sip= t_sip[size]; jsp= t_jsp[size]; ptke=t_ptke[size]; //MEASUREMENT UNITS //==================== if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { ry=ry/2.54; vy=vy/2.54; ly=ly/2.54; ky=ky/2.54; op=op/2.54; sl=sl/2.54; sp=sp/2.54; hp=hp/2.54; ray=ray/2.54; sip=sip/2.54; jsp=jsp/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 { ry=ry/2.54; vy=vy/2.54; ly=ly/2.54; ky=ky/2.54; op=op/2.54; sl=sl/2.54; sp=sp/2.54; hp=hp/2.54; ray=ray/2.54; sip=sip/2.54; jsp=jsp/2.54; } } if(metric==0) { sv=0.39; } //Measurements table double read; read = 0; if (is_function("measure_table")==1) { if (measure_table("default_babies")==1) { read = 1; } } if (read==0) { if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("BABIES' BASIC BODICE"); } if (language == 0) { add_picture_input("Neck circumference",ky, "bc_meas_neckcirc"); } if (language == 0) { add_picture_input("Chest circumference", ry, "bc_meas_chestcirc"); } if (language == 0) { add_picture_input("Waist circumference", vy, "bc_meas_waistcirc"); } if (language == 0) { add_picture_input("Hip circumference",ly, "bc_meas_hipcirc"); } if (language == 0) { add_picture_input("Back length", sp, "bc_meas_bklength"); } if (language == 0) { add_picture_input("Back width",sl, "bc_meas_bkwidth"); } if (language == 0) { add_picture_input("Shoulder length",op, "bc_meas_shldr"); } if (language == 0) { add_picture_input("Overarm length",hp, "bc_meas_overarm"); } if (language == 0) { add_picture_input("Wrist circumference", ray, "bc_meas_waistcirc"); } run_picture_input(); } else { if (language == 0) { dialog_box("BABIES' BASIC BODICE", "Neck circumference", ky, "Chest circumference", ry, "Waist circumference", vy, "Hip circumference",ly, "Back length", sp, "Back width",sl, "Shoulder length",op, "Overarm length",hp, "Wrist circumference", ray); } } } if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("BABIES' BODICE"); } if (language == 0) { add_picture_input("Button ext. width",nvl, "w_meas_button_ext_width"); } run_picture_input(); } else { if (language == 0) { dialog_box("BABIES' BODICE", "Button ext. width",nvl); } } //======== if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { ry=ry*2.54; vy=vy*2.54; ly=ly*2.54; ky=ky*2.54; op=op*2.54; sl=sl*2.54; sp=sp*2.54; hp=hp*2.54; ray=ray*2.54; sip=sip*2.54; jsp=jsp*2.54; } } else { if (metric<1) // If inches, convert cm to inches for dialog box { ry=ry*2.54; vy=vy*2.54; ly=ly*2.54; ky=ky*2.54; op=op*2.54; sl=sl*2.54; sp=sp*2.54; hp=hp*2.54; ray=ray*2.54; sip=sip*2.54; jsp=jsp*2.54; } } if(metric==2) { sv=sv/2.54; } //EASE basic f_ry[0]=ry+8; f_ky[0]=ky+1; f_vy[0]=vy+6; f_ly[0]=ly+6; f_sl[0]=sl+2; f_op[0]=op; f_sp[0]=sp; f_ktk[0]=ktk; f_ray[0]=ray+2; f_hp[0]=hp; //EASE / sis�vaate f_ry[1]=ry+24; f_ky[1]=ky+2; f_vy[1]=vy+16; f_ly[1]=ly+16; f_sl[1]=sl+6; f_op[1]=op+2; f_sp[1]=sp; f_ray[1]=ray+10; f_hp[1]=hp; //EASE / ulkovaate f_ry[2]=ry+26; f_ky[2]=ky+3; f_vy[2]=vy+20; f_ly[2]=ly+20; f_sl[2]=sl+8; f_op[2]=op+3; f_sp[2]=sp+1; f_ray[2]=ray+14; f_hp[2]=hp+1; ry=f_ry[ease]; ky=f_ky[ease]; vy=f_vy[ease]; ly=f_ly[ease]; sl=f_sl[ease]; op=f_op[ease]; sp=f_sp[ease]; ray=f_ray[ease]; //matikka ktk=ry/4-2; lk=ktk-2; ktl=ry/8; ptl=ky/5-.5; ptse=ky/5; rke=ry/10; pk=ry/6-2; hl=sl+1.5; ptkt=1; okt=1; oke=1; //pp=sp+sip/2; pp=sp; //STARTING POINT x[0]=0; y[0]=30; //1 coord(0,1,0,0); //2 coord(1,2,0,-ktk); //3 coord(1,3,0,-sp); //4 coord(3,4,0,-lk); //5 coord(1,5,0,-pp); //6 coord(2,6,-sl/2,0); //7 coord(6,7,-ktl,0); //8 coord(2,8,-ry/2,0); //9 x[9]=x[8]; y[9]=y[3]; //10 coord(9,10,-1,0); //11 coord(1,101,-100,0); cont(10,8,111,100); line_intersect (8,111,1,101,11); //12 coord(4,104,-100,0); cont(8,10,113,100); line_intersect(8,113,4,104,12); //13 coord(5,105,-100,0); line_intersect(8,113,5,105,13); //14 coord(1,14,-sl/2,0); //15 coord(14,15,-ktl,0); //16 center(6,7,16); //17 coord(1,17,-ptl,0); //18 coord(17,18,0,ptkt); //19 coord(14,19,0,-1); //20 coord(19,119,-50,0); //linecirc (18,19,119,op,1,20); coord(18,20,-sqrt(op*op-(ptkt+okt)*(ptkt+okt)),-ptkt-okt); //21 cont(8,11,21,ptke); //22 coord(21,22,ptl,0); //23 cont(10,21,23,-ptse); //123 //x[123]=x[22]; //y[123]=y[23]; cont(11,23,123,ptl); rotate (123,23,angle (x[123],y[23],x[123],y[23]+90*3.14159/180)); //24 coord(15,24,0,-oke); //25 //linecirc(22,24,124,op,1,25); coord(22,25,sqrt(op*op-(ptke+oke)*(ptke+oke)),-ptke-oke); //26 coord(7,26,0,ktk/4); //125 coord(7,125,0,ktk/2); //27 coord(6,27,0,ktk/3); //120 coord(6,120,0,ktk/3*2); //28 coord(16,28,0,-pp+ktk); double sivu; sivu=dist(16,28); //takakappale group_obj[0]=newobject("poly"); addpoint((x[1])/2.54, (y[1])/2.54, "xarc_start"); addpoint((x[17])/2.54, (y[17])/2.54, "xarc_corner"); addpoint((x[18])/2.54, (y[18])/2.54, "LINE"); addpoint((x[20])/2.54, (y[20])/2.54, "xarc_start"); addpoint((x[120])/2.54, (y[120])/2.54, "xarc_corner"); addpoint((x[27])/2.54, (y[27])/2.54, "xarc_start"); addpoint((x[6])/2.54, (y[6])/2.54, "xarc_corner"); addpoint((x[16])/2.54, (y[16])/2.54, "line"); addpoint((x[28])/2.54, (y[3])/2.54, "line"); addpoint((x[3])/2.54, (y[3])/2.54, "LINE"); addpoint((x[2])/2.54, (y[2])/2.54, "LINE"); //saumanvara if (language == 0) { current_object=newobject("text","Patterns are without seam allowance",-1.570796,0.3,0.2,"SIMP.CHR"); } addpoint((x[1]-.5-2+siirtox)/2.54, (y[1]-1)/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[1]-.5+siirtox)/2.54, (y[1]-1)/2.54, "line"); group_obj[2]=current_object; //etukappaleen pyoritys niin etta ke on pystysuora double ang; ang=angle(x[8],y[8],x[9],y[9])-angle(x[8],y[8],x[10],y[10]); rotate(22,8,ang); rotate(123,8,ang); rotate(23,8,ang); rotate(10,8,ang); rotate(12,8,ang); rotate(16,8,ang); rotate(7,8,ang); rotate(26,8,ang); rotate(125,8,ang); rotate(25,8,ang); rotate(28,8,ang); siirtox=ry/8; //etukappale group_obj[3]=newobject("poly"); addpoint((x[22]-siirtox)/2.54, (y[22])/2.54, "xarc_start"); addpoint((x[123]-siirtox)/2.54, (y[123])/2.54, "xarc_corner"); addpoint((x[23]-siirtox)/2.54, (y[23])/2.54, "line"); addpoint((x[8]-siirtox)/2.54, (y[8])/2.54, "line"); addpoint((x[10]-siirtox)/2.54, (y[10])/2.54, "xarc_start"); addpoint((x[15]-siirtox)/2.54, (y[10])/2.54, "xarc_corner"); addpoint((x[28]-siirtox)/2.54, (y[28])/2.54, "line"); addpoint((x[16]-siirtox)/2.54, (y[16])/2.54, "xarc_start"); addpoint((x[7]-siirtox)/2.54, (y[7])/2.54, "xarc_corner"); addpoint((x[26]-siirtox)/2.54, (y[26])/2.54, "xarc_start"); addpoint((x[125]-siirtox)/2.54, (y[125])/2.54, "xarc_corner"); addpoint((x[25]-siirtox)/2.54, (y[25])/2.54, "line"); //KE-teksti if (language == 0) { current_object=newobject("text","Center Front",-1.570796,0.2,0.2,"SIMP.CHR"); } addpoint((x[23]-siirtox+.5)/2.54, (y[23])/2.54, "line"); group_obj[4]=current_object; if(nvl>0) { //nappivara current_object=newobject("poly"); addpoint((x[23]-siirtox)/2.54, (y[23])/2.54, "line"); addpoint((x[23]-nvl-siirtox)/2.54, (y[23])/2.54, "line"); current_point=addpoint((x[10]-nvl-siirtox)/2.54, (y[10])/2.54, "line"); current_point=addpoint((x[10]-siirtox)/2.54, (y[10])/2.54, "open"); group_obj[5]=current_object; } siirtox=0; //hiha coord(1,1,hl/2+5,0); coord(1,2,0,-pk); coord(1,3,0,-hp); coord(1,4,0,-hp/2+1); coord(1,5,ktl/2,0); coord(2,6,hl/2,0); coord(3,7,ray/2,0); coord(1,9,-ktl/2,0); coord(2,10,-hl/2,0); coord(3,11,-ray/2,0); coord(10,13,ktl/2,0); coord(6,16,-ktl/4,0); center(5,16,15); center(9,13,14); center(7,3,18); y[18]=y[18]-.5; center(11,3,17); y[17]=y[17]+.5; group_obj[6]=newobject("poly"); addpoint((x[6])/2.54, (y[6])/2.54, "xarc_start"); addpoint((x[16])/2.54, (y[16])/2.54, "xarc_corner"); addpoint((x[15])/2.54, (y[15])/2.54, "xarc_start"); addpoint((x[5])/2.54, (y[5])/2.54, "xarc_corner"); addpoint((x[1])/2.54, (y[1])/2.54, "xarc_start"); addpoint((x[9])/2.54, (y[9])/2.54, "xarc_corner"); addpoint((x[14])/2.54, (y[14])/2.54, "xarc_start"); addpoint((x[13])/2.54, (y[13])/2.54, "xarc_corner"); addpoint((x[10])/2.54, (y[10])/2.54, "line"); addpoint((x[11])/2.54, (y[11])/2.54, "xarc_start"); addpoint((x[17])/2.54, (y[17])/2.54, "xarc_corner"); addpoint((x[3])/2.54, (y[3])/2.54, "xarc_start"); addpoint((x[18])/2.54, (y[18])/2.54, "xarc_corner"); addpoint((x[7])/2.54, (y[7])/2.54, "line"); //grain line group_obj[7]=newobject("poly"); addpoint((x[1])/2.54, (y[1])/2.54, "line"); addpoint((x[4])/2.54, (y[4]-2)/2.54, "line"); addpoint((x[4]-.5)/2.54, (y[4])/2.54, "line"); addpoint((x[4])/2.54, (y[4]-2)/2.54, "line"); addpoint((x[4]+.5)/2.54, (y[4])/2.54, "open"); //teksti if (language == 0) { current_object=newobject("text","Sleeve Front",0.0,0.2,0.2,"SIMP.CHR"); } addpoint((x[10]+3+siirtox)/2.54, (y[10]+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[6]-5+siirtox)/2.54, (y[6]+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; //LOPPU 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]); select(current_selection,group_obj[4]); if (group_obj[5] != 0) { 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"); //Run the command } //option pictures StyleSize() { if (language == 0) { start_pict_dialog("Select closest height"); add_pict_item("62cm / 24.5 inch",""); add_pict_item("68cm / 26.75 inch",""); add_pict_item("74cm / 29 inch",""); add_pict_item("80cm / 31.5 inch",""); add_pict_item("86cm / 34 inch",""); add_pict_item("92cm / 36.25 inch",""); add_pict_item("98cm / 38.5 inch",""); run_pict("Next"); size=get_pict_result(); Forward(); } } StyleEase() { if (language == 0) { start_pict_dialog("Garment ease"); add_pict_item("Fitting shell (chest + 8cm / 3 inch)","baby-ease-0.jpg"); add_pict_item("Average (chest + 24cm / 9.5 inch)","baby-ease-1.jpg"); add_pict_item("Loose (chest +26cm / 10.25 inch)","baby-ease-2.jpg"); if (run_pict("Back","Next")) //was Done { ease=get_pict_result(); Forward(); } else { ease=0; Backward(); } } } Forward() { index = index + 1; if (index == 2) { done = 1; } } Backward() { index = index - 1; } 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(); } } } shift(double orig, double xxx, double yyy) { x[orig]=x[orig]+xxx; y[orig]=y[orig]+yyy; } rect (double x1, double y1, double x2, double y2) { 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) { newobject("poly"); addpoint( x/2.54,y/2.54,"LINE"); } line (double x3, double y3, double x4, double y4) { newobject("poly"); addpoint( x3/2.54,y3/2.54,"LINE"); addpoint( x4/2.54,y4/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) { // 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 from_tspace double xarc_x_array[13], xarc_y_array[13]; double return_x, return_y; arclength(double start, double corner, double end) { double count, 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 (count=1; count < 12; count = count + 1) { from_tspace(start, corner, end, count); a_dist = a_dist + distance(return_x, return_y, last_x, last_y); last_x=return_x; last_y=return_y; } return a_dist; } ////////////////////////////////////// // These global variables are used by from_tspace for repeated calls. double A1, A2, B1, B2; //transformation vectors double sx, sy, cx, cy, ex, ey; double tspace_0[2], tspace_1[2]; double ft_center[2]; from_tspace(double start, double corner, double end, double pos) { // This routine finds the x and y coordinates of a point in an xarc. // "pos" gives the number of the point i.e. 7th. An xarc is // made up of 12 line segments. if (pos<1) { return_x=x[start]; return_y=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; //Take the negatives of these vectors because we are basing everything on //a unit circle in the third quadrant(not usual unit vectors) A1=-A1; B1=-B1; A2=-A2; B2=-B2; tspace_0[0]=A1; tspace_0[1]=B1; tspace_1[0]=A2; tspace_1[1]=B2; //This is the transformation matrix. Just multiply it by the //point you want to transform and add the center point // ft_center[0]= cx + (tspace_0[0] + tspace_0[1]); ft_center[1]= cy + (tspace_1[0] + tspace_1[1]); return_x = tspace_0[0]*(xarc_x_array[pos])+tspace_0[1] * (xarc_y_array[pos])+ ft_center[0]; return_y = tspace_1[0]*(xarc_x_array[pos])+tspace_1[1] *(xarc_y_array[pos])+ ft_center[1]; } else { if (pos>10) { return_x=x[end]; return_y=y[end]; } else { // Transformation matrix is already calculated return_x = tspace_0[0]*(xarc_x_array[pos])+tspace_0[1] * (xarc_y_array[pos])+ ft_center[0]; return_y = tspace_1[0]*(xarc_x_array[pos])+tspace_1[1] * (xarc_y_array[pos])+ ft_center[1]; } } } } /////////////////////////////////////// init_xarc_array() { // Must be called before calling from_tspace(). 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, count; double XARC_PIECES; XARC_PIECES = 12; ang_start = -3.14159/2; ang_end= -3.14159; count=0; step= (ang_end - ang_start)/(XARC_PIECES-1); for (theta=ang_start; count < XARC_PIECES; theta = theta + step) { xarc_x_array[count] = cos(theta); xarc_y_array[count] = sin(theta); count=count+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; } }