1

我正在绘制一张图片,展示如何为自然音乐音阶定位片段。我的三角学课程早就被遗忘了,所以我很抱歉这将是一个非常愚蠢的问题。

考虑以下 tikz 图片。我需要重新放置段 D,使其测量值是段 ut-C 的测量值的 8/9。现在我只是将它放置在 ut 和 ut' 之间 8/9 的随机距离处。我应该使用什么数学函数(sen,cos ...???)以及如何为 tikz 写下来?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}


\begin{tikzpicture}[scale=2]


\coordinate (o) at (0,0);
\coordinate [label=below:ut] (ut) at (2,0);
\coordinate [label=below:ut'] (ut') at (4,0);


\coordinate [label=above:C] (C) at (2, 2.4);
\coordinate [label=above:c] (c) at (4, 1.2);
\coordinate (O) at ($ (c)!2!(C) $);

\draw (ut) -- (ut');
\draw (ut) -- (C);
\draw (C) -- (c);
\draw (ut') -- (c);

\coordinate [label=below:re] (re) at ($ (ut)!8.0/9!(ut') $);

\coordinate [label=above:D] (D) at ($ (C)!8.0/9!(c) $);

\draw (re) --(D);

\node [fill=black, inner sep=1pt] (c') at ($ (ut)!1.0/6!(C) $) {};
\node [fill=black, inner sep=1pt] (c') at ($ (ut)!2.0/6!(C) $) {};
\node [fill=black, inner sep=1pt] (c') at ($ (ut)!3.0/6!(C) $) {};
\node [fill=black, inner sep=1pt] (c') at ($ (ut)!4.0/6!(C) $) {};
\node [fill=black, inner sep=1pt] (c') at ($ (ut)!5.0/6!(C) $) {};

\node [fill=black, inner sep=1pt] (c') at ($ (ut')!1.0/3!(c) $) {};
\node [fill=black, inner sep=1pt] (c') at ($ (ut')!2.0/3!(c) $) {};
\draw (ut') -- (c);



\end{tikzpicture}
\end{document}

谢谢你,A

4

1 回答 1

1

如果您仍然感兴趣,这里是您问题的答案。

在下面的代码中,我假设 c 始终是图中 C 的一半。您可以更改 D 位置的分数。现在它设置为 8/9。不需要三角函数。我删除了定义原点 (o) 的代码。它没有以任何方式使用。

\begin{tikzpicture}[scale=1]

\newlength{\height}\setlength{\height}{2.4cm}
\newlength{\width}\setlength{\width}{4cm}
\def\fraction{0.889} %8/9

\coordinate [label=below:ut] (ut) at (0,0);
\coordinate [label=below:ut'] (ut') at (\width,0);

\coordinate [label=above:C] (C) at ($(ut) + (0,\height)$);
\coordinate [label=above:c] (c) at ($(ut') + (0,0.5\height)$);

\draw (ut) -- (ut') -- (c) -- (C) -- cycle;

\draw let 
  \p{C} = (C),
  \p{c} = (c),
  \n{y_D} = {\fraction*\y{C}},
  \n{x_D} = {\x{c}*2*(1-\fraction)}
  in
  (\n{x_D},\n{y_D}) coordinate[label=above:D] (D) -- (\n{x_D},0) coordinate[label=below:re] (re);
  %you could replace the previous line by
  %(\n{x_D},\n{y_D}) -- (\n{x_D},0);
  %because (D) and (re) aren't used later


\foreach \x in {1,...,5}{
\fill[black]  ($ (ut)!\x/6!(C) - (1pt,1pt)$) rectangle ++(2pt,2pt);
}
\foreach \x in {1,2}{
\fill[black]  ($ (ut')!\x/3!(c) - (1pt,1pt)$) rectangle ++(2pt,2pt);
}

\end{tikzpicture}
\end{document}
于 2015-04-01T14:07:52.417 回答