## Dec 23, 2014

### 在win32 xp上嘗試跑python及opengl

---

noobtuts網站真的厲害

---

conda install pyopengl pyopengl_accelerate "pyvrml97==2.3.0a4" simpleparse numpy "openglContext==2.2.0a3" pydispatcher pillow

---

---

conda create -n tonytest -c https://conda.anaconda.org/menpo pyopengl pyopengl-accelerate menpo-pyvrml97 simpleparse numpy pydispatcher pillow

pip install PyDispatcher PyVRML97 OpenGLContext

http://cim.mcgill.ca/~fmannan/comp557/Python%20and%20PyOpenGL%20Installation.html

---

## Nov 30, 2014

### latex minted package "pygmentize not installed" and "undefined control sequence \PYGzus etc" error messages solution

\AtEndPreamble{%
% \ifthenelse{\boolean{minted@draft}}{}{%
% \TestAppExists{pygmentize}%
% \ifAppExists\else
% \PackageError{minted}%
% {You must have `pygmentize' installed
% to use this package}%
% {Refer to the installation instructions in the minted
% \fi
% }%
}

"_minted-yourlatexfilename"，移除之後就可以順利compile了。

http://whymranderson.blogspot.tw/2014/03/4th-runge-kutta.html

## Oct 30, 2014

### 陀螺儀教學文件的文書排版製作

1. 由於需要排出中英混雜，並且帶有許多數學公式的文件，而Scientific Workplace無法達到我的排版要求，這裡用上排版規則最為完整的排版引擎Latex，完整的說是TexLive 2013中的XeLatex排版引擎。其中也非常感謝套件xeCJK，其中文排版能力非常專業。
2. 所有向量圖片皆由開源軟體Python Matplotlib與其pgf套件，PSTricks與其套件pst-node所製作，這些軟件製作向量圖形都非常成熟。
3. 模擬程式是由開源軟體Python及其3D繪圖程式套件mplot3D所製作完成。Python軟體的強大已不用我在此贅述。
4. latex的minted套件，非常方便的就可以給出漂亮專業的程式碼區塊。
5. Sphinx，自動擷取程式說明行並自動排版成漂亮的說明書。我用它來作陀螺儀程式的說明書文件。這樣我就不用每次改了程式就要去改說明書，now sphinx will take care of that for me!

1. 使用Scientific Workplace 5.0編輯中文文件，但使用Xelatex來做排版。由於Scientific Workplace產生的中文文件使用其特殊的unicode編碼，因此要讓Xelatex讀到正確的中文字，要做個簡單的編碼轉換，我在我的blog中這篇文章有詳述如何轉換。我是寫了一個Python小程序來達成這個動作。這裡我學習到了電腦文字unicode與程式語言中的regular expression。
• (2016/六月: 由於此份文件已經開始越來越大，目前已近70頁，若每次更改後要看結果都要全部編譯後才看的到那會很麻煩會等很久，因此我必須將整個latex擋拆開成一個章節一個tex檔，並且每個章節都可以獨立編譯，獨立看到章節的pdf輸出結果，這樣就可以一個章節修改後很快看到結果。然後最後在全部編譯。目前我是用python程式語言配合windows batch執行檔來達成此目標，即在batch檔案可以選擇只編譯章節或編譯整份文件，然後用python去調整preamble，最後batch在執行xelatex。
不過後來我學到latex本身有一些套件可以達到此目的，目前考慮用import package，這樣才可以獨立章節編譯。還有想用另一個套件使得subdocument中可以用相對於subdoc所處在的subfolder路徑。)
3. minted套件有一個問題，就是他不會自動分割程式區塊，所以跨頁的程式區塊就要稍微用點技巧，參考這邊的解說，使用mdframed套件，並且在minted中不要使用背景顏色，讓mdframed來負責背景顏色的處理，然後將listing環境捨棄，這樣就可以跨頁了。
4. Sphinx中的autodoc套件，似乎還沒有辦法自動取得物件的屬性(autoattribute我無法用成功)，我得用autoclass加:member:指令來達到相同的目的。

6. GIT版本管理(請見我的另一篇部落格文章)

http://whymranderson.blogspot.tw/2014/11/latex-minted-package-pygmentize-not.html

Memo for myself:
http://www.chinabaike.com/t/30826/2014/0517/2213116.html

## Sep 28, 2014

### Diy 筆記簡易裝訂成書

2016八月。哥不是開玩笑的，現在自己的筆記我都自己裝訂拉，哈哈哈。後來發現也不用鐵絲，只要用粗一點的線綁就可以了!

## Jul 21, 2014

### Use python matplotlib to create 3D vector-based graphics, 3D vector graphics DIY

I drew the following graphs using Python and it's Matplotlib. If you are interested in the python code, they are here (not including the first gyroscope figure, will be added later). I am trying to improve the code into many functions/modules so that drawing can be convenient and automated. The part related to plotting starts from line 128, because this is just a portion of another bigger project. Just want to show this is not as time-consuming as one may think it is. We can create or draw beautiful vector-based graphs without buying expensive software like Adobe Illustrator or Acdsee Canvas. However as you can guess with this method you will need the numerical x,y,z locations of everything! (which is generated from yet another portion of the program!)

## Jun 25, 2014

### Python code for 3D rotation simulation (core algorithm: iteration of direction cosine matrix)

(ongoing revision persists...)

Iteration of DCM with angular velocity in body frame. (This is the module. Import it in Python to use the iteration method.)
An example. (A test code.)

The background theory is in this post (in Chinese language though, I want to translate it into English but it takes time. Hope someone is interested in translating it!). And it has a python simulation of a rotating symmetric top in 3D motion.

The approximation of rotation by iteration of DCM is discussed in this textbook[1]. The approximation of rotation ωdt is also discussed. Here I use ω(t+dt)dt to approximate the rotation from t to t+dt. This is discussed in the same post.

[1]  D.H. Titterton and J.L. Weston, Strapdown inertial navigation technology, Peter Peregrinus
Ltd., London UK, 1997

## May 22, 2014

### 模範生制度與無為而治

" 不尚賢，使民不爭；不貴難得之貨，使民不爲盜；不見可欲，使民心不亂。
是以聖人之治，虛其心，實其腹，弱其志，強其骨。
常使民無知無欲，使夫智者不敢爲也。
爲無爲，則無不治。"

- 老子道德經 -

## May 1, 2014

### direction of friction force of rolling objects 有外力作用的的純滾動摩擦的作用力方向討論

A sectional material I wrote up for university physics. These are more advanced problems for 1st and 2nd year engineering in university.

http://whymranderson.blogspot.tw/2013/06/3-dimentional-rolling-coin-simulation.html
http://whymranderson.blogspot.tw/2013/02/two-coins-roll-without-slipping-puzzle.html

## Mar 17, 2014

### 3/2-17感冒紀錄

(第二次用藥: Clarithromycin250 , Meptin25, Voren25, Medcon-A, Strocain, Tetosiv sustained)
(第三次用藥: Cravit500MG, Allegra, Panamax, Mucosolven, Gaster20MG, Anticough Capsules)

 尖點運動
 有環運動
 無環運動
 等周速運動

the python code

## Mar 12, 2014

### some great matches in CSGO, cool CSGO avitar names, and try to come up with some of my own, casters i like

Converted document
Some of the greatest matches in professional CSGO (chronologically, in reverse)
Some of the avatar names and casters I like:
Existing_names pusha, olofmeister, byali, apex, faflaren, karrigan, jkaem, hani, simple, cyjanb, nothing , shox, kioshima,
Cranking_my_head mehidae (somehow rhythm with meditate) toothless (from the movie "how to train your dragon") silen (silence) andoni (antoine) pfeifer (vacuum pump company - pfeiffer) timee continuing...
Casters ddk black ddk henryG warowl a few that I still need to find their names......

## Mar 9, 2014

### Typeset mix Chinese and English TeX documents with Scientific Workplace 5.0 and TEX live 2013

You can typeset Chinese documents with Scientific Workplace (5.0) if you have just a few Chinese paragraphs. But if you have a long Chinese document or a document with mix Chinese and English characters, the software will suffer. The SWP's compiler for international characters, Omega, is just not good enough for this purpose. You will run into a lot of overfull hbox problems during typesetting. We will need another latex compiler for long documents of mix Chinese and English. But we will want to use the convenient editing features of Scientific Workplace, what should we do?

Here is something you can try. Still prepare your international document with SWP. But typeset it with another latex compiler. Here I use a popular one, XeLATEX in TEX live 2013. But there are a few problems. First, the file prepared by SWP has a character encoding that is not recognized by other latex compiler. So I wrote a small Python program to convert the encoding. Second, the figure insertion syntax generated by SWP is not recognized  by XeLatex. But this can be done by inserting TEX fields containing the correct Xelatex figure insertion commands into the SWP file by using SWP's TEX OBJECTS buttons. You won't be able to preview the figures SWP window but that doesn't really hurt. Here are step-by-step details:

• How to convert SWP 5.0 special unicode format file to unicode correct characters:
SWP version 5.0 produced Chinese character in its special unicode codepoint format (if you open the tex file with any text editor, you will see every Chinese character has a form like \U{6211} instead of displaying 我 in the tex file.) This is due to the extra parenthesis {} after \U. So I wrote a small python program to automatically remove all {} in the tex file. So that the file can then be prepared by other tex programs (Tex Life 2013 in my case).

The program is very simple:
import re
import codecs
def dashrepl(matchobj):
return chr(int(matchobj.group(1),16))
f1 = open('rotationV4pngtest.tex', 'r')   # name of your origianl file
f2 = codecs.open('rotationV4pngtest.tex.temp', "w", "utf-8")   #  name of the new file
p= re.compile(r"\\U{([\w]{,4})}")
for line in f1:
m = re.sub(p,dashrepl,line)
##    print(m)
f2.write(m)
f1.close()
f2.close()

• For the SWP tex file to be readable by other compiler, you will also need to change the preamble (the packages and stuff)  in the beginning of the tex document so that other tex program can use it. Here is my case:
Original preamble generated by SWP:
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{sw2unicode}
\usepackage[UT1]{fontenc}
\usepackage{pmingliu}
\usepackage[left=0.95in,right=0.95in,top=2cm,bottom=2.54cm]{geometry}
Change the above to the following so that Xelatex can complie:
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{xeCJK}
\setmainfont[Mapping=tex-text]{Times New Roman} % rm
\setsansfont[Mapping=tex-text]{Arial}           % sf
\setmonofont{Courier New}                       % tt
\setCJKmainfont{微軟正黑體}
\usepackage[left=0.95in,right=0.95in,top=2cm,bottom=2.54cm]{geometry}
\usepackage{unicode-math}
\usepackage{graphicx}

• The file generated by SWP has symbols that use SWP's "tcilatex" macro, so you need to copy tcilatex.tex file into the same directory as your tex file. The location of tcilatex.tex in SWP's path has the following structure "D:\swp50\TCITeX\TeX\LaTeX\SWmacros\". Locate this file and copy it into your working directory. Then make sure your tex file has the \input{tcilatex.tex} line. You should have this line because you prepared your file with SWP.

• Change the TEX figure insertion command:

The figure insertion command for Xelatex should look like this:
\begin{figure}[th]
\caption{{}}
\label{firstfig}
\begin{center}
\fbox{\includegraphics[scale=0.7]{cordtrans.JPG}}
\end{center}
\end{figure}

So open the SWP tex file with Notepad and replace all things look like the following with the above

\FRAME{fhF}{5.5097in}{3.7135in}{0pt}{}{}{cordtrans.JPG}{\special{language
"Scientific Word";type "GRAPHIC";maintain-aspect-ratio TRUE;display
"USEDEF";valid_file "F";width 5.5097in;height 3.7135in;depth
0pt;original-width 9.135in;original-height 6.1436in;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename
'
cordtrans.JPG';file-properties "XNPEU";}}

There could be other commands you need to change before you can run your tex document with TEX life Xelatex. Here I only show three points, which is enough for me to typeset this document. Good luck!

### 鋼琴伴奏譜+彈唱 [轉錄 from 鸠玖的音乐世界 土豆網]

http://www.tudou.com/plcover/-ysO_c-u4NY/

## Mar 1, 2014

### 使用Scientific Workplace 5.0 + XeLatex軟體做中英文混雜並夾帶數學公式的長篇圖文文章電腦排版

這邊介紹如何利用Scientific Workplace 5.0的編輯方便性，加上XeLatex (TeX life 2013)對中英文混雜的完美支援，來對中英文混雜並夾帶數學公式的長篇圖文文章做自動排版。

## Feb 5, 2014

### 新酷音輸入法 2013 安裝問題

• 開啟->執行-> sfc /scannow 讓windows執行檔案修復，然後看看ctfmon有沒有出現在system32檔案夾中。(這一步我只跑一次，需要不少時間。)
• 如果沒有，或者檔案其實存在但是不正常運作，去另一台xp電腦(輸入法是正常的電腦)拷貝一份ctfmon.exe放到你的system32檔案夾中。我就是這樣做。
• 控制台->區域與語言選項->語言->文字服務與輸入語言->細節->移除所有的中文輸入法直到只剩下英文輸入法。
• 重新啟動電腦，如果還是不正常，再去控制台->區域與語言選項->語言->文字服務與輸入語言->細節->進階->確認[關閉進階文字服務]沒有被勾選。再到system32資料夾中執行ctfmon.exe(滑鼠左鍵雙擊)。或者到工作管理員看看ctfmon.exe有沒有在背景中執行。(這一步我重複做多次)
• 控制台->區域與語言選項->語言->文字服務與輸入語言，安裝windows本身內建的舊版微軟新注音輸入法，安裝後，我的語言輸入視窗就神奇的出現了。(也是只做一次)