cstm quat2mat vs glm quat2mat

Edit on GitHub

Setup

Tests

  • cstm quat2mat

    var mat4 = {
        fromQuat: function(q) {
            var x = q[0], y = q[1], z = q[2], w = q[3];
            var xx = x * x, 
                xy = x * y, yy = y * y,
                xz = x * z, yz = y * z, zz = z * z,
                xw = x * w, yw = y * w, zw = z * w;
    
            var m = new Float32Array(16);
            m[0] = 1 - 2 * (yy + zz); m[4] =     2 * (xy - zw); m[8]  =     2 * (xz + yw); m[12] = 0;
            m[1] =     2 * (xy + zw); m[5] = 1 - 2 * (xx + zz); m[9]  =     2 * (yz - xw); m[13] = 0;
            m[2] =     2 * (xz - yw); m[6] =     2 * (yz + xw); m[10] = 1 - 2 * (xx + yy); m[14] = 0;
            m[3] =                 0; m[7] =                 0; m[11] =                 0; m[15] = 1;
            return m;
        },
        fromQuatGLM: function(q) {
            var x = q[0], y = q[1], z = q[2], w = q[3],
                x2 = x + x,
                y2 = y + y,
                z2 = z + z,
    
                xx = x * x2,
                yx = y * x2,
                yy = y * y2,
                zx = z * x2,
                zy = z * y2,
                zz = z * z2,
                wx = w * x2,
                wy = w * y2,
                wz = w * z2;
    
            var out = new Float32Array(16);
            out[0] = 1 - yy - zz;
            out[1] = yx + wz;
            out[2] = zx - wy;
            out[3] = 0;
    
            out[4] = yx - wz;
            out[5] = 1 - xx - zz;
            out[6] = zy + wx;
            out[7] = 0;
    
            out[8] = zx + wy;
            out[9] = zy - wx;
            out[10] = 1 - xx - yy;
            out[11] = 0;
    
            out[12] = 0;
            out[13] = 0;
            out[14] = 0;
            out[15] = 1;
    
            return out;
        }
    };
    
    var quats = [
        [0.28667385732968476, 0.4695627561800271, 0.09028506571766393, 0.6715668351168038],
        [0.2651236299616677, 0.3352433131520407, 0.23935617684737243, 0.10348812500929161],
        [0.002380091963310127, 0.28556139677867076, 0.5177704362031104, 0.31917225466802934],
        [0.8559490413154973, 0.9934662185106788, 0.1708025955882695, 0.3767980410764995],
        [0.09983228063189431, 0.829539443437229, 0.11236207084829108, 0.6833875656880277],
        [0.5657875528667418, 0.7004290732317235, 0.5720529027324792, 0.17027477054342688],
        [0.00010866305239920493, 0.18951173463191484, 0.9635388512417984, 0.16784613237675106],
        [0.43269230780136914, 0.18989169071386836, 0.3820386998898746, 0.3845793978155678],
        [0.24995371521143506, 0.29756469496920035, 0.6977832036715326, 0.6251103749225848],
        [0.6373743198581032, 0.13346268288090868, 0.7021060015911651, 0.5686906559847418],
        [0.42948550530630913, 0.8599292037909345, 0.516879198136017, 0.3547202730238612],
        [0.3534864785574121, 0.33083240173509254, 0.2914021372654776, 0.9194039888247587],
        [0.6285279991330446, 0.13070831475743372, 0.9658516407364588, 0.9860634955854315],
        [0.5204649545942466, 0.38381482856360893, 0.05142379356253923, 0.5931324901474515],
        [0.07531672900216613, 0.9021857878379353, 0.4092683406763107, 0.3521779725904437],
        [0.7014660569947004, 0.8119539533215514, 0.43696242700175403, 0.04899616263737494],
        [0.9289906854447096, 0.08996025442855671, 0.7875344292843567, 0.03415147099157578],
        [0.5118848978252626, 0.8031482286609193, 0.09583849926710397, 0.10219779007893348],
        [0.31744261852667743, 0.48898378035273926, 0.35958149292788577, 0.9004223374838385],
        [0.31593414995469193, 0.04691500923460157, 0.2252736707929106, 0.7133595249121447],
        [0.22443863603070913, 0.9310593108584775, 0.21226019799470963, 0.8315928517998981],
        [0.48711250766482506, 0.4947413386148647, 0.7641090451417427, 0.7268992100994618],
        [0.2847051984990572, 0.18705843432758318, 0.614353616295632, 0.04441531016475908],
        [0.20526455035026947, 0.30009202992784667, 0.9342812486283747, 0.2609376468219078],
        [0.451482342318807, 0.5391579452717814, 0.22187997265477155, 0.32989845009387286],
        [0.8936769847108745, 0.38717750323108846, 0.5275960180137027, 0.8090404625372274],
        [0.379369025476777, 0.07429784084149538, 0.18329971667318024, 0.5233650628290183],
        [0.6795279582300646, 0.1381483066944078, 0.2770972796093889, 0.5345339041208603],
        [0.21838116395615836, 0.4871869913236695, 0.7631664893254175, 0.29444908599973374],
        [0.2739811854906382, 0.8155863079619736, 0.7762331074515498, 0.2564909683605341],
        [0.5464767152377707, 0.385159229434358, 0.8310414576821084, 0.7166542824237923],
        [0.8210319451521648, 0.34465191470887446, 0.4452471636831081, 0.13331259433311815],
        [0.596172612573282, 0.6243660645258371, 0.15037061240822003, 0.8747719345879845],
        [0.49112197848778383, 0.503921884515536, 0.9644291478052724, 0.017316403762208],
        [0.1738737654051732, 0.5670423976144741, 0.08659296391546256, 0.03631192426432861],
        [0.06262551300033836, 0.07010413164654827, 0.2336469112244537, 0.16724598445110073],
        [0.811422929813884, 0.8349897048458801, 0.9145952917521003, 0.26239346177864364],
        [0.6630403599564261, 0.35317099689193787, 0.8027273513615203, 0.5803018039406345],
        [0.1757431759081889, 0.3507169191905668, 0.6105343485302794, 0.9243469954405543],
        [0.3327192772323335, 0.9325407166345281, 0.47143317745214053, 0.7623110696019169],
        [0.1761835366817237, 0.19347432368153927, 0.7206931938985313, 0.06373877012860119],
        [0.7448629845505879, 0.9060597128682091, 0.6483915429127347, 0.43602768214863996],
        [0.22526999649654234, 0.654494121383776, 0.3956191493640093, 0.8547340808445887],
        [0.1497425525905356, 0.6886505831339009, 0.09953326720883382, 0.6170557848208393],
        [0.3269691700903268, 0.1728553127205561, 0.36233013399467007, 0.6108827976664737],
        [0.3454364745648453, 0.8193827532498554, 0.36431562391691874, 0.02927035374366893],
        [0.8799073354665614, 0.8058528942974545, 0.01650076349707197, 0.8296909570916355],
        [0.04933980275395422, 0.7348046876829648, 0.9837937592327617, 0.5550349591972974],
        [0.10234802723849468, 0.8593564991221694, 0.5113221105157657, 0.9894171565701668],
        [0.5925673136728724, 0.15666598568830414, 0.1019331817685789, 0.307753155238484],
        [0.6517539099060352, 0.46198533776106476, 0.004978322573423233, 0.6326162773745858],
        [0.46995492843470865, 0.3333469039993653, 0.869156360409266, 0.2650441810533861],
        [0.565918462782592, 0.4581839713732756, 0.7432233245804771, 0.05518397377013429],
        [0.26615368534808437, 0.2194693079766974, 0.136312300630542, 0.33446245347806336],
        [0.8761697625101192, 0.21988100464207672, 0.9825023846297076, 0.9809547299321255],
        [0.5957885199056787, 0.3122752685701453, 0.13085311075410644, 0.6350017715773832],
        [0.22740409187079225, 0.23347161675464756, 0.2681422541867109, 0.9304096243007987],
        [0.573966849368859, 0.8413250365922318, 0.4152768676328018, 0.680898559110134],
        [0.44653736717433934, 0.9979343251461044, 0.33359494355594177, 0.21924262088391],
        [0.13582482578575572, 0.8400221987477128, 0.19372052131519735, 0.283091031986235],
        [0.059875127547221796, 0.03164645829352786, 0.8378437893894644, 0.28181260643711004],
        [0.6137045832764998, 0.35660745681037875, 0.7416201811057221, 0.28729696407068617],
        [0.5091202430305206, 0.5334306387922261, 0.2751463344480265, 0.5035010234565933],
        [0.27689528143897024, 0.46566864179512635, 0.318154677684368, 0.15246592054905572],
        [0.7635840223994299, 0.47461678152921505, 0.6478020160575964, 0.625972580154285],
        [0.19214395771429982, 0.7219182748234585, 0.971661268809324, 0.21923851821341156],
        [0.6929809392268698, 0.9953404032587705, 0.6224696267841732, 0.12516325845907583],
        [0.004522264121473052, 0.6197117867384869, 0.680787199527144, 0.6831867262179412],
        [0.2808063885930321, 0.7869676123894036, 0.39060933908806894, 0.8715179244604554],
        [0.8210544824187092, 0.06716738971144975, 0.1804248372374706, 0.5509682243816845],
        [0.6257781700257348, 0.8957411866929248, 0.5731879050079507, 0.1329316394752056],
        [0.15788810363581685, 0.8799370950543823, 0.3941977993482251, 0.49396922798063336],
        [0.3554508404664265, 0.9541054193266156, 0.4343526704232319, 0.9285601891522282],
        [0.8235933541799219, 0.07359819922059763, 0.8712360127621397, 0.4260334512987196],
        [0.8971781319183232, 0.13770308325314184, 0.4677548676323737, 0.5236879388666908],
        [0.10820674219444282, 0.1971145974291526, 0.2924082494229938, 0.01697044474616538],
        [0.6334537380875278, 0.7241545477168163, 0.6734635151786799, 0.22889224200953495],
        [0.5183212709360256, 0.9863766639445266, 0.5512352181977425, 0.9356602999313495],
        [0.05231292082853045, 0.4144613405309452, 0.26866147258050566, 0.7754638859875818],
        [0.4968293856026764, 0.1724477467886829, 0.8418557719322943, 0.858659291017603],
        [0.32717337464384366, 0.3533755372869627, 0.6397145521183494, 0.2284117110639745],
        [0.15382332260472031, 0.7013898206577873, 0.34276756863329116, 0.5355229860440793],
        [0.04441442588211286, 0.582750548213917, 0.8951149310495512, 0.6206465646471295],
        [0.16088276583720407, 0.762499521384203, 0.7110834074948384, 0.9907080011357603],
        [0.22079444601934584, 0.3131014072533913, 0.7595965483733602, 0.6191702204699028],
        [0.4851141719475689, 0.5450328976995951, 0.5023366741437734, 0.9394907997644997],
        [0.3213019831116133, 0.8183320400974194, 0.6822701049785296, 0.10511853329999776],
        [0.06998341082698789, 0.19968947882301835, 0.7241629935662803, 0.6123816245868936],
        [0.10174229985843497, 0.15532738526271372, 0.035552855756835866, 0.057295670262505816],
        [0.8470924016428083, 0.5197576563474231, 0.3935029193311501, 0.6819223263837924],
        [0.0891069262349351, 0.5887563449687969, 0.7723667962002954, 0.2191605608169811],
        [0.7964325363482141, 0.3820789695752633, 0.7973018972136354, 0.22287333921395436],
        [0.49240755567900196, 0.8885691633886943, 0.8647890662759572, 0.5241717648661399],
        [0.9176996103445059, 0.6128869778990567, 0.23415392073385877, 0.20904331189752523],
        [0.3866187537089252, 0.14070416543622577, 0.9625767275702548, 0.2328091465696298],
        [0.8291122233933506, 0.7626645742819809, 0.4466308919167783, 0.5583192567928092],
        [0.955157790580152, 0.049708681552077305, 0.8692635548748922, 0.6332541895862409],
        [0.8929106139737326, 0.48006806842915317, 0.755341046492972, 0.3183044180994352],
        [0.5918807952168674, 0.1257242084050656, 0.7995723787489055, 0.44984677550921237],
        [0.5530361091216869, 0.34598812653118416, 0.5963955868667188, 0.5333258862628545],
        [0.4910238333064927, 0.36269398347808934, 0.47144837837493303, 0.29354605755130203],
        [0.2883403825317261, 0.953531382178946, 0.485727706688303, 0.2546637485975509],
        [0.9311879107631806, 0.8728179849378577, 0.3134335696665491, 0.2892679730454806],
        [0.8655100631075441, 0.1658782530676337, 0.7189514884809478, 0.337738370214673],
        [0.12758289222687513, 0.42872555891405995, 0.13200835380459375, 0.4364744726845087],
        [0.7953022120536053, 0.19813772057398382, 0.0064724077790550005, 0.4631528075393483],
        [0.5801479964474237, 0.18403530850430982, 0.2267950908546632, 0.03476452941749897],
        [0.1866873976485155, 0.2489825839855615, 0.4270890521531656, 0.46207234661790664],
        [0.24966343223558596, 0.08656432665856673, 0.20625095809369087, 0.3369022735666902],
        [0.34077375180728553, 0.22765663770178035, 0.011476146039079982, 0.9998983960450649],
        [0.851563586490012, 0.6061397217540072, 0.9356015432573304, 0.7098682662773717],
        [0.2796577598447756, 0.9034184564714831, 0.6129713016010241, 0.2549258099376128],
        [0.28134725902105084, 0.2569338330390707, 0.3464502243133061, 0.3397220675802466],
        [0.009087322806848652, 0.6542224911370589, 0.7292862132996196, 0.13294005703800194],
        [0.06332496716500624, 0.584335652036593, 0.7368757502697509, 0.8793384701387321],
        [0.05871562171676481, 0.3623858378148126, 0.5850483515801899, 0.5280660161953179],
        [0.9396107221096133, 0.052009895568242426, 0.46901352480696334, 0.5002025317369199],
        [0.7072074782669271, 0.09681128264885075, 0.9951321378328568, 0.3986564263907504],
        [0.16722457625875253, 0.26158755927489574, 0.2674768198737838, 0.9167281283039481],
        [0.30798484938703985, 0.012919856579447053, 0.47871294391660557, 0.6416458082234289],
        [0.30554259648820814, 0.8974633382685584, 0.17374593958160833, 0.6172121475423193],
        [0.49091374292714995, 0.435582345746925, 0.6729590117010167, 0.4116437628389962],
        [0.4901006501343641, 0.5801140650918399, 0.9354665528017838, 0.5699836358565862],
        [0.21442370640844466, 0.14716547913757227, 0.18483200648100695, 0.9119908332223312],
        [0.6411497478062373, 0.8165182845599899, 0.7446114815208522, 0.6589356416297363],
        [0.9047454582102494, 0.833363570817574, 0.21841107343564636, 0.8449044774471963],
        [0.19045227006161514, 0.8485055544084514, 0.47880012910365854, 0.6903065380420514],
        [0.01211794504382957, 0.3975870420908032, 0.741082713380145, 0.04665050397816195],
        [0.9685523158620923, 0.9856972619844659, 0.6714859350750249, 0.3795506266761661],
        [0.2989551601561147, 0.8140954512378225, 0.7123707431311654, 0.03563150051658592],
        [0.7715001899888096, 0.39895646508887994, 0.840309049874987, 0.7996322362085666],
        [0.2360673371507782, 0.341692578053568, 0.6985954872472102, 0.31443929897243206],
        [0.8762018967785754, 0.7339011546551413, 0.1895347663963649, 0.36034266422334427],
        [0.3091006427139811, 0.3749757323207412, 0.7847826238136086, 0.8841450794639523],
        [0.9769191009095779, 0.4254547008671197, 0.49893547035213626, 0.6329091154275079],
        [0.7965451882446406, 0.507785480575154, 0.0544641819777163, 0.7487432602855455],
        [0.9288713075482016, 0.09762183623237597, 0.37962170669020434, 0.8197681246917374],
        [0.9414075002025897, 0.1873498940210303, 0.06788177174144283, 0.2368627067766711],
        [0.03186924552536374, 0.12580067419317031, 0.9481431100229842, 0.7609988660472464],
        [0.3854346805697808, 0.011632965060166311, 0.19724839392529692, 0.29498106997843077],
        [0.4481823848523221, 0.2997564336288534, 0.6155218766969408, 0.5776937266107864],
        [0.2842519685972482, 0.13398092117348748, 0.8629071737784724, 0.6593533822803903],
        [0.5559894349145276, 0.6167076429456249, 0.9538610437979151, 0.05715963602134155],
        [0.6563138443526018, 0.2606705019456961, 0.5047276167966837, 0.7670736901910089],
        [0.2717369757818424, 0.5975921544311527, 0.41740991387781357, 0.039392677617891225],
        [0.6827452849310289, 0.7203843477032512, 0.42634155303091914, 0.4097735528593409],
        [0.7814677590375414, 0.6682862285105025, 0.5515642885907228, 0.2846269108187913],
        [0.09692950197422356, 0.572498765904935, 0.9131422548386428, 0.14120185906218752],
        [0.03711462692502887, 0.3430887972494783, 0.4944508869795228, 0.3295949310594979],
        [0.8634195272887932, 0.6219188199780545, 0.6844738801650669, 0.12722015869535497],
        [0.8045597561655022, 0.48765719771694527, 0.9270802410349421, 0.5483938286609604],
        [0.8786585021563373, 0.18597136804001457, 0.46625086500024926, 0.45088694516395567],
        [0.915320762866265, 0.4420305526359416, 0.9254247514175904, 0.7402948474658229],
        [0.7971947207180619, 0.0913622472766018, 0.7836942091770382, 0.6830205923654153],
        [0.4386887042581791, 0.4700050064646957, 0.7170156597544024, 0.7615826728045123],
        [0.1009469616452443, 0.3058452918455683, 0.9622770254869222, 0.23717458224291432],
        [0.17124183104375246, 0.30896319487782553, 0.9524758835401419, 0.44875574965244835],
        [0.5626989398902904, 0.6853811826242455, 0.03802799762167752, 0.2100159931886414],
        [0.2208366772381991, 0.03432524176069296, 0.9817460656108368, 0.30527512835985626],
        [0.34199774485942225, 0.7712985594312238, 0.33082650999369756, 0.46012747786797314],
        [0.5485538937311245, 0.07747673923988319, 0.6424051644833066, 0.2141414452603152],
        [0.6656459694281927, 0.7523134602496666, 0.06005019493605679, 0.46537767212051984],
        [0.3286899281814455, 0.29019262373009536, 0.4879997405442589, 0.4594040837743487],
        [0.6457574835577273, 0.3103547845797048, 0.5489947329040432, 0.21717693212325773],
        [0.31088437224672893, 0.05127318447733997, 0.9993387184940603, 0.8192426129318648],
        [0.13882813621122692, 0.6814175140938643, 0.9023393791760352, 0.4853731077132102],
        [0.4590131188049038, 0.19471558521005372, 0.47692951358352675, 0.16028548443787805],
        [0.6182399936055263, 0.06892795999953427, 0.7777517169824366, 0.5996014011052602],
        [0.5409993197585685, 0.5437791900049089, 0.09728347742329957, 0.09437829524921204],
        [0.15600381917572004, 0.3438989257575762, 0.07981835285890804, 0.3973996129759958],
        [0.7338639899975345, 0.4820130028835439, 0.6598640785478334, 0.8127012815217483],
        [0.9701335205552701, 0.029014364937398618, 0.6867011057684504, 0.4260486786096136],
        [0.07994513503326917, 0.9549523206339148, 0.9212850243269375, 0.610055709057399],
        [0.10160676920406697, 0.6788117981980535, 0.12470979139423255, 0.5511024155483],
        [0.5646314765487266, 0.31567362749645245, 0.8717194327417583, 0.34329726941345795],
        [0.47568905489809366, 0.06825267349077047, 0.3592787085599891, 0.7722399075702449],
        [0.4478557092651967, 0.04659466683045288, 0.4717661280277734, 0.44347226563754516],
        [0.877183341241798, 0.8932136902029904, 0.4684572744963986, 0.3566950747000506],
        [0.1348704391325981, 0.8612855851931134, 0.4150546241239086, 0.927269621929423],
        [0.43442081691205003, 0.08301228580144682, 0.07683178052282691, 0.48385268401747816],
        [0.307554254930825, 0.7533401778680249, 0.2412250260416049, 0.48629796519844026],
        [0.4893346744702505, 0.24596127768762943, 0.8923525656677667, 0.9921901729642624],
        [0.49477370225992745, 0.4047563244237755, 0.40960949854652484, 0.3015559053084522],
        [0.13392654419157024, 0.9025776560470358, 0.01747938730256382, 0.795305511942626],
        [0.6449284404405919, 0.5616225252186764, 0.6478116811441128, 0.3982676662837459],
        [0.07339856748493001, 0.39476195312877516, 0.4105993717686567, 0.0425806068487764],
        [0.5354220985831335, 0.2650075746260412, 0.19384265749470964, 0.2913343159347841],
        [0.4388593858862171, 0.8572935700055999, 0.123982394705618, 0.07491435522397083],
        [0.265194257144578, 0.5335055701151044, 0.6524929608574261, 0.8484432997875464],
        [0.7828680777266233, 0.00241230098243439, 0.6240697613310402, 0.7020722535978319],
        [0.8546240757615138, 0.01816066747541445, 0.9351820016937373, 0.21112273328286713],
        [0.40832798028047557, 0.674415050459003, 0.48614445518893357, 0.4167601350876593],
        [0.03681887678851559, 0.5497005190303266, 0.32594016682068205, 0.29790419669236545],
        [0.3385319253749126, 0.27744564196847943, 0.9255037308056941, 0.9837203830608432],
        [0.15355812452797024, 0.8962704835177568, 0.06570754340104434, 0.30094717522322334],
        [0.28475415050173014, 0.5393350773284817, 0.04649368291324074, 0.5613027723088042],
        [0.9478722143727873, 0.9750280938834379, 0.4467296076720684, 0.8917316707785294],
        [0.15209771321760157, 0.18903694413505434, 0.5543251582330053, 0.45576846791872816],
        [0.1558980025404575, 0.9666547484728794, 0.6185611856594633, 0.24879606584833236],
        [0.2638326748413393, 0.5943888327819611, 0.7398670206736515, 0.10153950188076166],
        [0.05746307834540754, 0.10505114297724627, 0.29687115559328126, 0.11683785280243764],
        [0.05055794361363097, 0.31313927460030566, 0.3035063157543618, 0.05622064904802104],
        [0.7337207822096006, 0.28921537211992, 0.7188540953380707, 0.3535827457093763],
        [0.6123979070528458, 0.4385225866531117, 0.191186112645773, 0.23745602308491143],
        [0.8265163588150195, 0.42525764940440425, 0.1534360093415299, 0.8324431314899454],
        [0.5168965872035467, 0.1553680420519028, 0.37934407550405047, 0.007575417783621363],
        [0.04163963879637089, 0.7757841678148796, 0.26103896331689436, 0.2762731051295051],
        [0.612381396288489, 0.2948976737475011, 0.15767819855285792, 0.14968505758171924],
        [0.6267277738792159, 0.7582817317521644, 0.10871029137490096, 0.5530749200683389],
        [0.947231115841348, 0.28906680614140967, 0.44048238804652184, 0.21291945267212498],
        [0.29961440541416984, 0.8837482116796929, 0.7682394627102713, 0.45900626136797285],
        [0.5194984755097609, 0.7354492168639293, 0.787847748778945, 0.5441423054612091],
        [0.13922457020170986, 0.9701489670296413, 0.19154529103197326, 0.786478106428151],
        [0.7484806055416069, 0.33513076687366095, 0.2530991616948235, 0.48669146313090605],
        [0.3747671706845457, 0.6363702142432277, 0.18759239621288115, 0.22819721363616763],
        [0.8235934707334811, 0.0032884426059092142, 0.3253036580360542, 0.2139181305392288],
        [0.9911253847764951, 0.5117167545352417, 0.08856968958752454, 0.6577156884011599],
        [0.8692318941608888, 0.23017852192972277, 0.6748028790238008, 0.8640016227665555],
        [0.834246355046375, 0.26839557235386136, 0.3869240381084773, 0.4897302245459929],
        [0.8823610801632933, 0.67332343977154, 0.24421097532191793, 0.9253965765466154],
        [0.6440459532229867, 0.7345604927917342, 0.45949424775519243, 0.5805674921433213],
        [0.11269712752945438, 0.456304004086884, 0.8025049510758964, 0.14103969013450723],
        [0.9009212779791003, 0.716197840244694, 0.34843676034732685, 0.22663230877502527],
        [0.8141803817755857, 0.8971994869765756, 0.9786741579152767, 0.10298705713334932],
        [0.7338566324661415, 0.34767427933132256, 0.1439387267282004, 0.9540717791006725],
        [0.6053772343664201, 0.007839366943807269, 0.510009036647884, 0.1841121255870508],
        [0.7760415809553449, 0.11131792192352874, 0.7527968127040348, 0.3797350847615597],
        [0.625736475936082, 0.5532820161874068, 0.9722420059654959, 0.8256206005195752],
        [0.4325088649783857, 0.17020613559606157, 0.08851180635967815, 0.1782731719491195],
        [0.15511988907087582, 0.14085545117039389, 0.18416336997059224, 0.6896623185268673],
        [0.9691867105493766, 0.4423465319792941, 0.3917267430380207, 0.12289783829797396],
        [0.5079895220841621, 0.11015411853212287, 0.01908225361378646, 0.4423047768494677],
        [0.09230714318970157, 0.8838868459157301, 0.6994637471223224, 0.7836635519138162],
        [0.7920247189650689, 0.6071967932009945, 0.3753791373900024, 0.6490057544932903],
        [0.8974833059810652, 0.5268423281227352, 0.0995311194229509, 0.13249498098306778],
        [0.7444797982855593, 0.6867250089498371, 0.0873508425587497, 0.26174330224235365],
        [0.2663553829269685, 0.7655778842043681, 0.6023315674209895, 0.93491352705713],
        [0.6387067531008197, 0.12883715991129807, 0.5937839546235337, 0.7966986103684375],
        [0.36022938967151497, 0.17071075147913972, 0.17512769800754246, 0.8477856086040549],
        [0.4556953276671598, 0.03333146205430637, 0.6330272013168359, 0.30558350963646697],
        [0.3037986022863888, 0.7627068452289592, 0.2553400619081365, 0.07338266925312698],
        [0.3193480374923727, 0.02645095950050358, 0.7832939572004816, 0.6254845410969687],
        [0.8376408804868551, 0.3518098753011645, 0.22521468782103793, 0.8877588402289232],
        [0.616038315197293, 0.5966060032784317, 0.5942344220929852, 0.2943280061048099],
        [0.8004972290650461, 0.29875096996135464, 0.44281846930159907, 0.07120750516872643],
        [0.2274168196792843, 0.6331241690658493, 0.7782949373220951, 0.04797507493329878],
        [0.9133115277729551, 0.10048902993388675, 0.7238129981692387, 0.26944984594813315],
        [0.3074112815861223, 0.6637905397219577, 0.7913967904962338, 0.03531430909081279],
        [0.29727415801689894, 0.19360733366596516, 0.3432554695059722, 0.5263088403204981],
        [0.8616339814753722, 0.2129988546811432, 0.37956417148114796, 0.3894194413445342],
        [0.6528965945809992, 0.18782222430428175, 0.5547299345369512, 0.5078981038970389],
        [0.5879376382196329, 0.6572022875532615, 0.15880679972754996, 0.3628240488756682],
        [0.8840666619945632, 0.615945567217389, 0.013814296915753532, 0.5808121934728214],
        [0.6024185449749904, 0.36407999250599055, 0.8679980764242146, 0.04000968281375439],
        [0.53467616011092, 0.4664273360887288, 0.18629464411993446, 0.30574938933078877],
        [0.05531536968200301, 0.5129910418278905, 0.938681424122922, 0.83755868287787],
        [0.38326172074130316, 0.12072594889741528, 0.5684147351086868, 0.8674056419634537],
        [0.7703380002873461, 0.6809914906022667, 0.717752198710963, 0.23121671247621345],
        [0.8479798087214958, 0.22668223357355255, 0.8519254312221218, 0.8307396109631138],
        [0.8477164052708253, 0.9180589754387505, 0.24580024699050562, 0.9522679330957129],
        [0.7726004230664629, 0.1291433788081935, 0.657019400918941, 0.9960734204313153],
        [0.6258602999217553, 0.3919630328040924, 0.15268187314815163, 0.8101132002836022],
        [0.18966002617886102, 0.6380035011361007, 0.6776509606786476, 0.8243688167387477],
        [0.8523065829747545, 0.25819519239583033, 0.243372142504388, 0.35931248548239814],
        [0.7297254338202805, 0.8152017644815883, 0.6053144338849743, 0.47163026866518787],
        [0.051819705358636226, 0.5241929518703696, 0.7268759897366932, 0.17734396284078335],
        [0.8842614530992279, 0.8888853543978681, 0.6424253122049186, 0.5554983248397898],
        [0.5771044726711785, 0.40934996356227127, 0.6835990050097085, 0.4978071722382913],
        [0.328031599487588, 0.2144520465894768, 0.836550113462182, 0.11671298626972892],
        [0.1916577614448367, 0.5647384496834751, 0.2852655593116009, 0.4586065649802904],
        [0.6788242427782729, 0.9463274121634371, 0.3485140271079932, 0.6430685050788805],
        [0.43615258985858363, 0.1271518837893233, 0.3995820951342206, 0.07636799800890604],
        [0.15313010388673431, 0.5247558739543252, 0.10160915411064675, 0.8537004942886888],
        [0.13790102365087487, 0.7150404804098573, 0.4419075370645964, 0.5485172494899078],
        [0.12083161989209468, 0.12342067709124582, 0.8224445519675456, 0.5147045041087777],
        [0.6470922262042227, 0.16586847923417758, 0.8668085672778705, 0.6815463305803502],
        [0.20307630040429392, 0.15504406495030487, 0.3704713196639704, 0.20629381869036223],
        [0.12069645691607467, 0.3035399126316447, 0.990113415415351, 0.18155783421088234],
        [0.744127281091244, 0.8312062289874405, 0.09575510238013552, 0.07051741344767049],
        [0.08234509233102827, 0.06461111736802194, 0.24221691447912175, 0.8453545987945108],
        [0.03930740876195138, 0.43000660197559704, 0.3405411613103013, 0.8562548093271902],
        [0.7270214622601683, 0.3284944377369474, 0.7622899091401183, 0.2282821786747422],
        [0.7335446170546918, 0.3552918544083441, 0.322110719299753, 0.8829053594372005],
        [0.22228152428230263, 0.9596441212475109, 0.29874604095785884, 0.849936187856039],
        [0.7451449913232406, 0.2928550354650796, 0.823593166137438, 0.8213601520675797],
        [0.29474023920646153, 0.26245019480403253, 0.1633069472848092, 0.8732137709861272],
        [0.25809603086676747, 0.7724568957064084, 0.3509996761518792, 0.055512483811333446],
        [0.11713858297015478, 0.41364521939508503, 0.23145196416922698, 0.29226744363683776],
        [0.6755092595213561, 0.6104849301638415, 0.3744979890508926, 0.0002826765325538716],
        [0.0996444863193584, 0.0449486881953447, 0.09921609018539623, 0.33661601179780476],
        [0.39034186524077086, 0.17553891043329206, 0.1704869378990963, 0.8996115446982851],
        [0.5732476540872982, 0.9742912730790665, 0.08961645644770999, 0.2622345268135826],
        [0.19206094602377188, 0.7255193998287162, 0.04030388473905533, 0.14504505410735402],
        [0.6074451829384488, 0.9269527849060009, 0.21561196228895785, 0.9909398388723085],
        [0.5653381621252045, 0.3127506685693846, 0.19805124271697339, 0.6448835267605686],
        [0.8722334281473885, 0.2370377733003295, 0.15621432238292798, 0.33979610552155237],
        [0.35910966465502847, 0.3746524655599408, 0.8348140923427017, 0.8848705839998103],
        [0.6087682789643776, 0.19851753455691745, 0.3372484725356324, 0.4397493959451704],
        [0.7041447783817267, 0.6370213473946427, 0.4658299109408599, 0.4587036818718335],
        [0.7083833411881943, 0.2947025254429798, 0.5916785007660301, 0.10459853164967159]
    ];
    
    var mat;
    for(var i = 0; i < 300; ++i) {
        mat = mat4.fromQuat(quats[i]);
        // mat = mat4.fromQuatGLM(quats[i]);
    }
  • glm quat2mat

    var mat4 = {
        fromQuat: function(q) {
            var x = q[0], y = q[1], z = q[2], w = q[3];
            var xx = x * x, 
                xy = x * y, yy = y * y,
                xz = x * z, yz = y * z, zz = z * z,
                xw = x * w, yw = y * w, zw = z * w;
    
            var m = new Float32Array(16);
            m[0] = 1 - 2 * (yy + zz); m[4] =     2 * (xy - zw); m[8]  =     2 * (xz + yw); m[12] = 0;
            m[1] =     2 * (xy + zw); m[5] = 1 - 2 * (xx + zz); m[9]  =     2 * (yz - xw); m[13] = 0;
            m[2] =     2 * (xz - yw); m[6] =     2 * (yz + xw); m[10] = 1 - 2 * (xx + yy); m[14] = 0;
            m[3] =                 0; m[7] =                 0; m[11] =                 0; m[15] = 1;
            return m;
        },
        fromQuatGLM: function(q) {
            var x = q[0], y = q[1], z = q[2], w = q[3],
                x2 = x + x,
                y2 = y + y,
                z2 = z + z,
    
                xx = x * x2,
                yx = y * x2,
                yy = y * y2,
                zx = z * x2,
                zy = z * y2,
                zz = z * z2,
                wx = w * x2,
                wy = w * y2,
                wz = w * z2;
    
            var out = new Float32Array(16);
            out[0] = 1 - yy - zz;
            out[1] = yx + wz;
            out[2] = zx - wy;
            out[3] = 0;
    
            out[4] = yx - wz;
            out[5] = 1 - xx - zz;
            out[6] = zy + wx;
            out[7] = 0;
    
            out[8] = zx + wy;
            out[9] = zy - wx;
            out[10] = 1 - xx - yy;
            out[11] = 0;
    
            out[12] = 0;
            out[13] = 0;
            out[14] = 0;
            out[15] = 1;
    
            return out;
        }
    };
    
    var quats = [
        [0.28667385732968476, 0.4695627561800271, 0.09028506571766393, 0.6715668351168038],
        [0.2651236299616677, 0.3352433131520407, 0.23935617684737243, 0.10348812500929161],
        [0.002380091963310127, 0.28556139677867076, 0.5177704362031104, 0.31917225466802934],
        [0.8559490413154973, 0.9934662185106788, 0.1708025955882695, 0.3767980410764995],
        [0.09983228063189431, 0.829539443437229, 0.11236207084829108, 0.6833875656880277],
        [0.5657875528667418, 0.7004290732317235, 0.5720529027324792, 0.17027477054342688],
        [0.00010866305239920493, 0.18951173463191484, 0.9635388512417984, 0.16784613237675106],
        [0.43269230780136914, 0.18989169071386836, 0.3820386998898746, 0.3845793978155678],
        [0.24995371521143506, 0.29756469496920035, 0.6977832036715326, 0.6251103749225848],
        [0.6373743198581032, 0.13346268288090868, 0.7021060015911651, 0.5686906559847418],
        [0.42948550530630913, 0.8599292037909345, 0.516879198136017, 0.3547202730238612],
        [0.3534864785574121, 0.33083240173509254, 0.2914021372654776, 0.9194039888247587],
        [0.6285279991330446, 0.13070831475743372, 0.9658516407364588, 0.9860634955854315],
        [0.5204649545942466, 0.38381482856360893, 0.05142379356253923, 0.5931324901474515],
        [0.07531672900216613, 0.9021857878379353, 0.4092683406763107, 0.3521779725904437],
        [0.7014660569947004, 0.8119539533215514, 0.43696242700175403, 0.04899616263737494],
        [0.9289906854447096, 0.08996025442855671, 0.7875344292843567, 0.03415147099157578],
        [0.5118848978252626, 0.8031482286609193, 0.09583849926710397, 0.10219779007893348],
        [0.31744261852667743, 0.48898378035273926, 0.35958149292788577, 0.9004223374838385],
        [0.31593414995469193, 0.04691500923460157, 0.2252736707929106, 0.7133595249121447],
        [0.22443863603070913, 0.9310593108584775, 0.21226019799470963, 0.8315928517998981],
        [0.48711250766482506, 0.4947413386148647, 0.7641090451417427, 0.7268992100994618],
        [0.2847051984990572, 0.18705843432758318, 0.614353616295632, 0.04441531016475908],
        [0.20526455035026947, 0.30009202992784667, 0.9342812486283747, 0.2609376468219078],
        [0.451482342318807, 0.5391579452717814, 0.22187997265477155, 0.32989845009387286],
        [0.8936769847108745, 0.38717750323108846, 0.5275960180137027, 0.8090404625372274],
        [0.379369025476777, 0.07429784084149538, 0.18329971667318024, 0.5233650628290183],
        [0.6795279582300646, 0.1381483066944078, 0.2770972796093889, 0.5345339041208603],
        [0.21838116395615836, 0.4871869913236695, 0.7631664893254175, 0.29444908599973374],
        [0.2739811854906382, 0.8155863079619736, 0.7762331074515498, 0.2564909683605341],
        [0.5464767152377707, 0.385159229434358, 0.8310414576821084, 0.7166542824237923],
        [0.8210319451521648, 0.34465191470887446, 0.4452471636831081, 0.13331259433311815],
        [0.596172612573282, 0.6243660645258371, 0.15037061240822003, 0.8747719345879845],
        [0.49112197848778383, 0.503921884515536, 0.9644291478052724, 0.017316403762208],
        [0.1738737654051732, 0.5670423976144741, 0.08659296391546256, 0.03631192426432861],
        [0.06262551300033836, 0.07010413164654827, 0.2336469112244537, 0.16724598445110073],
        [0.811422929813884, 0.8349897048458801, 0.9145952917521003, 0.26239346177864364],
        [0.6630403599564261, 0.35317099689193787, 0.8027273513615203, 0.5803018039406345],
        [0.1757431759081889, 0.3507169191905668, 0.6105343485302794, 0.9243469954405543],
        [0.3327192772323335, 0.9325407166345281, 0.47143317745214053, 0.7623110696019169],
        [0.1761835366817237, 0.19347432368153927, 0.7206931938985313, 0.06373877012860119],
        [0.7448629845505879, 0.9060597128682091, 0.6483915429127347, 0.43602768214863996],
        [0.22526999649654234, 0.654494121383776, 0.3956191493640093, 0.8547340808445887],
        [0.1497425525905356, 0.6886505831339009, 0.09953326720883382, 0.6170557848208393],
        [0.3269691700903268, 0.1728553127205561, 0.36233013399467007, 0.6108827976664737],
        [0.3454364745648453, 0.8193827532498554, 0.36431562391691874, 0.02927035374366893],
        [0.8799073354665614, 0.8058528942974545, 0.01650076349707197, 0.8296909570916355],
        [0.04933980275395422, 0.7348046876829648, 0.9837937592327617, 0.5550349591972974],
        [0.10234802723849468, 0.8593564991221694, 0.5113221105157657, 0.9894171565701668],
        [0.5925673136728724, 0.15666598568830414, 0.1019331817685789, 0.307753155238484],
        [0.6517539099060352, 0.46198533776106476, 0.004978322573423233, 0.6326162773745858],
        [0.46995492843470865, 0.3333469039993653, 0.869156360409266, 0.2650441810533861],
        [0.565918462782592, 0.4581839713732756, 0.7432233245804771, 0.05518397377013429],
        [0.26615368534808437, 0.2194693079766974, 0.136312300630542, 0.33446245347806336],
        [0.8761697625101192, 0.21988100464207672, 0.9825023846297076, 0.9809547299321255],
        [0.5957885199056787, 0.3122752685701453, 0.13085311075410644, 0.6350017715773832],
        [0.22740409187079225, 0.23347161675464756, 0.2681422541867109, 0.9304096243007987],
        [0.573966849368859, 0.8413250365922318, 0.4152768676328018, 0.680898559110134],
        [0.44653736717433934, 0.9979343251461044, 0.33359494355594177, 0.21924262088391],
        [0.13582482578575572, 0.8400221987477128, 0.19372052131519735, 0.283091031986235],
        [0.059875127547221796, 0.03164645829352786, 0.8378437893894644, 0.28181260643711004],
        [0.6137045832764998, 0.35660745681037875, 0.7416201811057221, 0.28729696407068617],
        [0.5091202430305206, 0.5334306387922261, 0.2751463344480265, 0.5035010234565933],
        [0.27689528143897024, 0.46566864179512635, 0.318154677684368, 0.15246592054905572],
        [0.7635840223994299, 0.47461678152921505, 0.6478020160575964, 0.625972580154285],
        [0.19214395771429982, 0.7219182748234585, 0.971661268809324, 0.21923851821341156],
        [0.6929809392268698, 0.9953404032587705, 0.6224696267841732, 0.12516325845907583],
        [0.004522264121473052, 0.6197117867384869, 0.680787199527144, 0.6831867262179412],
        [0.2808063885930321, 0.7869676123894036, 0.39060933908806894, 0.8715179244604554],
        [0.8210544824187092, 0.06716738971144975, 0.1804248372374706, 0.5509682243816845],
        [0.6257781700257348, 0.8957411866929248, 0.5731879050079507, 0.1329316394752056],
        [0.15788810363581685, 0.8799370950543823, 0.3941977993482251, 0.49396922798063336],
        [0.3554508404664265, 0.9541054193266156, 0.4343526704232319, 0.9285601891522282],
        [0.8235933541799219, 0.07359819922059763, 0.8712360127621397, 0.4260334512987196],
        [0.8971781319183232, 0.13770308325314184, 0.4677548676323737, 0.5236879388666908],
        [0.10820674219444282, 0.1971145974291526, 0.2924082494229938, 0.01697044474616538],
        [0.6334537380875278, 0.7241545477168163, 0.6734635151786799, 0.22889224200953495],
        [0.5183212709360256, 0.9863766639445266, 0.5512352181977425, 0.9356602999313495],
        [0.05231292082853045, 0.4144613405309452, 0.26866147258050566, 0.7754638859875818],
        [0.4968293856026764, 0.1724477467886829, 0.8418557719322943, 0.858659291017603],
        [0.32717337464384366, 0.3533755372869627, 0.6397145521183494, 0.2284117110639745],
        [0.15382332260472031, 0.7013898206577873, 0.34276756863329116, 0.5355229860440793],
        [0.04441442588211286, 0.582750548213917, 0.8951149310495512, 0.6206465646471295],
        [0.16088276583720407, 0.762499521384203, 0.7110834074948384, 0.9907080011357603],
        [0.22079444601934584, 0.3131014072533913, 0.7595965483733602, 0.6191702204699028],
        [0.4851141719475689, 0.5450328976995951, 0.5023366741437734, 0.9394907997644997],
        [0.3213019831116133, 0.8183320400974194, 0.6822701049785296, 0.10511853329999776],
        [0.06998341082698789, 0.19968947882301835, 0.7241629935662803, 0.6123816245868936],
        [0.10174229985843497, 0.15532738526271372, 0.035552855756835866, 0.057295670262505816],
        [0.8470924016428083, 0.5197576563474231, 0.3935029193311501, 0.6819223263837924],
        [0.0891069262349351, 0.5887563449687969, 0.7723667962002954, 0.2191605608169811],
        [0.7964325363482141, 0.3820789695752633, 0.7973018972136354, 0.22287333921395436],
        [0.49240755567900196, 0.8885691633886943, 0.8647890662759572, 0.5241717648661399],
        [0.9176996103445059, 0.6128869778990567, 0.23415392073385877, 0.20904331189752523],
        [0.3866187537089252, 0.14070416543622577, 0.9625767275702548, 0.2328091465696298],
        [0.8291122233933506, 0.7626645742819809, 0.4466308919167783, 0.5583192567928092],
        [0.955157790580152, 0.049708681552077305, 0.8692635548748922, 0.6332541895862409],
        [0.8929106139737326, 0.48006806842915317, 0.755341046492972, 0.3183044180994352],
        [0.5918807952168674, 0.1257242084050656, 0.7995723787489055, 0.44984677550921237],
        [0.5530361091216869, 0.34598812653118416, 0.5963955868667188, 0.5333258862628545],
        [0.4910238333064927, 0.36269398347808934, 0.47144837837493303, 0.29354605755130203],
        [0.2883403825317261, 0.953531382178946, 0.485727706688303, 0.2546637485975509],
        [0.9311879107631806, 0.8728179849378577, 0.3134335696665491, 0.2892679730454806],
        [0.8655100631075441, 0.1658782530676337, 0.7189514884809478, 0.337738370214673],
        [0.12758289222687513, 0.42872555891405995, 0.13200835380459375, 0.4364744726845087],
        [0.7953022120536053, 0.19813772057398382, 0.0064724077790550005, 0.4631528075393483],
        [0.5801479964474237, 0.18403530850430982, 0.2267950908546632, 0.03476452941749897],
        [0.1866873976485155, 0.2489825839855615, 0.4270890521531656, 0.46207234661790664],
        [0.24966343223558596, 0.08656432665856673, 0.20625095809369087, 0.3369022735666902],
        [0.34077375180728553, 0.22765663770178035, 0.011476146039079982, 0.9998983960450649],
        [0.851563586490012, 0.6061397217540072, 0.9356015432573304, 0.7098682662773717],
        [0.2796577598447756, 0.9034184564714831, 0.6129713016010241, 0.2549258099376128],
        [0.28134725902105084, 0.2569338330390707, 0.3464502243133061, 0.3397220675802466],
        [0.009087322806848652, 0.6542224911370589, 0.7292862132996196, 0.13294005703800194],
        [0.06332496716500624, 0.584335652036593, 0.7368757502697509, 0.8793384701387321],
        [0.05871562171676481, 0.3623858378148126, 0.5850483515801899, 0.5280660161953179],
        [0.9396107221096133, 0.052009895568242426, 0.46901352480696334, 0.5002025317369199],
        [0.7072074782669271, 0.09681128264885075, 0.9951321378328568, 0.3986564263907504],
        [0.16722457625875253, 0.26158755927489574, 0.2674768198737838, 0.9167281283039481],
        [0.30798484938703985, 0.012919856579447053, 0.47871294391660557, 0.6416458082234289],
        [0.30554259648820814, 0.8974633382685584, 0.17374593958160833, 0.6172121475423193],
        [0.49091374292714995, 0.435582345746925, 0.6729590117010167, 0.4116437628389962],
        [0.4901006501343641, 0.5801140650918399, 0.9354665528017838, 0.5699836358565862],
        [0.21442370640844466, 0.14716547913757227, 0.18483200648100695, 0.9119908332223312],
        [0.6411497478062373, 0.8165182845599899, 0.7446114815208522, 0.6589356416297363],
        [0.9047454582102494, 0.833363570817574, 0.21841107343564636, 0.8449044774471963],
        [0.19045227006161514, 0.8485055544084514, 0.47880012910365854, 0.6903065380420514],
        [0.01211794504382957, 0.3975870420908032, 0.741082713380145, 0.04665050397816195],
        [0.9685523158620923, 0.9856972619844659, 0.6714859350750249, 0.3795506266761661],
        [0.2989551601561147, 0.8140954512378225, 0.7123707431311654, 0.03563150051658592],
        [0.7715001899888096, 0.39895646508887994, 0.840309049874987, 0.7996322362085666],
        [0.2360673371507782, 0.341692578053568, 0.6985954872472102, 0.31443929897243206],
        [0.8762018967785754, 0.7339011546551413, 0.1895347663963649, 0.36034266422334427],
        [0.3091006427139811, 0.3749757323207412, 0.7847826238136086, 0.8841450794639523],
        [0.9769191009095779, 0.4254547008671197, 0.49893547035213626, 0.6329091154275079],
        [0.7965451882446406, 0.507785480575154, 0.0544641819777163, 0.7487432602855455],
        [0.9288713075482016, 0.09762183623237597, 0.37962170669020434, 0.8197681246917374],
        [0.9414075002025897, 0.1873498940210303, 0.06788177174144283, 0.2368627067766711],
        [0.03186924552536374, 0.12580067419317031, 0.9481431100229842, 0.7609988660472464],
        [0.3854346805697808, 0.011632965060166311, 0.19724839392529692, 0.29498106997843077],
        [0.4481823848523221, 0.2997564336288534, 0.6155218766969408, 0.5776937266107864],
        [0.2842519685972482, 0.13398092117348748, 0.8629071737784724, 0.6593533822803903],
        [0.5559894349145276, 0.6167076429456249, 0.9538610437979151, 0.05715963602134155],
        [0.6563138443526018, 0.2606705019456961, 0.5047276167966837, 0.7670736901910089],
        [0.2717369757818424, 0.5975921544311527, 0.41740991387781357, 0.039392677617891225],
        [0.6827452849310289, 0.7203843477032512, 0.42634155303091914, 0.4097735528593409],
        [0.7814677590375414, 0.6682862285105025, 0.5515642885907228, 0.2846269108187913],
        [0.09692950197422356, 0.572498765904935, 0.9131422548386428, 0.14120185906218752],
        [0.03711462692502887, 0.3430887972494783, 0.4944508869795228, 0.3295949310594979],
        [0.8634195272887932, 0.6219188199780545, 0.6844738801650669, 0.12722015869535497],
        [0.8045597561655022, 0.48765719771694527, 0.9270802410349421, 0.5483938286609604],
        [0.8786585021563373, 0.18597136804001457, 0.46625086500024926, 0.45088694516395567],
        [0.915320762866265, 0.4420305526359416, 0.9254247514175904, 0.7402948474658229],
        [0.7971947207180619, 0.0913622472766018, 0.7836942091770382, 0.6830205923654153],
        [0.4386887042581791, 0.4700050064646957, 0.7170156597544024, 0.7615826728045123],
        [0.1009469616452443, 0.3058452918455683, 0.9622770254869222, 0.23717458224291432],
        [0.17124183104375246, 0.30896319487782553, 0.9524758835401419, 0.44875574965244835],
        [0.5626989398902904, 0.6853811826242455, 0.03802799762167752, 0.2100159931886414],
        [0.2208366772381991, 0.03432524176069296, 0.9817460656108368, 0.30527512835985626],
        [0.34199774485942225, 0.7712985594312238, 0.33082650999369756, 0.46012747786797314],
        [0.5485538937311245, 0.07747673923988319, 0.6424051644833066, 0.2141414452603152],
        [0.6656459694281927, 0.7523134602496666, 0.06005019493605679, 0.46537767212051984],
        [0.3286899281814455, 0.29019262373009536, 0.4879997405442589, 0.4594040837743487],
        [0.6457574835577273, 0.3103547845797048, 0.5489947329040432, 0.21717693212325773],
        [0.31088437224672893, 0.05127318447733997, 0.9993387184940603, 0.8192426129318648],
        [0.13882813621122692, 0.6814175140938643, 0.9023393791760352, 0.4853731077132102],
        [0.4590131188049038, 0.19471558521005372, 0.47692951358352675, 0.16028548443787805],
        [0.6182399936055263, 0.06892795999953427, 0.7777517169824366, 0.5996014011052602],
        [0.5409993197585685, 0.5437791900049089, 0.09728347742329957, 0.09437829524921204],
        [0.15600381917572004, 0.3438989257575762, 0.07981835285890804, 0.3973996129759958],
        [0.7338639899975345, 0.4820130028835439, 0.6598640785478334, 0.8127012815217483],
        [0.9701335205552701, 0.029014364937398618, 0.6867011057684504, 0.4260486786096136],
        [0.07994513503326917, 0.9549523206339148, 0.9212850243269375, 0.610055709057399],
        [0.10160676920406697, 0.6788117981980535, 0.12470979139423255, 0.5511024155483],
        [0.5646314765487266, 0.31567362749645245, 0.8717194327417583, 0.34329726941345795],
        [0.47568905489809366, 0.06825267349077047, 0.3592787085599891, 0.7722399075702449],
        [0.4478557092651967, 0.04659466683045288, 0.4717661280277734, 0.44347226563754516],
        [0.877183341241798, 0.8932136902029904, 0.4684572744963986, 0.3566950747000506],
        [0.1348704391325981, 0.8612855851931134, 0.4150546241239086, 0.927269621929423],
        [0.43442081691205003, 0.08301228580144682, 0.07683178052282691, 0.48385268401747816],
        [0.307554254930825, 0.7533401778680249, 0.2412250260416049, 0.48629796519844026],
        [0.4893346744702505, 0.24596127768762943, 0.8923525656677667, 0.9921901729642624],
        [0.49477370225992745, 0.4047563244237755, 0.40960949854652484, 0.3015559053084522],
        [0.13392654419157024, 0.9025776560470358, 0.01747938730256382, 0.795305511942626],
        [0.6449284404405919, 0.5616225252186764, 0.6478116811441128, 0.3982676662837459],
        [0.07339856748493001, 0.39476195312877516, 0.4105993717686567, 0.0425806068487764],
        [0.5354220985831335, 0.2650075746260412, 0.19384265749470964, 0.2913343159347841],
        [0.4388593858862171, 0.8572935700055999, 0.123982394705618, 0.07491435522397083],
        [0.265194257144578, 0.5335055701151044, 0.6524929608574261, 0.8484432997875464],
        [0.7828680777266233, 0.00241230098243439, 0.6240697613310402, 0.7020722535978319],
        [0.8546240757615138, 0.01816066747541445, 0.9351820016937373, 0.21112273328286713],
        [0.40832798028047557, 0.674415050459003, 0.48614445518893357, 0.4167601350876593],
        [0.03681887678851559, 0.5497005190303266, 0.32594016682068205, 0.29790419669236545],
        [0.3385319253749126, 0.27744564196847943, 0.9255037308056941, 0.9837203830608432],
        [0.15355812452797024, 0.8962704835177568, 0.06570754340104434, 0.30094717522322334],
        [0.28475415050173014, 0.5393350773284817, 0.04649368291324074, 0.5613027723088042],
        [0.9478722143727873, 0.9750280938834379, 0.4467296076720684, 0.8917316707785294],
        [0.15209771321760157, 0.18903694413505434, 0.5543251582330053, 0.45576846791872816],
        [0.1558980025404575, 0.9666547484728794, 0.6185611856594633, 0.24879606584833236],
        [0.2638326748413393, 0.5943888327819611, 0.7398670206736515, 0.10153950188076166],
        [0.05746307834540754, 0.10505114297724627, 0.29687115559328126, 0.11683785280243764],
        [0.05055794361363097, 0.31313927460030566, 0.3035063157543618, 0.05622064904802104],
        [0.7337207822096006, 0.28921537211992, 0.7188540953380707, 0.3535827457093763],
        [0.6123979070528458, 0.4385225866531117, 0.191186112645773, 0.23745602308491143],
        [0.8265163588150195, 0.42525764940440425, 0.1534360093415299, 0.8324431314899454],
        [0.5168965872035467, 0.1553680420519028, 0.37934407550405047, 0.007575417783621363],
        [0.04163963879637089, 0.7757841678148796, 0.26103896331689436, 0.2762731051295051],
        [0.612381396288489, 0.2948976737475011, 0.15767819855285792, 0.14968505758171924],
        [0.6267277738792159, 0.7582817317521644, 0.10871029137490096, 0.5530749200683389],
        [0.947231115841348, 0.28906680614140967, 0.44048238804652184, 0.21291945267212498],
        [0.29961440541416984, 0.8837482116796929, 0.7682394627102713, 0.45900626136797285],
        [0.5194984755097609, 0.7354492168639293, 0.787847748778945, 0.5441423054612091],
        [0.13922457020170986, 0.9701489670296413, 0.19154529103197326, 0.786478106428151],
        [0.7484806055416069, 0.33513076687366095, 0.2530991616948235, 0.48669146313090605],
        [0.3747671706845457, 0.6363702142432277, 0.18759239621288115, 0.22819721363616763],
        [0.8235934707334811, 0.0032884426059092142, 0.3253036580360542, 0.2139181305392288],
        [0.9911253847764951, 0.5117167545352417, 0.08856968958752454, 0.6577156884011599],
        [0.8692318941608888, 0.23017852192972277, 0.6748028790238008, 0.8640016227665555],
        [0.834246355046375, 0.26839557235386136, 0.3869240381084773, 0.4897302245459929],
        [0.8823610801632933, 0.67332343977154, 0.24421097532191793, 0.9253965765466154],
        [0.6440459532229867, 0.7345604927917342, 0.45949424775519243, 0.5805674921433213],
        [0.11269712752945438, 0.456304004086884, 0.8025049510758964, 0.14103969013450723],
        [0.9009212779791003, 0.716197840244694, 0.34843676034732685, 0.22663230877502527],
        [0.8141803817755857, 0.8971994869765756, 0.9786741579152767, 0.10298705713334932],
        [0.7338566324661415, 0.34767427933132256, 0.1439387267282004, 0.9540717791006725],
        [0.6053772343664201, 0.007839366943807269, 0.510009036647884, 0.1841121255870508],
        [0.7760415809553449, 0.11131792192352874, 0.7527968127040348, 0.3797350847615597],
        [0.625736475936082, 0.5532820161874068, 0.9722420059654959, 0.8256206005195752],
        [0.4325088649783857, 0.17020613559606157, 0.08851180635967815, 0.1782731719491195],
        [0.15511988907087582, 0.14085545117039389, 0.18416336997059224, 0.6896623185268673],
        [0.9691867105493766, 0.4423465319792941, 0.3917267430380207, 0.12289783829797396],
        [0.5079895220841621, 0.11015411853212287, 0.01908225361378646, 0.4423047768494677],
        [0.09230714318970157, 0.8838868459157301, 0.6994637471223224, 0.7836635519138162],
        [0.7920247189650689, 0.6071967932009945, 0.3753791373900024, 0.6490057544932903],
        [0.8974833059810652, 0.5268423281227352, 0.0995311194229509, 0.13249498098306778],
        [0.7444797982855593, 0.6867250089498371, 0.0873508425587497, 0.26174330224235365],
        [0.2663553829269685, 0.7655778842043681, 0.6023315674209895, 0.93491352705713],
        [0.6387067531008197, 0.12883715991129807, 0.5937839546235337, 0.7966986103684375],
        [0.36022938967151497, 0.17071075147913972, 0.17512769800754246, 0.8477856086040549],
        [0.4556953276671598, 0.03333146205430637, 0.6330272013168359, 0.30558350963646697],
        [0.3037986022863888, 0.7627068452289592, 0.2553400619081365, 0.07338266925312698],
        [0.3193480374923727, 0.02645095950050358, 0.7832939572004816, 0.6254845410969687],
        [0.8376408804868551, 0.3518098753011645, 0.22521468782103793, 0.8877588402289232],
        [0.616038315197293, 0.5966060032784317, 0.5942344220929852, 0.2943280061048099],
        [0.8004972290650461, 0.29875096996135464, 0.44281846930159907, 0.07120750516872643],
        [0.2274168196792843, 0.6331241690658493, 0.7782949373220951, 0.04797507493329878],
        [0.9133115277729551, 0.10048902993388675, 0.7238129981692387, 0.26944984594813315],
        [0.3074112815861223, 0.6637905397219577, 0.7913967904962338, 0.03531430909081279],
        [0.29727415801689894, 0.19360733366596516, 0.3432554695059722, 0.5263088403204981],
        [0.8616339814753722, 0.2129988546811432, 0.37956417148114796, 0.3894194413445342],
        [0.6528965945809992, 0.18782222430428175, 0.5547299345369512, 0.5078981038970389],
        [0.5879376382196329, 0.6572022875532615, 0.15880679972754996, 0.3628240488756682],
        [0.8840666619945632, 0.615945567217389, 0.013814296915753532, 0.5808121934728214],
        [0.6024185449749904, 0.36407999250599055, 0.8679980764242146, 0.04000968281375439],
        [0.53467616011092, 0.4664273360887288, 0.18629464411993446, 0.30574938933078877],
        [0.05531536968200301, 0.5129910418278905, 0.938681424122922, 0.83755868287787],
        [0.38326172074130316, 0.12072594889741528, 0.5684147351086868, 0.8674056419634537],
        [0.7703380002873461, 0.6809914906022667, 0.717752198710963, 0.23121671247621345],
        [0.8479798087214958, 0.22668223357355255, 0.8519254312221218, 0.8307396109631138],
        [0.8477164052708253, 0.9180589754387505, 0.24580024699050562, 0.9522679330957129],
        [0.7726004230664629, 0.1291433788081935, 0.657019400918941, 0.9960734204313153],
        [0.6258602999217553, 0.3919630328040924, 0.15268187314815163, 0.8101132002836022],
        [0.18966002617886102, 0.6380035011361007, 0.6776509606786476, 0.8243688167387477],
        [0.8523065829747545, 0.25819519239583033, 0.243372142504388, 0.35931248548239814],
        [0.7297254338202805, 0.8152017644815883, 0.6053144338849743, 0.47163026866518787],
        [0.051819705358636226, 0.5241929518703696, 0.7268759897366932, 0.17734396284078335],
        [0.8842614530992279, 0.8888853543978681, 0.6424253122049186, 0.5554983248397898],
        [0.5771044726711785, 0.40934996356227127, 0.6835990050097085, 0.4978071722382913],
        [0.328031599487588, 0.2144520465894768, 0.836550113462182, 0.11671298626972892],
        [0.1916577614448367, 0.5647384496834751, 0.2852655593116009, 0.4586065649802904],
        [0.6788242427782729, 0.9463274121634371, 0.3485140271079932, 0.6430685050788805],
        [0.43615258985858363, 0.1271518837893233, 0.3995820951342206, 0.07636799800890604],
        [0.15313010388673431, 0.5247558739543252, 0.10160915411064675, 0.8537004942886888],
        [0.13790102365087487, 0.7150404804098573, 0.4419075370645964, 0.5485172494899078],
        [0.12083161989209468, 0.12342067709124582, 0.8224445519675456, 0.5147045041087777],
        [0.6470922262042227, 0.16586847923417758, 0.8668085672778705, 0.6815463305803502],
        [0.20307630040429392, 0.15504406495030487, 0.3704713196639704, 0.20629381869036223],
        [0.12069645691607467, 0.3035399126316447, 0.990113415415351, 0.18155783421088234],
        [0.744127281091244, 0.8312062289874405, 0.09575510238013552, 0.07051741344767049],
        [0.08234509233102827, 0.06461111736802194, 0.24221691447912175, 0.8453545987945108],
        [0.03930740876195138, 0.43000660197559704, 0.3405411613103013, 0.8562548093271902],
        [0.7270214622601683, 0.3284944377369474, 0.7622899091401183, 0.2282821786747422],
        [0.7335446170546918, 0.3552918544083441, 0.322110719299753, 0.8829053594372005],
        [0.22228152428230263, 0.9596441212475109, 0.29874604095785884, 0.849936187856039],
        [0.7451449913232406, 0.2928550354650796, 0.823593166137438, 0.8213601520675797],
        [0.29474023920646153, 0.26245019480403253, 0.1633069472848092, 0.8732137709861272],
        [0.25809603086676747, 0.7724568957064084, 0.3509996761518792, 0.055512483811333446],
        [0.11713858297015478, 0.41364521939508503, 0.23145196416922698, 0.29226744363683776],
        [0.6755092595213561, 0.6104849301638415, 0.3744979890508926, 0.0002826765325538716],
        [0.0996444863193584, 0.0449486881953447, 0.09921609018539623, 0.33661601179780476],
        [0.39034186524077086, 0.17553891043329206, 0.1704869378990963, 0.8996115446982851],
        [0.5732476540872982, 0.9742912730790665, 0.08961645644770999, 0.2622345268135826],
        [0.19206094602377188, 0.7255193998287162, 0.04030388473905533, 0.14504505410735402],
        [0.6074451829384488, 0.9269527849060009, 0.21561196228895785, 0.9909398388723085],
        [0.5653381621252045, 0.3127506685693846, 0.19805124271697339, 0.6448835267605686],
        [0.8722334281473885, 0.2370377733003295, 0.15621432238292798, 0.33979610552155237],
        [0.35910966465502847, 0.3746524655599408, 0.8348140923427017, 0.8848705839998103],
        [0.6087682789643776, 0.19851753455691745, 0.3372484725356324, 0.4397493959451704],
        [0.7041447783817267, 0.6370213473946427, 0.4658299109408599, 0.4587036818718335],
        [0.7083833411881943, 0.2947025254429798, 0.5916785007660301, 0.10459853164967159]
    ];
    
    var mat;
    for(var i = 0; i < 300; ++i) {
        // mat = mat4.fromQuat(quats[i]);
        mat = mat4.fromQuatGLM(quats[i]);
    }