1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
% tkz-obj-eu-polygons.tex
% Copyright 2020 by Alain Matthes
% This file may be distributed and/or modified
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
\def\fileversion{3.02c}
\def\filedate{2020/01/24}
\typeout{2020/01/24 3.02c tkz-obj-eu-polygons.tex}
\makeatletter
%<--------------------------------------------------------------------------–>
% Polygon
%<--------------------------------------------------------------------------–>
%<--------------------------- square ------------------------------------–>
%
%<--------------------------------------------------------------------------–>
\def\tkzDefSquare(#1,#2){
\begingroup
\tkzURotateAngle(#2,-90)(#1)
\pgfnodealias{tkzFirstPointResult}{tkzPointResult}
\tkzURotateAngle(#1, 90)(#2)
\pgfnodealias{tkzSecondPointResult}{tkzPointResult}
\endgroup
}
%<--------------------- parallélogramme ---------------------------------–>
%
%<--------------------------------------------------------------------------–>
\def\tkzDefParallelogram(#1,#2,#3){
\begingroup
\tkzDefPointWith[colinear= at #3](#2,#1)
\endgroup
}
%<-------------------------- gold rectangle -------------------------------–>
%
%<--------------------------------------------------------------------------–>
\def\tkzDefGoldRectangle(#1,#2){
\begingroup
\tkzVecKOrth[-\tkzInvPhi](#2,#1)
\pgfnodealias{tkzFirstPointResult}{tkzPointResult}
\tkzVecKOrth[\tkzInvPhi](#1,#2)
\pgfnodealias{tkzSecondPointResult}{tkzPointResult}
\endgroup
}
\def\tkzDrawGoldRectangle{\pgfutil@ifnextchar[{\tkz@DrawGoldRectangle}{%
\tkz@DrawGoldRectangle[]}}
%<---------------------------- Regular Polygon -------------------------–>
\def\tkz@numregpol{0}
\pgfkeys{/defregpoly/.cd,
name/.store in = \tkz@regpolname,
sides/.store in = \tkz@regpolsides,
center/.code = \def\tkz@numregpol{0},
side/.code = \def\tkz@numregpol{1},
center,
name = P,
sides = 5
}
\def\tkzDefRegPolygon{\pgfutil@ifnextchar[{\tkz@DefRegPolygon}{%
\tkz@DefRegPolygon[]}}
\def\tkz@DefRegPolygon[#1](#2,#3){%
\begingroup
\pgfqkeys{/defregpoly}{#1}
\ifcase\tkz@numregpol%
\tkzRegPolygonCenter(#2,#3)
\or%
\tkzRegPolygonSide(#2,#3)
\fi
\endgroup
}
\def\tkzRegPolygonCenter(#1,#2){
\begingroup
\foreach \v in {1,2,...,\tkz@regpolsides}
{%
\pgfmathsetmacro{\tkz@regangle}{360/\tkz@regpolsides*(\v-1)}
\tkzDefPointBy[rotation= center #1 angle \tkz@regangle](#2)
\pgfnodealias{\tkz@regpolname\v}{tkzPointResult}
}
\endgroup
}
\def\tkzRegPolygonSide(#1,#2){
\begingroup
% get the center
\pgfmathsetmacro{\tkz@regangle}{360/\tkz@regpolsides*(\tkz@regpolsides-1)}
\pgfmathsetmacro{\tkz@regangleside}{(180-\tkz@regangle)/2}
\tkzDefMidPoint(#1,#2)
\pgfnodealias{tkz@tempPt}{tkzPointResult}
\tkzCalcLength[cm](tkz@tempPt,B) \tkzGetLength{tkz@len}
\pgfmathsetmacro{\tkz@inscriberadius}{%
\tkz@len*tan(90*(\tkz@regpolsides-2)/\tkz@regpolsides)}
\tkzDefPointWith[orthogonal normed,K=\tkz@inscriberadius](tkz@tempPt,#2)
\pgfnodealias{tkz@RegPolCenter}{tkzPointResult}
\tkzRegPolygonCenter(tkz@RegPolCenter,#1)
\pgfnodealias{tkzPointResult}{tkz@RegPolCenter}
\endgroup
}
%<---------------------------- CLIP --------------------------------–>
%
%<--------------------------------------------------------------------------–>
\def\tkzClipPolygon(#1,#2){%
\path[clip] (#1)
\foreach \pt in {#1,#2}{--(\pt)}--cycle;
}
\def\tkzClipOutPolygon(#1,#2){\clip[tkzreverseclip] (#1)
\foreach \pt in {#1,#2}{--(\pt)}--cycle;
}
\makeatother
\endinput
|