/* Draws figures for the FMC (Fundamentos de Matematica para Computacao) book */ /* Last edited on 2024-12-21 14:02:34 by stolfi */ /* This program draws several figures for the book "Fundamentos de Matematica para Computacao" by A.Gomide and J.Stolfi (2011). */ #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv); /* IMPLEMENTATIONS */ int main(int argc, char **argv) { double labht = 0.67*fmc_font_size; /* Estimated actual label height (mm). */ #define dnA (4) r3_t qA[dnA]= { {{0,3,1}}, {{0,2,2}}, {{0,1,5}}, {{0,0,9}} }; r2_t szLabA = (r2_t){{ 1.0*fmc_digit_width, labht }}; ptset_t sA = make_ptset("A","A",dnA,qA,&szLabA); #undef dnA #define dnB (5) r3_t qB[dnB]= { {{0,4,20}}, {{0,3,30}}, {{0,2,40}}, {{0,1,50}}, {{0,0,60}} }; r2_t szLabB = (r2_t){{ 2.0*fmc_digit_width, labht }}; ptset_t sB = make_ptset("B","B",dnB,qB,&szLabB); #undef dnB #define dnC (4) r3_t qC[dnC]= { {{0,3,200}}, {{0,2,300}}, {{0,1,400}}, {{0,0,500}} }; r2_t szLabC = (r2_t){{ 3.0*fmc_digit_width, labht }}; ptset_t sC = make_ptset("C","C",dnC,qC,&szLabC); #undef dnC /* RELATIONS */ #define dnR (5) i2_t qR[dnR] = { {{0,0}},{{0,1}},{{1,0}},{{1,3}},{{3,3}} }; double labwdR = 1.5*fmc_digit_width; double dxinvR = 0.7*fmc_digit_width; relac_t rR = make_relac("R","R",TRUE,dnR,qR,labwdR,dxinvR); #undef dnR #define dnS (4) i2_t qS[dnS] = { {{0,1}},{{0,2}},{{1,0}},{{2,3}} }; double labwdS = 1.5*fmc_digit_width; double dxinvS = 0.7*fmc_digit_width; relac_t rS = make_relac("S","S",TRUE,dnS,qS,labwdS,dxinvS); #undef dnS #define dnRS (5) i2_t qRS[dnRS] = { {{0,0}},{{0,1}},{{0,2}},{{1,1}},{{1,2}} }; double labwdRS = 2.5*fmc_digit_width; double dxinvRS = 1.7*fmc_digit_width; relac_t rRS = make_relac("RS","RS",TRUE,dnRS,qRS,labwdRS,dxinvRS); #undef dnRS draw_fig_relac_setas(&sA, &sB, &rR, FALSE); draw_fig_relac_setas(&sA, &sB, &rR, TRUE); draw_fig_relac_pontos(&sA, &sB, &rR); draw_fig_compos_setas(&sA, &sB, &sC, &rR, &rS, FALSE); draw_fig_compos_setas(&sA, &sB, &sC, &rR, &rS, TRUE); draw_fig_relac_setas(&sA, &sC, &rRS, FALSE); draw_fig_relac_setas(&sA, &sC, &rRS, TRUE); /* FUNCTIONS */ #define dnF (4) i2_t qF[dnF] = { {{0,0}},{{1,3}},{{2,3}},{{3,2}} }; double labwdF = 1.0*fmc_digit_width; double dxinvF = 0.8*fmc_digit_width; relac_t rF = make_relac("f","f",FALSE,dnF,qF,labwdF,dxinvF); #undef dnF #define dnG (5) i2_t qG[dnG] = { {{0,0}},{{1,3}},{{2,3}},{{3,2}},{{4,2}} }; double labwdG = 1.0*fmc_digit_width; double dxinvG = 0.7*fmc_digit_width; relac_t rG = make_relac("g","g",FALSE,dnG,qG,labwdG,dxinvG); #undef dnG #define dnFG (4) i2_t qFG[dnFG] = { {{0,0}},{{1,2}},{{2,2}},{{3,3}} }; double labwdFG = 2.0*fmc_digit_width; double dxinvFG = 1.7*fmc_digit_width; relac_t rFG = make_relac("fg","fg",FALSE,dnFG,qFG,labwdFG,dxinvFG); #undef dnFG draw_fig_relac_setas(&sA, &sB, &rF, FALSE); draw_fig_relac_setas(&sA, &sB, &rF, TRUE); draw_fig_relac_pontos(&sA, &sB, &rF); draw_fig_compos_setas(&sA, &sB, &sC, &rF, &rG, FALSE); draw_fig_relac_setas(&sA, &sC, &rFG, FALSE); return 0; }