旋轉矩陣程式記錄

三度空間中一個點, 分別繞 X Y Z 軸旋轉 Ω Φ Κ 弧度, 結果可以表示成旋轉矩陣乘上該點的座標向量; 實作中需要用到矩陣的相乘, 將多次旋轉的相乘,用一個矩陣代表三次轉旋。

低階的 C 語言

一開始用 C 寫,結果覺得宣告矩陣超麻煩。 我是用二維陣列模擬矩陣, 但 C 又只能在初始化陣列時對多個陣列賦值。 覺得不管怎麼作都很麻煩, 在副函數宣告的矩陣又不能回傳, 試了很多寫法都不滿意。

C 的問題是對底層過於嚴格, 我認為需要親自管理記憶體的語言都太低階, 不想用。

JS 物向導向

後來改用我唯一熟練的語言 JavaScript 寫, 就她不尋常的 物件導向 風格來寫。 宣告一個 matrix class , 有 public 方法 multiply , 可以接受另一個 matrix 作輸入, 返回一個新的 matrix ; 所以可以像 jQuery 鏈式呼叫m4 = m1.multiply(m2).multiply(m3)

用 matlab 寫,還可以用匿名函數, 一行搞定一種矩陣宣告。 mw = @(w) [1 0 0; 0 cos(w) sin(w); 0 -sin(w) cos(w)] 可惜老師規定不能用 matlab QQ

其實我是用 JS 的方言 CoffeeScript 寫的, 然後再編譯成 JS , 最原始是 wfk.coffee , 編譯好的 JS 是 wfk.js

可以直接引用原始碼, 看要用 nodejs require 或直接在網頁中引用。 或用我包好的版本: 計算旋轉矩陣 。 (媽的超麻煩,寫這個浪費了我 寫核心程式 2 到 3 倍的時間。)


class Matrix3
# Matrix3 is 2 demition array,
# access m(i,j) by m[i][j].

    constructor: (a = 0) ->
    # a = number, [1,2,3,4,5,6,7,8,9], [[1,2,3],[4,5,6],[7,8,9]].
    # if no arguments, a = 0.
        a = [1..9].map( -> a ) if typeof a == 'number'

        if a.length >= 9
            for i in [0..2]
                this[i] = a.slice i*3,(i+1)*3
        else if a.length >= 3
            for i in [0..2]
                this[i] = a[i].slice 0
        else
            throw new Error 'arguments not array!'

    ':': (n) ->
    # m[':'](n) to access nth column of m, 
    # just like syntax of matlab. 
        this.reduce(
            (s,v,i) ->
                s.push v if i[1] == n
                return s
            []
        )

    size: [3,3] # Matrix3 is [3,3] matrix.

    forEach: (callback) ->
    # callback will get 3 argument v,i,m, 
    # v = current value, i = [row, col], m = matrix it self.
    # row first order.
        for i in [0..2]
            for j in [0..2]
                callback this[i][j], [i,j], this
        return undefined

    map: (callback) ->
    # map will return a new Matrix3 instance.
        m = new Matrix3()
        this.forEach (v,i,a) -> m[i[0]][i[1]] = callback v,i,a
        return m

    reduce: (callback, sum) ->
        this.forEach (v,i,a) -> sum = callback sum, v, i, a
        return sum

    multiply: (m) ->
    # matrix to matrix multiply, return a new matrix.
        @map (v,i,a) ->
            a[i[0]].reduce(
                (s,v,j) -> s + v*m[j][i[1]]
                0
            )

    add: (m) -> @map (v,i) -> v + m[i[0]][i[1]]
    # add by matrix, return a new matrix.

    # convert Matrix3 into 1 demantion array, 
    # and slice.
    slice: (start, end) ->
        (this.reduce ((s,v) -> s.push v), []).slice start, end


sin = Math.sin
cos = Math.cos

# define omega, phi, kappa rotate matrix.
rotateMatrix =
    omega: (w) -> new Matrix3 [
        [1, 0, 0]
        [0, cos(w), sin(w)]
        [0, -sin(w), cos(w)]
    ]
    phi: (f) -> new Matrix3 [
        [cos(f), 0, -sin(f)]
        [0, 1, 0]
        [sin(f), 0, cos(f)]
    ]
    kappa: (k) -> new Matrix3 [
        [cos(k), sin(k), 0]
        [-sin(k), cos(k), 0]
        [0, 0, 1]
    ]

# define a function directly return 
# a matrix rotate by omega, phi, kappa. 
rotateWFKMatrix = (w, f, k) ->
    rotateMatrix.kappa k
        .multiply rotateMatrix.phi f
        .multiply rotateMatrix.omega w


# check is excute in nodejs or browser.
if  typeof exports == 'object'
    md = exports
else if typeof window == 'object'
    window.rotateWFK = {}
    md = window.rotateWFK
else
    md = {}

# export modules.
md.Matrix3 = Matrix3
md.rotateMatrix = rotateMatrix
md.rotateWFKMatrix = rotateWFKMatrix

轉換成果

成果和 australis 的計算結果相比, 誤差大約在 1E-9 , 而 australis 的輸出小數到 1E-8 而已, 我的計算結果則是到 1E-16 , 可以視為資料型態轉換造成的誤差。 (比較上是把矩陣平展,再逐項比較。 反正都差很少,也看不出系統誤差。)

wfk.js australis 絕對誤差 相對誤差
-0.9594048627 -0.95940486 2.72450939586832E-09 -2.83979111369972E-09
0.2702826332 0.27028263 -3.15688525320823E-09 -1.16799413014748E-08
-0.0805581007 -0.0805581 7.36957675440131E-10 -9.14815115351691E-09
-0.2625913422 -0.26259134 2.17179546568858E-09 -8.2706286722501E-09
-0.9602687102 -0.96026871 2.28323915330009E-10 -2.377708582528E-10
-0.0944975723 -0.09449758 -7.68808326723214E-09 8.13574619289948E-08
-0.1028984762 -0.10289848 -3.83548021121172E-09 3.72744107708075E-08
-0.0695075706 -0.06950757 5.96385427154011E-10 -8.5801507253672E-09
0.9922603495 0.99226035 4.7835946315189E-10 4.82090676254362E-10
0.9520811777 0.95208118 2.32005359368515E-09 2.43682329030508E-09
-0.2955838473 -0.29558384 7.33637389727093E-09 -2.48199424477026E-08
0.0785596608 0.07855967 9.22302081929338E-09 1.17401471000239E-07
0.2866815354 0.28668153 -5.435108030305E-09 -0.000000019
0.9519762174 0.95197622 2.62365085212934E-09 2.75600461125945E-09
0.1074940872 0.10749408 -7.2345410634389E-09 -6.7301762696503E-08
-0.1065604446 -0.10656045 -5.42446480789049E-09 5.09050478661689E-08
-0.079821493 -0.07982149 0.000000003 -3.74972591668433E-08
0.9910970694 0.99109707 6.3281679896221E-10 6.38501331622553E-10
0.9636887734 0.96368877 -3.41986905461056E-09 -3.54872772317411E-09
-0.2587704255 -0.25877042 5.51757856070978E-09 -2.13222924038605E-08
0.0658924492 0.06589245 7.97077487346698E-10 1.20966436571519E-08
0.2520336641 0.25203366 -4.12110612302286E-09 -1.63514116448686E-08
0.9629732244 0.96297322 -4.38664171653613E-09 -4.55531018457204E-09
0.0957162539 0.09571626 6.0820583014376E-09 6.35425820172832E-08
-0.0882212 -0.0882212 2.69656796891837E-11 -3.05659860545807E-10
-0.0756335639 -0.07563357 -6.07600045277046E-09 8.03347039253926E-08
0.993225344 0.99322534 -0.000000004 -0.000000004
0.9545324099 0.95453241 7.95191690272645E-11 8.33069345725668E-11
-0.2850706968 -0.2850707 -3.21131610192538E-09 1.12649812903444E-08
0.0871927534 0.08719275 -3.39048221442706E-09 -3.88849097479671E-08
0.2751016782 0.27510168 1.80754772260983E-09 6.57047140755311E-09
0.9550181014 0.9550181 -1.41304812295573E-09 -1.47960349961506E-09
0.1107225931 0.11072259 -3.12856379691695E-09 -2.82558762120444E-08
-0.1148344246 -0.11483442 4.57336406245457E-09 -3.98257252699545E-08
-0.0817014309 -0.08170143 8.67710556184953E-10 -1.06205063508063E-08
0.9900191569 0.99001916 3.05046243820328E-09 3.0812155576901E-09
0.961410574 0.96141057 -0.000000004 -4.20614477641533E-09
-0.2650761582 -0.26507616 -1.82773840506911E-09 6.89514441837815E-09
0.0736501085 0.07365011 1.47772001579671E-09 2.00640571452875E-08
0.2553348839 0.25533488 -3.86440202060356E-09 -1.51346420849496E-08
0.9593906515 0.95939065 -1.47957002205601E-09 -1.5421976668795E-09
0.1198902621 0.11989027 7.94524047942335E-09 6.627093657745E-08
-0.1024392757 -0.10243928 -4.33552746481603E-09 4.23229005984426E-08
-0.0964583238 -0.09645833 -6.24180518382644E-09 6.47098615933579E-08
0.990051507 0.99005151 0.000000003 0.000000003
0.9598871125 0.95988711 -2.53507992376001E-09 -2.64101882122368E-09
-0.2704259661 -0.27042597 -3.90049081921973E-09 1.44235068074998E-08
0.0740711013 0.0740711 -1.3028283035732E-09 -1.75888882921031E-08
0.2623042215 0.26230422 -1.49910328595126E-09 -5.71513216962832E-09
0.9594156415 0.95941564 -1.50188239622651E-09 -1.56541370977286E-09
0.1035283644 0.10352837 5.64857624563153E-09 5.45606604801325E-08
-0.0990617311 -0.09906174 -8.87836031082667E-09 8.96245140740176E-08
-0.0799463802 -0.07994638 1.59948262967724E-10 -0.000000002
0.9918645824 0.99186458 -2.3531078197081E-09 -2.37240835811286E-09
0.9559630327 0.95596303 -2.72121392086433E-09 -2.84656815741539E-09
-0.2783277551 -0.27832776 -4.92865476209303E-09 1.77080962462854E-08
0.0931039249 0.09310393 5.1235249098891E-09 0.000000055
0.2646134953 0.2646135 4.70903604998796E-09 1.77959025143765E-08
0.9546076761 0.95460767 -6.06786720869224E-09 -6.35639896827168E-09
0.1367621399 0.13676215 1.01285992648581E-08 7.40599593151913E-08
-0.1269424207 -0.12694242 7.2828948427528E-10 -5.73716401716053E-09
-0.106102995 -0.106103 -0.000000005 4.70671358164068E-08
0.9862189292 0.98621893 8.21295254027632E-10 8.32771739665991E-10
0.9591083881 0.95910839 1.94911886630678E-09 0.000000002
-0.2712804576 -0.27128045 7.621841213723E-09 -2.80957998032037E-08
0.0807342138 0.08073421 -3.83109376167479E-09 -4.74531646705255E-08
0.2600352478 0.26003525 2.24868024201186E-09 8.64759774688954E-09
0.9571911252 0.95719113 4.7903979671915E-09 0.000000005
0.1271488095 0.12714881 5.4082352485274E-10 4.25346902462351E-09
-0.1117710602 -0.11177106 1.96054936174583E-10 -1.75407602088218E-09
-0.1009557484 -0.10095574 8.38740288333639E-09 -8.30800000409723E-08
0.9885925182 0.98859252 1.83582282708983E-09 1.85700659265541E-09
0.9594020635 0.95940206 -3.4557541273017E-09 -3.60198739546348E-09
-0.2773046897 -0.27730469 -2.92897650577828E-10 1.05623042501671E-09
0.0514761081 0.05147611 1.91781443503736E-09 3.7256397871505E-08
0.1584491538 0.15844915 -3.84842605005708E-09 -2.42880826439087E-08
0.6809204859 0.68092049 4.10480183177242E-09 0.000000006
0.7150112989 0.7150113 1.11517461931498E-09 1.55966013308459E-09
-0.2333271229 -0.23332712 2.90164425820194E-09 -1.24359494010038E-08
-0.6778269698 -0.67782697 -2.24752105815185E-10 3.31577402143182E-10
0.6972152127 0.69721522 7.34056149198636E-09 1.05284011040183E-08
-0.164085842 -0.16408584 0.000000002 -1.24422380836272E-08
-0.7737012247 -0.77370123 -5.25002008533448E-09 6.78559097719734E-09
-0.6119332082 -0.61193321 -1.82946624516234E-09 0.000000003
0.9728603987 0.9728604 1.26117027932082E-09 1.29635277509581E-09
-0.2295256894 -0.22952569 -6.4689295586895E-10 2.81839020228607E-09
0.0293360272 0.02933603 2.78590451055494E-09 0.000000095
-0.1631517116 -0.16315171 1.62824453919797E-09 -0.00000001
-0.5905119582 -0.59051196 -1.82526338488032E-09 3.09098461761946E-09
0.790365198 0.7903652 0.000000002 2.50179462572408E-09
0.7199795511 0.71997955 -1.12597831058991E-09 -1.56390318390281E-09
0.6938632721 0.69386327 -2.07028416632227E-09 -0.000000003
0.0135353475 0.01353535 2.48494752205786E-09 1.83589454432863E-07
-0.5641813119 -0.56418131 1.91079418954132E-09 -3.38684418585458E-09
0.5738361799 0.57383618 1.41630374095314E-10 2.46813252687054E-10
0.5936425574 0.59364256 2.58336074754339E-09 4.35171081322639E-09
0.4041396952 0.40413969 -5.21818788179473E-09 -1.29118421449641E-08
-0.4350468921 -0.43504689 2.13632067591618E-09 -4.91055268988633E-09
0.8046150063 0.80461501 3.68239549963789E-09 4.57659309591787E-09
0.5156791556 0.51567915 -5.56001089613289E-09 -1.07819191373801E-08
-0.6615452525 -0.66154525 2.49261655760336E-09 -3.76787008538472E-09
-0.5444565065 -0.54445651 -3.54113305345294E-09 6.50397779880148E-09
0.7686902888 0.76869029 1.21652243834092E-09 1.58259113477408E-09
0.6378911057 0.63789111 4.3296485285893E-09 6.78744139981713E-09
-0.0470125221 -0.04701252 2.12581675179679E-09 -4.52180983235273E-08
0.3784048737 0.37840488 6.28549828851632E-09 1.66105106480559E-08
-0.3942750515 -0.39427505 1.46932227496066E-09 -3.7266427965976E-09
0.8374705579 0.83747056 2.10678363643524E-09 2.51565098173151E-09
0.2645595106 0.26455951 -5.77307646132397E-10 -2.18214664115607E-09
0.9636631015 0.9636631 -1.54788160067199E-09 -1.60624766131648E-09
0.0369011122 0.03690111 -2.15414470983166E-09 -5.83761493849822E-08
-0.7765103501 -0.77651035 6.00870464495529E-11 -7.73808700032818E-11
0.1901763787 0.19017639 1.13218153463546E-08 5.95332330493526E-08
0.6007200856 0.60072008 -5.59928536869592E-09 -9.32095589129619E-09
0.571874061 0.57187406 -0.000000001 -1.69975089573915E-09
-0.1875803074 -0.1875803 7.35652677663623E-09 -3.92180137073895E-08
0.798607342 0.79860734 -0.000000002 -2.49108651829599E-09
0.8369535479 0.83695355 2.07956440956281E-09 2.48468318171636E-09
-0.2179541712 -0.21795417 1.22043278261152E-09 -5.59949269431975E-09
-0.5020007349 -0.50200073 4.93074636676027E-09 -9.82218963458534E-09
0.2435769416 0.24357694 -1.64434771354749E-09 -6.75083492529091E-09
0.9697664364 0.96976644 3.630408640376E-09 3.74359071486945E-09
-0.0149443096 -0.01494431 -3.73608434120487E-10 0.000000025
0.4900806384 0.49008064 1.61221253014432E-09 3.28968826465848E-09
-0.1097681108 -0.10976811 7.54616119591489E-10 -6.87463890552082E-09
0.86473807 0.86473807 -1.81882287009216E-11 -2.10332230439694E-11
0.8486912434 0.84869124 -3.44307260480292E-09 -4.05692016427897E-09
-0.2198460621 -0.21984606 2.13804723925293E-09 -9.72520153080263E-09
-0.4810310616 -0.48103106 1.64305535843567E-09 -3.41569494168562E-09
0.2501558595 0.25015586 5.15546161317104E-10 2.06089979789841E-09
0.968204903 0.9682049 -0.000000003 -3.07237932216082E-09
-0.0011453477 -0.00114535 -2.29745720733455E-09 2.00589968772389E-06
0.4659884325 0.46598843 -2.54811088895579E-09 -5.46818488380879E-09
-0.1193606921 -0.11936069 2.09819212004803E-09 -1.75785857140071E-08
0.8767028036 0.8767028 -3.64168750710547E-09 -4.15384495989459E-09
-0.5993440434 -0.59934405 -6.61189691886221E-09 0.000000011
0.800472525 0.80047252 -0.000000005 -6.21498096496341E-09
-0.0055185519 -0.00551855 1.93626493658061E-09 -3.5086479901072E-07
-0.6430518322 -0.64305183 2.22879692479694E-09 -3.46596778178353E-09
-0.4773486693 -0.47734867 -7.43171635342321E-10 1.55687379487686E-09
0.5988510575 0.59885105 -7.46414297037035E-09 -1.24641060082809E-08
0.4767295446 0.47672954 -4.62922367105989E-09 -9.71037723204627E-09
0.3624665291 0.36246653 8.98334295840186E-10 2.47839240726637E-09
0.8008414054 0.80084141 4.62774751852635E-09 5.7786066763535E-09
0.7774084482 0.77740845 1.83670301190375E-09 2.36259718029017E-09
0.4094381908 0.40943819 -7.8522183200036E-10 -1.91780310478698E-09
-0.4774897618 -0.47748976 1.82831272343975E-09 -3.82900928271164E-09
-0.4864110979 -0.4864111 -2.07834938148466E-09 4.2728247391654E-09
0.8726384083 0.87263841 1.66778468813078E-09 1.91119789023587E-09
-0.0436629376 -0.04366294 -2.37468118780004E-09 5.43866534823363E-08
0.3987986316 0.39879863 -1.57110879861477E-09 -3.93960430258944E-09
0.2662002559 0.26620026 4.12119310899683E-09 1.54815517798399E-08
0.8775517507 0.87755175 -7.40130956522478E-10 -8.43404342276655E-10
-0.9718175942 -0.97181759 4.17989032275301E-09 -4.30110585130797E-09
0.2345009441 0.23450095 5.89290180541546E-09 2.51295434215318E-08
-0.0240805078 -0.02408051 -2.21279803855334E-09 9.18916600418074E-08
-0.1959216396 -0.19592164 -4.27099161592892E-10 2.17994888973414E-09
-0.7466583531 -0.74665835 3.1393435628857E-09 -4.20452481765683E-09
0.6357011993 0.6357012 6.66296129381294E-10 0.000000001
0.1310926191 0.13109262 8.73383171340336E-10 6.66233668485942E-09
0.6225035027 0.6225035 -2.7211676245642E-09 -4.37132903600414E-09
0.7715595339 0.77155953 -3.87305176818842E-09 -0.000000005
0.2250586861 0.22505869 3.93503052364963E-09 1.74844638243013E-08
0.8457460311 0.84574603 -1.08117603758728E-09 -1.27836962780338E-09
-0.483799792 -0.48379979 0.000000002 -4.12946520277624E-09
-0.9702075749 -0.97020757 4.92668117413331E-09 -5.077966124438E-09
0.2402362225 0.24023623 7.51687820321756E-09 3.12895278252475E-08
-0.0313658885 -0.03136589 -1.49148944583732E-09 4.75513191507502E-08
0.0896986588 0.08969866 1.24972766857301E-09 1.39325121308725E-08
0.4764453886 0.47644539 1.40076261700983E-09 2.94002764306279E-09
0.8746164544 0.87461646 5.6036035811502E-09 6.40692673580622E-09
-0.7951456108 -0.79514561 8.22672818756587E-10 -0.000000001
-0.6064184746 -0.60641848 -5.37803868105868E-09 8.86852702948413E-09
0.0003020374 0.00030203 -7.43499251916599E-09 -2.46167351559977E-05
0.4490426978 0.4490427 2.15618728427458E-09 4.80174220463795E-09
-0.5884570884 -0.58845709 -1.62106472689771E-09 2.7547713409277E-09
0.6723681363 0.67236814 3.74595632290919E-09 5.57128766230535E-09
-0.4075587235 -0.40755873 -6.49798886920294E-09 1.59436871078751E-08
0.5347662001 0.5347662 -1.04082631402491E-10 -1.94632030600459E-10
0.7402168588 0.74021686 1.15142484435893E-09 1.5555236668872E-09
-0.5755819944 -0.57558199 4.40526759515336E-09 -7.65358831876126E-09
0.62510739 0.62510739 -2.10860218174957E-11 -3.37318389684943E-11
-0.5272059547 -0.52720595 4.68704686173993E-09 -8.89035273926618E-09
-0.729194251 -0.72919425 0.000000001 -1.34279503851079E-09
-0.684140584 -0.68414058 0.000000004 -5.80689900294781E-09
-0.0150799768 -0.01507998 -3.19666860343348E-09 0.000000212
-0.3701095947 -0.37010959 4.65460858745104E-09 -1.25762982457467E-08
0.3757557881 0.37575579 1.88427345948483E-09 0.000000005
0.8496037168 0.84960372 3.17542625527523E-09 3.73753807866475E-09
-0.3624886001 -0.3624886 1.47824807950059E-10 -4.07805398432003E-10
-0.9252581218 -0.92525812 1.7895642745458E-09 -1.93412436579945E-09
0.1118008176 0.11180082 2.35845463991691E-09 2.10951461708144E-08
0.6916127615 0.69161276 -1.4843259954489E-09 -2.14618075503537E-09
-0.1866444324 -0.18664443 2.4149081068181E-09 -1.2938549019749E-08
0.6977360848 0.69773609 5.22256660140386E-09 7.48501715226434E-09
-0.6247189792 -0.62471898 -8.46256731357187E-10 1.35461985060417E-09
0.3302442489 0.33024425 1.13112946786842E-09 3.42512993903276E-09
0.7075768037 0.7075768 -3.72814679128197E-09 -5.26889348446977E-09
-0.2893735823 -0.28937358 2.27872865021794E-09 -7.87469488478507E-09
-0.9476182468 -0.94761825 -3.24799998008274E-09 3.42754055241416E-09
0.1352131218 0.13521312 -1.78128761740837E-09 -1.31739258542985E-08
0.7394685761 0.73946858 3.93040200385997E-09 5.31517107036511E-09
-0.1316087278 -0.13160873 -2.22528087623353E-09 1.69083074977893E-08
0.6602010056 0.660201 -5.58778379122771E-09 -8.4637614775314E-09
-0.6078232925 -0.60782329 2.48291975868398E-09 -4.08493685505861E-09
0.2910305846 0.29103058 -4.64048988124688E-09 -1.59450250253663E-08
0.7388180046 0.73881801 5.40141309457454E-09 7.31088444172407E-09
-0.8504016826 -0.85040168 2.56628907013834E-09 -0.000000003
0.1722354225 0.17223542 -2.5353331933875E-09 -1.47201614707794E-08
-0.4971437795 -0.49714378 -4.82947459801153E-10 0.000000001
-0.2823501632 -0.28235016 3.21357329635674E-09 -1.13815175325445E-08
-0.9467075222 -0.94670752 2.18269435858787E-09 -2.30556355841334E-09
0.1549943637 0.15499436 -3.69097988284217E-09 -2.38136399469127E-08
-0.443954236 -0.44395424 -0.000000004 9.11306168803196E-09
0.272176095 0.27217609 -0.000000005 -1.82174456139018E-08
0.8537123694 0.85371237 5.73664227232484E-10 6.7196429077452E-10
0.4741558416 0.47415584 -1.64767771648755E-09 -3.47497083762071E-09
-0.8775287934 -0.87752879 3.36950800594593E-09 -3.83976918403547E-09
0.0715503644 0.07155037 5.64846472372871E-09 7.89438925854431E-08
0.6533281588 0.65332816 1.20883891785439E-09 1.85027830096041E-09
0.4051588178 0.40515882 2.20744544865425E-09 5.44834603046345E-09
0.6395378404 0.63953784 -3.93741483861731E-10 -6.15665656095864E-10
-0.5902021304 -0.59020213 4.2815562206755E-10 -7.25438964558718E-10
-0.2564947352 -0.25649473 5.17480736039744E-09 -2.01751020786955E-08
0.7654226911 0.76542269 -1.10973696898498E-09 -1.44983547454672E-09
-0.6693679095 -0.66936791 -5.42633715738816E-10 8.10665864963285E-10
-0.526992966 -0.52699297 -0.000000004 7.61135850864784E-09
-0.5236649841 -0.52366499 -5.88617632413246E-09 1.12403472382839E-08
0.562273929 0.56227393 0.000000001 1.71790425746299E-09
-0.8200579644 -0.82005796 4.41218384050757E-09 -5.3803317030269E-09
0.1065502873 0.10655029 2.65764667217727E-09 2.49426507631023E-08
-0.4855868929 -0.4855869 -7.14016618053037E-09 1.47041985286884E-08
-0.223121825 -0.22312183 -0.000000005 2.22980900091605E-08
0.8452348908 0.84523489 -8.32323987509653E-10 -0.000000001
旋轉矩陣程式記錄
================
三度空間中一個點,
分別繞 X Y Z 軸旋轉 Ω Φ Κ 弧度,
結果可以表示成旋轉矩陣乘上該點的座標向量;
實作中需要用到矩陣的相乘,
將多次旋轉的相乘,用一個矩陣代表三次轉旋。

低階的 C 語言
-------------
一開始用 C 寫,結果覺得宣告矩陣超麻煩。
我是用二維陣列模擬矩陣,
但 C 又只能在初始化陣列時對多個陣列賦值。
覺得不管怎麼作都很麻煩,
在副函數宣告的矩陣又不能回傳,
試了很多寫法都不滿意。

C 的問題是對底層過於嚴格,
我認為需要親自管理記憶體的語言都太低階,
不想用。

JS 物向導向
-----------
後來改用我唯一熟練的語言 JavaScript 寫,
就她不尋常的 **物件導向** 風格來寫。
宣告一個 matrix class ,
有 public 方法 multiply ,
可以接受另一個 matrix 作輸入,
返回一個新的 matrix ;
所以可以像 jQuery **鏈式呼叫** :
`m4 = m1.multiply(m2).multiply(m3)` 。

用 matlab 寫,還可以用匿名函數,
一行搞定一種矩陣宣告。
`mw = @(w) [1 0 0; 0 cos(w) sin(w); 0 -sin(w) cos(w)]`
可惜老師規定不能用 matlab QQ

其實我是用 JS 的方言 CoffeeScript 寫的,
然後再編譯成 JS ,
最原始是 [wfk.coffee](wfk.coffee) ,
編譯好的 JS 是 [wfk.js](wfk.js) 。

原始碼
------
可以直接引用原始碼,
看要用 nodejs `require`
或直接在網頁中引用。
或用我包好的版本: [計算旋轉矩陣](wfk.html) 。
(媽的超麻煩,寫這個浪費了我
寫核心程式 2 到 3 倍的時間。)


    class Matrix3
    # Matrix3 is 2 demition array,
    # access m(i,j) by m[i][j].
    
        constructor: (a = 0) ->
        # a = number, [1,2,3,4,5,6,7,8,9], [[1,2,3],[4,5,6],[7,8,9]].
        # if no arguments, a = 0.
            a = [1..9].map( -> a ) if typeof a == 'number'
    
            if a.length >= 9
                for i in [0..2]
                    this[i] = a.slice i*3,(i+1)*3
            else if a.length >= 3
                for i in [0..2]
                    this[i] = a[i].slice 0
            else
                throw new Error 'arguments not array!'
    
        ':': (n) ->
        # m[':'](n) to access nth column of m, 
        # just like syntax of matlab. 
            this.reduce(
                (s,v,i) ->
                    s.push v if i[1] == n
                    return s
                []
            )
    
        size: [3,3] # Matrix3 is [3,3] matrix.
    
        forEach: (callback) ->
        # callback will get 3 argument v,i,m, 
        # v = current value, i = [row, col], m = matrix it self.
        # row first order.
            for i in [0..2]
                for j in [0..2]
                    callback this[i][j], [i,j], this
            return undefined
    
        map: (callback) ->
        # map will return a new Matrix3 instance.
            m = new Matrix3()
            this.forEach (v,i,a) -> m[i[0]][i[1]] = callback v,i,a
            return m
    
        reduce: (callback, sum) ->
            this.forEach (v,i,a) -> sum = callback sum, v, i, a
            return sum
    
        multiply: (m) ->
        # matrix to matrix multiply, return a new matrix.
            @map (v,i,a) ->
                a[i[0]].reduce(
                    (s,v,j) -> s + v*m[j][i[1]]
                    0
                )
    
        add: (m) -> @map (v,i) -> v + m[i[0]][i[1]]
        # add by matrix, return a new matrix.
    
        # convert Matrix3 into 1 demantion array, 
        # and slice.
        slice: (start, end) ->
            (this.reduce ((s,v) -> s.push v), []).slice start, end
    
    
    sin = Math.sin
    cos = Math.cos
    
    # define omega, phi, kappa rotate matrix.
    rotateMatrix =
        omega: (w) -> new Matrix3 [
            [1, 0, 0]
            [0, cos(w), sin(w)]
            [0, -sin(w), cos(w)]
        ]
        phi: (f) -> new Matrix3 [
            [cos(f), 0, -sin(f)]
            [0, 1, 0]
            [sin(f), 0, cos(f)]
        ]
        kappa: (k) -> new Matrix3 [
            [cos(k), sin(k), 0]
            [-sin(k), cos(k), 0]
            [0, 0, 1]
        ]
    
    # define a function directly rotate by
    # omega, phi, kappa. 
    rotateWFKMatrix = (w, f, k) ->
        rotateMatrix.kappa k
            .multiply rotateMatrix.phi f
            .multiply rotateMatrix.omega w
    
    
    # check is excute in nodejs or browser.
    if  typeof exports == 'object'
        md = exports
    else if typeof window == 'object'
        window.rotateWFK = {}
        md = window.rotateWFK
    else
        md = {}
    
    # export modules.
    md.Matrix3 = Matrix3
    md.rotateMatrix = rotateMatrix
    md.rotateWFKMatrix = rotateWFKMatrix




轉換成果
--------
成果和 australis 的計算結果相比,
誤差大約在 1E-9 ,
而 australis 的輸出小數到 1E-8 而已,
我的計算結果則是到 1E-16 ,
可以視為資料型態轉換造成的誤差。
(比較上是把矩陣平展,再逐項比較。
反正都差很少,也看不出系統誤差。)

wfk.js|australis|絕對誤差|相對誤差
-------|----------|-------|----------
-0.9594048627|-0.95940486|2.72450939586832E-09|-2.83979111369972E-09
0.2702826332|0.27028263|-3.15688525320823E-09|-1.16799413014748E-08
-0.0805581007|-0.0805581|7.36957675440131E-10|-9.14815115351691E-09
-0.2625913422|-0.26259134|2.17179546568858E-09|-8.2706286722501E-09
-0.9602687102|-0.96026871|2.28323915330009E-10|-2.377708582528E-10
-0.0944975723|-0.09449758|-7.68808326723214E-09|8.13574619289948E-08
-0.1028984762|-0.10289848|-3.83548021121172E-09|3.72744107708075E-08
-0.0695075706|-0.06950757|5.96385427154011E-10|-8.5801507253672E-09
0.9922603495|0.99226035|4.7835946315189E-10|4.82090676254362E-10
0.9520811777|0.95208118|2.32005359368515E-09|2.43682329030508E-09
-0.2955838473|-0.29558384|7.33637389727093E-09|-2.48199424477026E-08
0.0785596608|0.07855967|9.22302081929338E-09|1.17401471000239E-07
0.2866815354|0.28668153|-5.435108030305E-09|-0.000000019
0.9519762174|0.95197622|2.62365085212934E-09|2.75600461125945E-09
0.1074940872|0.10749408|-7.2345410634389E-09|-6.7301762696503E-08
-0.1065604446|-0.10656045|-5.42446480789049E-09|5.09050478661689E-08
-0.079821493|-0.07982149|0.000000003|-3.74972591668433E-08
0.9910970694|0.99109707|6.3281679896221E-10|6.38501331622553E-10
0.9636887734|0.96368877|-3.41986905461056E-09|-3.54872772317411E-09
-0.2587704255|-0.25877042|5.51757856070978E-09|-2.13222924038605E-08
0.0658924492|0.06589245|7.97077487346698E-10|1.20966436571519E-08
0.2520336641|0.25203366|-4.12110612302286E-09|-1.63514116448686E-08
0.9629732244|0.96297322|-4.38664171653613E-09|-4.55531018457204E-09
0.0957162539|0.09571626|6.0820583014376E-09|6.35425820172832E-08
-0.0882212|-0.0882212|2.69656796891837E-11|-3.05659860545807E-10
-0.0756335639|-0.07563357|-6.07600045277046E-09|8.03347039253926E-08
0.993225344|0.99322534|-0.000000004|-0.000000004
0.9545324099|0.95453241|7.95191690272645E-11|8.33069345725668E-11
-0.2850706968|-0.2850707|-3.21131610192538E-09|1.12649812903444E-08
0.0871927534|0.08719275|-3.39048221442706E-09|-3.88849097479671E-08
0.2751016782|0.27510168|1.80754772260983E-09|6.57047140755311E-09
0.9550181014|0.9550181|-1.41304812295573E-09|-1.47960349961506E-09
0.1107225931|0.11072259|-3.12856379691695E-09|-2.82558762120444E-08
-0.1148344246|-0.11483442|4.57336406245457E-09|-3.98257252699545E-08
-0.0817014309|-0.08170143|8.67710556184953E-10|-1.06205063508063E-08
0.9900191569|0.99001916|3.05046243820328E-09|3.0812155576901E-09
0.961410574|0.96141057|-0.000000004|-4.20614477641533E-09
-0.2650761582|-0.26507616|-1.82773840506911E-09|6.89514441837815E-09
0.0736501085|0.07365011|1.47772001579671E-09|2.00640571452875E-08
0.2553348839|0.25533488|-3.86440202060356E-09|-1.51346420849496E-08
0.9593906515|0.95939065|-1.47957002205601E-09|-1.5421976668795E-09
0.1198902621|0.11989027|7.94524047942335E-09|6.627093657745E-08
-0.1024392757|-0.10243928|-4.33552746481603E-09|4.23229005984426E-08
-0.0964583238|-0.09645833|-6.24180518382644E-09|6.47098615933579E-08
0.990051507|0.99005151|0.000000003|0.000000003
0.9598871125|0.95988711|-2.53507992376001E-09|-2.64101882122368E-09
-0.2704259661|-0.27042597|-3.90049081921973E-09|1.44235068074998E-08
0.0740711013|0.0740711|-1.3028283035732E-09|-1.75888882921031E-08
0.2623042215|0.26230422|-1.49910328595126E-09|-5.71513216962832E-09
0.9594156415|0.95941564|-1.50188239622651E-09|-1.56541370977286E-09
0.1035283644|0.10352837|5.64857624563153E-09|5.45606604801325E-08
-0.0990617311|-0.09906174|-8.87836031082667E-09|8.96245140740176E-08
-0.0799463802|-0.07994638|1.59948262967724E-10|-0.000000002
0.9918645824|0.99186458|-2.3531078197081E-09|-2.37240835811286E-09
0.9559630327|0.95596303|-2.72121392086433E-09|-2.84656815741539E-09
-0.2783277551|-0.27832776|-4.92865476209303E-09|1.77080962462854E-08
0.0931039249|0.09310393|5.1235249098891E-09|0.000000055
0.2646134953|0.2646135|4.70903604998796E-09|1.77959025143765E-08
0.9546076761|0.95460767|-6.06786720869224E-09|-6.35639896827168E-09
0.1367621399|0.13676215|1.01285992648581E-08|7.40599593151913E-08
-0.1269424207|-0.12694242|7.2828948427528E-10|-5.73716401716053E-09
-0.106102995|-0.106103|-0.000000005|4.70671358164068E-08
0.9862189292|0.98621893|8.21295254027632E-10|8.32771739665991E-10
0.9591083881|0.95910839|1.94911886630678E-09|0.000000002
-0.2712804576|-0.27128045|7.621841213723E-09|-2.80957998032037E-08
0.0807342138|0.08073421|-3.83109376167479E-09|-4.74531646705255E-08
0.2600352478|0.26003525|2.24868024201186E-09|8.64759774688954E-09
0.9571911252|0.95719113|4.7903979671915E-09|0.000000005
0.1271488095|0.12714881|5.4082352485274E-10|4.25346902462351E-09
-0.1117710602|-0.11177106|1.96054936174583E-10|-1.75407602088218E-09
-0.1009557484|-0.10095574|8.38740288333639E-09|-8.30800000409723E-08
0.9885925182|0.98859252|1.83582282708983E-09|1.85700659265541E-09
0.9594020635|0.95940206|-3.4557541273017E-09|-3.60198739546348E-09
-0.2773046897|-0.27730469|-2.92897650577828E-10|1.05623042501671E-09
0.0514761081|0.05147611|1.91781443503736E-09|3.7256397871505E-08
0.1584491538|0.15844915|-3.84842605005708E-09|-2.42880826439087E-08
0.6809204859|0.68092049|4.10480183177242E-09|0.000000006
0.7150112989|0.7150113|1.11517461931498E-09|1.55966013308459E-09
-0.2333271229|-0.23332712|2.90164425820194E-09|-1.24359494010038E-08
-0.6778269698|-0.67782697|-2.24752105815185E-10|3.31577402143182E-10
0.6972152127|0.69721522|7.34056149198636E-09|1.05284011040183E-08
-0.164085842|-0.16408584|0.000000002|-1.24422380836272E-08
-0.7737012247|-0.77370123|-5.25002008533448E-09|6.78559097719734E-09
-0.6119332082|-0.61193321|-1.82946624516234E-09|0.000000003
0.9728603987|0.9728604|1.26117027932082E-09|1.29635277509581E-09
-0.2295256894|-0.22952569|-6.4689295586895E-10|2.81839020228607E-09
0.0293360272|0.02933603|2.78590451055494E-09|0.000000095
-0.1631517116|-0.16315171|1.62824453919797E-09|-0.00000001
-0.5905119582|-0.59051196|-1.82526338488032E-09|3.09098461761946E-09
0.790365198|0.7903652|0.000000002|2.50179462572408E-09
0.7199795511|0.71997955|-1.12597831058991E-09|-1.56390318390281E-09
0.6938632721|0.69386327|-2.07028416632227E-09|-0.000000003
0.0135353475|0.01353535|2.48494752205786E-09|1.83589454432863E-07
-0.5641813119|-0.56418131|1.91079418954132E-09|-3.38684418585458E-09
0.5738361799|0.57383618|1.41630374095314E-10|2.46813252687054E-10
0.5936425574|0.59364256|2.58336074754339E-09|4.35171081322639E-09
0.4041396952|0.40413969|-5.21818788179473E-09|-1.29118421449641E-08
-0.4350468921|-0.43504689|2.13632067591618E-09|-4.91055268988633E-09
0.8046150063|0.80461501|3.68239549963789E-09|4.57659309591787E-09
0.5156791556|0.51567915|-5.56001089613289E-09|-1.07819191373801E-08
-0.6615452525|-0.66154525|2.49261655760336E-09|-3.76787008538472E-09
-0.5444565065|-0.54445651|-3.54113305345294E-09|6.50397779880148E-09
0.7686902888|0.76869029|1.21652243834092E-09|1.58259113477408E-09
0.6378911057|0.63789111|4.3296485285893E-09|6.78744139981713E-09
-0.0470125221|-0.04701252|2.12581675179679E-09|-4.52180983235273E-08
0.3784048737|0.37840488|6.28549828851632E-09|1.66105106480559E-08
-0.3942750515|-0.39427505|1.46932227496066E-09|-3.7266427965976E-09
0.8374705579|0.83747056|2.10678363643524E-09|2.51565098173151E-09
0.2645595106|0.26455951|-5.77307646132397E-10|-2.18214664115607E-09
0.9636631015|0.9636631|-1.54788160067199E-09|-1.60624766131648E-09
0.0369011122|0.03690111|-2.15414470983166E-09|-5.83761493849822E-08
-0.7765103501|-0.77651035|6.00870464495529E-11|-7.73808700032818E-11
0.1901763787|0.19017639|1.13218153463546E-08|5.95332330493526E-08
0.6007200856|0.60072008|-5.59928536869592E-09|-9.32095589129619E-09
0.571874061|0.57187406|-0.000000001|-1.69975089573915E-09
-0.1875803074|-0.1875803|7.35652677663623E-09|-3.92180137073895E-08
0.798607342|0.79860734|-0.000000002|-2.49108651829599E-09
0.8369535479|0.83695355|2.07956440956281E-09|2.48468318171636E-09
-0.2179541712|-0.21795417|1.22043278261152E-09|-5.59949269431975E-09
-0.5020007349|-0.50200073|4.93074636676027E-09|-9.82218963458534E-09
0.2435769416|0.24357694|-1.64434771354749E-09|-6.75083492529091E-09
0.9697664364|0.96976644|3.630408640376E-09|3.74359071486945E-09
-0.0149443096|-0.01494431|-3.73608434120487E-10|0.000000025
0.4900806384|0.49008064|1.61221253014432E-09|3.28968826465848E-09
-0.1097681108|-0.10976811|7.54616119591489E-10|-6.87463890552082E-09
0.86473807|0.86473807|-1.81882287009216E-11|-2.10332230439694E-11
0.8486912434|0.84869124|-3.44307260480292E-09|-4.05692016427897E-09
-0.2198460621|-0.21984606|2.13804723925293E-09|-9.72520153080263E-09
-0.4810310616|-0.48103106|1.64305535843567E-09|-3.41569494168562E-09
0.2501558595|0.25015586|5.15546161317104E-10|2.06089979789841E-09
0.968204903|0.9682049|-0.000000003|-3.07237932216082E-09
-0.0011453477|-0.00114535|-2.29745720733455E-09|2.00589968772389E-06
0.4659884325|0.46598843|-2.54811088895579E-09|-5.46818488380879E-09
-0.1193606921|-0.11936069|2.09819212004803E-09|-1.75785857140071E-08
0.8767028036|0.8767028|-3.64168750710547E-09|-4.15384495989459E-09
-0.5993440434|-0.59934405|-6.61189691886221E-09|0.000000011
0.800472525|0.80047252|-0.000000005|-6.21498096496341E-09
-0.0055185519|-0.00551855|1.93626493658061E-09|-3.5086479901072E-07
-0.6430518322|-0.64305183|2.22879692479694E-09|-3.46596778178353E-09
-0.4773486693|-0.47734867|-7.43171635342321E-10|1.55687379487686E-09
0.5988510575|0.59885105|-7.46414297037035E-09|-1.24641060082809E-08
0.4767295446|0.47672954|-4.62922367105989E-09|-9.71037723204627E-09
0.3624665291|0.36246653|8.98334295840186E-10|2.47839240726637E-09
0.8008414054|0.80084141|4.62774751852635E-09|5.7786066763535E-09
0.7774084482|0.77740845|1.83670301190375E-09|2.36259718029017E-09
0.4094381908|0.40943819|-7.8522183200036E-10|-1.91780310478698E-09
-0.4774897618|-0.47748976|1.82831272343975E-09|-3.82900928271164E-09
-0.4864110979|-0.4864111|-2.07834938148466E-09|4.2728247391654E-09
0.8726384083|0.87263841|1.66778468813078E-09|1.91119789023587E-09
-0.0436629376|-0.04366294|-2.37468118780004E-09|5.43866534823363E-08
0.3987986316|0.39879863|-1.57110879861477E-09|-3.93960430258944E-09
0.2662002559|0.26620026|4.12119310899683E-09|1.54815517798399E-08
0.8775517507|0.87755175|-7.40130956522478E-10|-8.43404342276655E-10
-0.9718175942|-0.97181759|4.17989032275301E-09|-4.30110585130797E-09
0.2345009441|0.23450095|5.89290180541546E-09|2.51295434215318E-08
-0.0240805078|-0.02408051|-2.21279803855334E-09|9.18916600418074E-08
-0.1959216396|-0.19592164|-4.27099161592892E-10|2.17994888973414E-09
-0.7466583531|-0.74665835|3.1393435628857E-09|-4.20452481765683E-09
0.6357011993|0.6357012|6.66296129381294E-10|0.000000001
0.1310926191|0.13109262|8.73383171340336E-10|6.66233668485942E-09
0.6225035027|0.6225035|-2.7211676245642E-09|-4.37132903600414E-09
0.7715595339|0.77155953|-3.87305176818842E-09|-0.000000005
0.2250586861|0.22505869|3.93503052364963E-09|1.74844638243013E-08
0.8457460311|0.84574603|-1.08117603758728E-09|-1.27836962780338E-09
-0.483799792|-0.48379979|0.000000002|-4.12946520277624E-09
-0.9702075749|-0.97020757|4.92668117413331E-09|-5.077966124438E-09
0.2402362225|0.24023623|7.51687820321756E-09|3.12895278252475E-08
-0.0313658885|-0.03136589|-1.49148944583732E-09|4.75513191507502E-08
0.0896986588|0.08969866|1.24972766857301E-09|1.39325121308725E-08
0.4764453886|0.47644539|1.40076261700983E-09|2.94002764306279E-09
0.8746164544|0.87461646|5.6036035811502E-09|6.40692673580622E-09
-0.7951456108|-0.79514561|8.22672818756587E-10|-0.000000001
-0.6064184746|-0.60641848|-5.37803868105868E-09|8.86852702948413E-09
0.0003020374|0.00030203|-7.43499251916599E-09|-2.46167351559977E-05
0.4490426978|0.4490427|2.15618728427458E-09|4.80174220463795E-09
-0.5884570884|-0.58845709|-1.62106472689771E-09|2.7547713409277E-09
0.6723681363|0.67236814|3.74595632290919E-09|5.57128766230535E-09
-0.4075587235|-0.40755873|-6.49798886920294E-09|1.59436871078751E-08
0.5347662001|0.5347662|-1.04082631402491E-10|-1.94632030600459E-10
0.7402168588|0.74021686|1.15142484435893E-09|1.5555236668872E-09
-0.5755819944|-0.57558199|4.40526759515336E-09|-7.65358831876126E-09
0.62510739|0.62510739|-2.10860218174957E-11|-3.37318389684943E-11
-0.5272059547|-0.52720595|4.68704686173993E-09|-8.89035273926618E-09
-0.729194251|-0.72919425|0.000000001|-1.34279503851079E-09
-0.684140584|-0.68414058|0.000000004|-5.80689900294781E-09
-0.0150799768|-0.01507998|-3.19666860343348E-09|0.000000212
-0.3701095947|-0.37010959|4.65460858745104E-09|-1.25762982457467E-08
0.3757557881|0.37575579|1.88427345948483E-09|0.000000005
0.8496037168|0.84960372|3.17542625527523E-09|3.73753807866475E-09
-0.3624886001|-0.3624886|1.47824807950059E-10|-4.07805398432003E-10
-0.9252581218|-0.92525812|1.7895642745458E-09|-1.93412436579945E-09
0.1118008176|0.11180082|2.35845463991691E-09|2.10951461708144E-08
0.6916127615|0.69161276|-1.4843259954489E-09|-2.14618075503537E-09
-0.1866444324|-0.18664443|2.4149081068181E-09|-1.2938549019749E-08
0.6977360848|0.69773609|5.22256660140386E-09|7.48501715226434E-09
-0.6247189792|-0.62471898|-8.46256731357187E-10|1.35461985060417E-09
0.3302442489|0.33024425|1.13112946786842E-09|3.42512993903276E-09
0.7075768037|0.7075768|-3.72814679128197E-09|-5.26889348446977E-09
-0.2893735823|-0.28937358|2.27872865021794E-09|-7.87469488478507E-09
-0.9476182468|-0.94761825|-3.24799998008274E-09|3.42754055241416E-09
0.1352131218|0.13521312|-1.78128761740837E-09|-1.31739258542985E-08
0.7394685761|0.73946858|3.93040200385997E-09|5.31517107036511E-09
-0.1316087278|-0.13160873|-2.22528087623353E-09|1.69083074977893E-08
0.6602010056|0.660201|-5.58778379122771E-09|-8.4637614775314E-09
-0.6078232925|-0.60782329|2.48291975868398E-09|-4.08493685505861E-09
0.2910305846|0.29103058|-4.64048988124688E-09|-1.59450250253663E-08
0.7388180046|0.73881801|5.40141309457454E-09|7.31088444172407E-09
-0.8504016826|-0.85040168|2.56628907013834E-09|-0.000000003
0.1722354225|0.17223542|-2.5353331933875E-09|-1.47201614707794E-08
-0.4971437795|-0.49714378|-4.82947459801153E-10|0.000000001
-0.2823501632|-0.28235016|3.21357329635674E-09|-1.13815175325445E-08
-0.9467075222|-0.94670752|2.18269435858787E-09|-2.30556355841334E-09
0.1549943637|0.15499436|-3.69097988284217E-09|-2.38136399469127E-08
-0.443954236|-0.44395424|-0.000000004|9.11306168803196E-09
0.272176095|0.27217609|-0.000000005|-1.82174456139018E-08
0.8537123694|0.85371237|5.73664227232484E-10|6.7196429077452E-10
0.4741558416|0.47415584|-1.64767771648755E-09|-3.47497083762071E-09
-0.8775287934|-0.87752879|3.36950800594593E-09|-3.83976918403547E-09
0.0715503644|0.07155037|5.64846472372871E-09|7.89438925854431E-08
0.6533281588|0.65332816|1.20883891785439E-09|1.85027830096041E-09
0.4051588178|0.40515882|2.20744544865425E-09|5.44834603046345E-09
0.6395378404|0.63953784|-3.93741483861731E-10|-6.15665656095864E-10
-0.5902021304|-0.59020213|4.2815562206755E-10|-7.25438964558718E-10
-0.2564947352|-0.25649473|5.17480736039744E-09|-2.01751020786955E-08
0.7654226911|0.76542269|-1.10973696898498E-09|-1.44983547454672E-09
-0.6693679095|-0.66936791|-5.42633715738816E-10|8.10665864963285E-10
-0.526992966|-0.52699297|-0.000000004|7.61135850864784E-09
-0.5236649841|-0.52366499|-5.88617632413246E-09|1.12403472382839E-08
0.562273929|0.56227393|0.000000001|1.71790425746299E-09
-0.8200579644|-0.82005796|4.41218384050757E-09|-5.3803317030269E-09
0.1065502873|0.10655029|2.65764667217727E-09|2.49426507631023E-08
-0.4855868929|-0.4855869|-7.14016618053037E-09|1.47041985286884E-08
-0.223121825|-0.22312183|-0.000000005|2.22980900091605E-08
0.8452348908|0.84523489|-8.32323987509653E-10|-0.000000001