音乐间隔图形与TIKZ

时间:2014-09-18 07:26:37

标签: trigonometry tikz

我正在绘制一张图片,展示如何为自然音乐音阶定位片段。我的三角学课程很久以前就被遗忘了,所以我为此道歉是一个非常虚假的问题。

考虑一下followintìgtikz图片。我需要将片段重新放置D,以便其度量将是8 -9分段ut-C的度量。现在我把它放在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}

谢谢你, 甲

1 个答案:

答案 0 :(得分: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}