[Tugindia] Need Some Help

E. Krishnan ekmath at asianetindia.com
Thu Apr 14 09:11:06 CEST 2005


On Wed, 13 Apr 2005, Habeeb Basha Syed wrote:

> > On Mon, 11 Apr 2005, Habeeb Basha Syed wrote:

> >>    I need to do the following using PSTricks :
> >>    Partition a big area which is either a rectangle or a triangle
> >>     into smaller areas of same shape.
> >>    Place a dot in center of each of the smaller areas.

Please try this 

\documentclass{article}
\usepackage{pstricks}
\usepackage{multido}
\usepackage{calc}


\begin{document}


 \newlength{\RectHbeg}
 \newlength{\RectHend}
 \newlength{\RectWid}
 \newlength{\RectVbeg}
 \newlength{\RectVend}
 \newlength{\RectHt}
 \newlength{\PartRectWd}
 \newlength{\PartRectHt}
 \newlength{\HcentPartBeg}
 \newlength{\VcentPartBeg}


 \def\RectPartCent(#1,#2)(#3,#4)#5#6{%
   \setlength{\RectHbeg}{#1cm}
   \setlength{\RectHend}{#3cm}
   \setlength{\RectWid}{\RectHend-\RectHbeg}
   \setlength{\RectVbeg}{#2cm}
   \setlength{\RectVend}{#4cm}
   \setlength{\RectHt}{\RectVend-\RectVbeg}
   \setlength{\PartRectWd}{\RectWid/#5}
   \setlength{\PartRectHt}{\RectHt/#6}
   \psframe(#1,#2)(#3,#4)
   \multido{\d=\RectHbeg+\PartRectWd}{#5}{%
     \psline(\d,#2)(\d,#4)}
   \multido{\d=\RectVbeg+\PartRectHt}{#6}{%
     \psline(#1,\d)(#3,\d)}
   \setlength{\HcentPartBeg}{\RectHbeg+\PartRectWd/2}
   \setlength{\VcentPartBeg}{\RectVbeg+\PartRectHt/2}
   \multido{\dx=\HcentPartBeg+\PartRectWd}{#5}{%
     \multido{\dy=\VcentPartBeg+\PartRectHt}{#6}{%
       \psdots(\dx,\dy)}}}




\begin{center}
  \begin{pspicture}(2,4)(7,6)
    \RectPartCent(2,4)(7,6){3}{4}
  \end{pspicture}
\end{center}

 \vspace{2cm}

 \begin{center}
   \begin{pspicture}(5,4)(9,6)
     \RectPartCent(5,4)(9,6){5}{7}
   \end{pspicture}
 \end{center}


\end{document}



-- 
Krishnan



More information about the tugindia mailing list