
我想畫下圖,這是一個平行四邊形和兩個全等的正六邊形。
\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[portuguese]{babel}
\usepackage{tikz,tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=0.9]
\tkzInit[xmin=0,xmax=8,ymin=0,ymax=3]
\tkzClip[space=.5]
\tkzDefPoint(0,0){A} \tkzDefPoint(6,0){B}
\tkzDefPoint(7.5,3){C} \tkzDefPoint(1.5,3){D}
\tkzDefPointWith[colinear= at C](B,A)
\tkzDrawPolygon(A,B,C,D)
\end{tikzpicture}
\end{document}
答案1
六邊形很好,因為所有角度都是 60 度,這意味著所有邊從中心到角的距離都相同。我把這個稱為距離\D
。然後主要是計算邊和角的問題。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\newcommand\D{2}
\coordinate (A) at (0,0);
\path (A) ++(0:\D) ++(-60:\D)coordinate (B);
%%
\draw[fill=gray!50] ($(A)+(120:\D)$)
-- ($(A)+(120:\D)+(-120:3*\D)$)
-- ($(B)+(-60:\D)$)
-- ($(B)+(-60:\D)+(60:3*\D)$) -- cycle;
%% Hexagons
\draw[fill=white] (A) +(0:\D) -- +(60:\D) -- +(120:\D) -- +(180:\D) -- +(240:\D) -- +(300:\D) -- cycle;
\draw[fill=white] (B) +(0:\D) -- +(60:\D) -- +(120:\D) -- +(180:\D) -- +(240:\D) -- +(300:\D) -- cycle;
%% Where are A and B?
\draw (A) circle (1pt) node[below]{A};
\draw (B) circle (1pt) node[below]{B};
\end{tikzpicture}
\end{document}