PGF和tikz中如何定義乙個實數

2021-06-13 17:09:22 字數 1719 閱讀 9367

使用\pgfmathsetmacro,定義的實數在tikz的繪圖環境中可以很方便的進行四則運算:

看下面的例子:

%傳熱學圖4-3

\begin[>=stealth,line width=0.5pt]

\useasboundingbox(0,-0.4)rectangle(5.25,5);

\coordinate (p)at (2.5,2.5);

%%題注

\path (p)+(-0.8,-2.5) coordinate[label=0:];

%%畫花括號:

\draw (p)+(0.5,+2.1) node[yscale=1,xscale=2.6,rotate=-90] ;

\draw (p)+(0.5,+2.1) coordinate[label=above:] ;

\draw (p)+(2.1,-0.5) node[yscale=2.6,xscale=1]} ;

\draw (p)+(2.1,-0.5) coordinate[label=right:] ;

%\clip[draw] (p) circle (2.0);

\foreach \i in

\foreach \i in

%矩形四個頂點座標點

%繪製節點

\foreach \i in

}\pgfmathsetmacro

\pgfmathsetmacro

%\draw[fill=blue] (p) circle (2pt);

\draw[fill=red] (p)+(1,0) circle (2pt);

\draw[fill=red] (p)+(-1,0) circle (2pt);

\draw[fill=red] (p)+(0,1) circle (2pt);

\draw[fill=red] (p)+(0,-1) circle (2pt);

\path (p)+(0,-0.25 ) node[blue,scale=1](mn)n)$};

\path (p)+(-0.65,\a ) node[scale=\s](w);

\path (p)+(\a,-0.65 ) node[scale=\s](s);

\path (p)+(+0.65,\a ) node[scale=\s](e);

\path (p)+(\a,+0.65 ) node[scale=\s](n);

%\pgfmathsetmacro

\pgfmathsetmacro

\path (p)+(\b,1+\c ) node[scale=\s](mn1)n+1)$};

\path (p)+(\b,-1-\c ) node[scale=\s](mn2)n-1)$};

\path (p)+(-1-\b,\c ) node[scale=\s](mn3)n)$};

\path (p)+(+1+\b,\c ) node[scale=\s](mn4)n)$};

%xelatex不支援pattern模式

\draw[dashed,pattern=north east lines] (2.0,2.0) rectangle (3.0,3.0);

\end

上面的例子使用pdflatex編譯兩次即可.圖形如下:

C 中如何定義乙個模板

如果兩個值相等,返回0,如果v1小返回 1,如果v2小返回1 int compare const string v1,const string v2 缺點 如果對每種希望比較的型別都不得不重複定義完全一樣的函式體,是非常繁瑣且容易出錯的。乙個函式模板就是乙個公式,可用來生成針對特定型別的函式版本。t...

前端如何定義乙個常量

為什麼會這樣?實際上,const定義的變數儲存的是指向實際資料的指標,對於基本資料型別string boolean number undefined null symbol而言,其值儲存在棧記憶體中的簡單資料段,按值訪問,就是等同於常量。但是相對於引用資料型別而言,const只能保證指向儲存在堆記憶...

python定義乙個 Python定義乙個類

在物件導向的世界裡,你的 通常稱為 類的方法 method,而資料通常稱為 類的屬性 attribute,例項化的資料物件通常稱為 例項 instance。python使用class建立類。每個定義的類都有乙個特殊的方法,名為 init 可以通過這個方法控制如何初始化物件。類中方法的定義與函式的定義...