発言者: zyam56
発言日: 2006 12/28 20:29
一見簡単な図ですが1つ1つ書くと意外とパラメータが多くいくつも書くのはしんどいので
数値入力を自動化、一本を固定、一本の直線を可変、もう一本を準可変にするという仕様で
ソースを書きました。
このくらいの規模のソースでも設計仕様書とでもいうべきものをはじめにきちんと作ってから
書き始めると、後からのメンテナンスやバグ取りなども楽になりますね。
こういうことをやっているとemathのすごさをあらためて感じます。
emroundをさっそく使わせていただきました。ありがとうございます。
実測値とほぼ合うようです。どなたかの役に立てば幸いです。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,10pt,fleqn]{jsarticle}
%--------------------------------------------------------
\usepackage{emathPp}
%%*******************************************************
\makeatletter
%%*******************************************************
%%【5】2006/12/28%%マクロコマンド名【HeikouSenHiB{#1}{#2}{#3}{#4}】
%%平行な四直線によって切り取られた線分の比
\def\HeikouSenHiB#1#2#3#4{%%#1#2直線Sとr,qの離れ具合、#2直線nの下のx座標#3直線nの上のx座標
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\unitlength10truemm
\begin{picture}(7,6)(0,0)%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\A{(0,5.5)}\Put\A[w]{$p$}%
\def\B{(7,5.5)}%直線AB
\Drawline{\A\B}%一番上の横線p
%%%%%%
\def\G{(0,0.5)}\Put\G[w]{$s$}%%
\def\H{(7,0.5)}%直線GH%
\Drawline{\G\H}%一番下の横線s
%%%%%%
\Add{0.5}{#1}\ANS%最下線sからの離れ具合
\def\E{(0,\ANS)}\Put\E[w]{$r$}%%
\def\F{(7,\ANS)}%直線EF%
\Drawline{\E\F}%三番目の横線r
%%%%%%
\Add{\ANS}{#2}\ANs%下線rからの離れ具合
\def\C{(0,\ANs)}\Put\C[w]{$q$}%%
\def\D{(7,\ANs)}%直線CD%
\Drawline{\C\D}%上から二番目の横線q
%%%%%%
\thicklines
%%準固定直線m,1定義%%
\def\aval{2}%%\avalの値変更で移動できる%%
\def\bval{6}%%\bvalの値変更で移動できる%%
\def\K{(\aval,0)}\Put\K[s]{\small{$m$}}%
\def\L{(\bval,6)}%準固定斜め直線KL
\Drawline{\K\L}
%%固定直線m,1と横線の交点%%%%%%%%%%%%%
\LandL\A\B\K\L\T%\Put\T[nw]{\footnotesize{$T$}}
\LandL\C\D\K\L\U%\Put\U[nw]{\footnotesize{$U$}}
\LandL\E\F\K\L\V%\Put\V[nw]{\footnotesize{$V$}}
\LandL\G\H\K\L\W%\Put\W[nw]{\footnotesize{$W$}}
%%固定直線ell,2定義%%%%%%%%%%%%%%%%%%
\def\I{(0.8,0)}\Put\I[s]{\small{$\ell$}}%
\def\J{(1,6)}%固定斜め直線IJ
\Drawline{\I\J}
%%固定直線ell,2と横線の交点%%%%%%%%%%%%%
\LandL\A\B\I\J\P%\Put\P[ne]{\footnotesize{$P$}}
\LandL\C\D\I\J\Q%\Put\Q[ne]{\footnotesize{$Q$}}
\LandL\E\F\I\J\R%\Put\R[ne]{\footnotesize{$R$}}
\LandL\G\H\I\J\S%\Put\S[ne]{\footnotesize{$S$}}
%\calcval[2.1f]{5-#1-#2}\e
\thinlines
%\Hen_ko<0.4>\P\Q{\small{\e}}
\Hen_ko<0.4>\Q\R{\small{#2}}
\Hen_ko<0.4>\R\S{\small{#1}}
%%可変直線定義%%%%%%%%%%%%%%%%%%
\def\M{(#3,0)}\Put\M[s]{\small{$n$}}%
\def\N{(#4,6)}%可変斜め直線MN%
\Drawline{\M\N}
%%可変直線と横線の交点%%%%%%%%%%
\LandL\A\B\M\N\X%\Put\X[ne]{\footnotesize{$X$}}
\LandL\C\D\M\N\Y%\Put\Y[ne]{\footnotesize{$Y$}}
\LandL\E\F\M\N\Z%\Put\Z[ne]{\footnotesize{$Z$}}
\LandL\G\H\M\N\O%\Put\O[ne]{\footnotesize{$O$}}
%%%%%%%%%%%%%%%%%%%%
%%perlによる計算値を引数として受けとる%%%%%%%%%%%%
\calcval{(#3-#4)/12}\Xx
\calcval{\Xx+#4}\a%点Xのx座標
\calcval{#3-\Xx}\b%点Oのx座標
%%%%%%%%%%%%%%%%%%%%
\calcval{((\b-\a)**2+5**2)**0.5}\x
\calcval[s]{emround((5-#1-#2)*\x/5,1)}\Ax
\calcval[s]{emround(#2*\x/5,1)}\Bx
\calcval[s]{emround(#1*\x/5,1)}\Cx
\thinlines
\Hen_ko<0.4>\X\Y{\small{\Ax}}
%\Hen_ko<0.4>\Z\Y{\small{\Bx}}
\Hen_ko<0.4>\Z\Y{\small{$x$}}
\Hen_ko<0.4>\Z\O{\small{\Cx}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%perlによる計算値を引数として受けとる%%%%%%%%%%%%
\calcval{(\bval-\aval)/12}\Yy
\calcval{\bval-\Yy}\p%点Tのx座標
\calcval{\aval+\Yy}\q%点Wのx座標
\calcval{((\p-\q)**2+5**2)**0.5}\y
%%%%%%%%%%%%%%%%%%%%
\calcval[s]{emround((5-#1-#2)/5*\y,1)}\Dx
\calcval[s]{emround((#1+#2)/5*\y,1)}\Ex
\calcval[s]{emround(#1/5*\y,1)}\Fx
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
\thinlines
\Hen_ko<0.4>\U\W{\small{\Ex}}
%\Hen_ko<0.4>\W\V{\small{\Fx}}
\Hen_ko<0.4>\W\V{\small{$y$}}
%\Hen_ko<0.4>\U\T{\small{\Dx}}
\Hen_ko<0.4>\U\T{\small{$z$}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{picture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3学年数学 練習問題{\LARGE{マクロ作成テスト版}}
\begin{flushright}
\underline{\hspace{0.8cm}}組 {\small{番号\underline{\hspace{1cm}}}\small{氏名\underline{\hspace{4cm}}}}
\end{flushright}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{enumerate}
\item マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版マクロ作成テスト版\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%作成マクロコマンド実行%%%%%%
%%%***********************%%%%%
\HeikouSenHiB{2}{2}{6.5}{3}%%(#1rのsからの距離)(#2qのrからの距離)(#3可変直線nのx座標)(#4可変直線nのx座標)
%%%***********************%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{enumerate}
\end{document}
▼関連発言
│
└◆207:Re[2]:\calcvalの戻り値を小数第1位にするには?(Re:5424) [石原 守] 12/27 09:35
├◆210:Re[3]:\calcvalの戻り値を小数第1位にするには?(Re:5424) [田中徹] 12/27 12:20
└◆213:Re[3]:\calcvalの戻り値を小数第1位にするには?(Re:5424) [tDB] 12/27 13:50
├◆214: 補足 [tDB] 12/27 13:53
└◆216:Re[4]:\calcvalの戻り値を小数第1位にするには?(Re:5424... [石原 守] 12/27 16:40
└◆218:Re[5]:\calcvalの戻り値を小数第1位にするには?(Re:542.. [zyam56] 12/27 22:41
└◆219:Re[6]:\calcvalの戻り値を小数第1位にするには?(Re:5.. [石原 守] 12/28 19:55
└◆220:Re[7]:\calcvalの戻り値を小数第1位にするには?(Re.. [zyam56] 12/28 20:29
└◆221:Re[8]:\calcvalの戻り値を小数第1位にするには?(.. [田中徹] 12/29 01:05
└◆222:Re[9]:\calcvalの戻り値を小数第1位にするには?.. [zyam56] 12/29 10:18<-last