index.html 278 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="generator" content="Asciidoctor 1.5.8">
  8. <meta name="keywords" content="c++, boost, matrix, vector, quaternion">
  9. <meta name="author" content="Generic C&#43;&#43; library for working with Quaternions Vectors and Matrices">
  10. <title>QVM</title>
  11. <style>
  12. /* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
  13. /* Uncomment @import statement below to use as custom stylesheet */
  14. /*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/
  15. /* Zajo's custom font import. The rest of the customizations are at the bottom of this css file, which is otherwise kept unchanged */
  16. @import "https://fonts.googleapis.com/css?family=Anonymous+Pro|Istok+Web|Quicksand|Press+Start+2P";
  17. article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
  18. audio,canvas,video{display:inline-block}
  19. audio:not([controls]){display:none;height:0}
  20. script{display:none!important}
  21. html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
  22. a{background:transparent}
  23. a:focus{outline:thin dotted}
  24. a:active,a:hover{outline:0}
  25. h1{font-size:2em;margin:.67em 0}
  26. abbr[title]{border-bottom:1px dotted}
  27. b,strong{font-weight:bold}
  28. dfn{font-style:italic}
  29. hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
  30. mark{background:#ff0;color:#000}
  31. code,kbd,pre,samp{font-family:monospace;font-size:1em}
  32. pre{white-space:pre-wrap}
  33. q{quotes:"\201C" "\201D" "\2018" "\2019"}
  34. small{font-size:80%}
  35. sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
  36. sup{top:-.5em}
  37. sub{bottom:-.25em}
  38. img{border:0}
  39. svg:not(:root){overflow:hidden}
  40. figure{margin:0}
  41. fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
  42. legend{border:0;padding:0}
  43. button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
  44. button,input{line-height:normal}
  45. button,select{text-transform:none}
  46. button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
  47. button[disabled],html input[disabled]{cursor:default}
  48. input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
  49. button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
  50. textarea{overflow:auto;vertical-align:top}
  51. table{border-collapse:collapse;border-spacing:0}
  52. *,*::before,*::after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
  53. html,body{font-size:100%}
  54. body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
  55. a:hover{cursor:pointer}
  56. img,object,embed{max-width:100%;height:auto}
  57. object,embed{height:100%}
  58. img{-ms-interpolation-mode:bicubic}
  59. .left{float:left!important}
  60. .right{float:right!important}
  61. .text-left{text-align:left!important}
  62. .text-right{text-align:right!important}
  63. .text-center{text-align:center!important}
  64. .text-justify{text-align:justify!important}
  65. .hide{display:none}
  66. img,object,svg{display:inline-block;vertical-align:middle}
  67. textarea{height:auto;min-height:50px}
  68. select{width:100%}
  69. .center{margin-left:auto;margin-right:auto}
  70. .stretch{width:100%}
  71. .subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
  72. div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
  73. a{color:#2156a5;text-decoration:underline;line-height:inherit}
  74. a:hover,a:focus{color:#1d4b8f}
  75. a img{border:none}
  76. p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
  77. p aside{font-size:.875em;line-height:1.35;font-style:italic}
  78. h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
  79. h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
  80. h1{font-size:2.125em}
  81. h2{font-size:1.6875em}
  82. h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
  83. h4,h5{font-size:1.125em}
  84. h6{font-size:1em}
  85. hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
  86. em,i{font-style:italic;line-height:inherit}
  87. strong,b{font-weight:bold;line-height:inherit}
  88. small{font-size:60%;line-height:inherit}
  89. code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
  90. ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
  91. ul,ol{margin-left:1.5em}
  92. ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
  93. ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
  94. ul.square{list-style-type:square}
  95. ul.circle{list-style-type:circle}
  96. ul.disc{list-style-type:disc}
  97. ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
  98. dl dt{margin-bottom:.3125em;font-weight:bold}
  99. dl dd{margin-bottom:1.25em}
  100. abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
  101. abbr{text-transform:none}
  102. blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
  103. blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
  104. blockquote cite::before{content:"\2014 \0020"}
  105. blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
  106. blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
  107. @media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
  108. h1{font-size:2.75em}
  109. h2{font-size:2.3125em}
  110. h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
  111. h4{font-size:1.4375em}}
  112. table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
  113. table thead,table tfoot{background:#f7f8f7}
  114. table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
  115. table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
  116. table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
  117. table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
  118. h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
  119. h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
  120. .clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
  121. .clearfix::after,.float-group::after{clear:both}
  122. *:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
  123. *:not(pre)>code.nobreak{word-wrap:normal}
  124. *:not(pre)>code.nowrap{white-space:nowrap}
  125. pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
  126. em em{font-style:normal}
  127. strong strong{font-weight:400}
  128. .keyseq{color:rgba(51,51,51,.8)}
  129. kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
  130. .keyseq kbd:first-child{margin-left:0}
  131. .keyseq kbd:last-child{margin-right:0}
  132. .menuseq,.menuref{color:#000}
  133. .menuseq b:not(.caret),.menuref{font-weight:inherit}
  134. .menuseq{word-spacing:-.02em}
  135. .menuseq b.caret{font-size:1.25em;line-height:.8}
  136. .menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
  137. b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
  138. b.button::before{content:"[";padding:0 3px 0 2px}
  139. b.button::after{content:"]";padding:0 2px 0 3px}
  140. p a>code:hover{color:rgba(0,0,0,.9)}
  141. #header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
  142. #header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
  143. #header::after,#content::after,#footnotes::after,#footer::after{clear:both}
  144. #content{margin-top:1.25em}
  145. #content::before{content:none}
  146. #header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
  147. #header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
  148. #header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
  149. #header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
  150. #header .details span:first-child{margin-left:-.125em}
  151. #header .details span.email a{color:rgba(0,0,0,.85)}
  152. #header .details br{display:none}
  153. #header .details br+span::before{content:"\00a0\2013\00a0"}
  154. #header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
  155. #header .details br+span#revremark::before{content:"\00a0|\00a0"}
  156. #header #revnumber{text-transform:capitalize}
  157. #header #revnumber::after{content:"\00a0"}
  158. #content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
  159. #toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
  160. #toc>ul{margin-left:.125em}
  161. #toc ul.sectlevel0>li>a{font-style:italic}
  162. #toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
  163. #toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
  164. #toc li{line-height:1.3334;margin-top:.3334em}
  165. #toc a{text-decoration:none}
  166. #toc a:active{text-decoration:underline}
  167. #toctitle{color:#7a2518;font-size:1.2em}
  168. @media screen and (min-width:768px){#toctitle{font-size:1.375em}
  169. body.toc2{padding-left:15em;padding-right:0}
  170. #toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
  171. #toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
  172. #toc.toc2>ul{font-size:.9em;margin-bottom:0}
  173. #toc.toc2 ul ul{margin-left:0;padding-left:1em}
  174. #toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
  175. body.toc2.toc-right{padding-left:0;padding-right:15em}
  176. body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
  177. @media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
  178. #toc.toc2{width:20em}
  179. #toc.toc2 #toctitle{font-size:1.375em}
  180. #toc.toc2>ul{font-size:.95em}
  181. #toc.toc2 ul ul{padding-left:1.25em}
  182. body.toc2.toc-right{padding-left:0;padding-right:20em}}
  183. #content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
  184. #content #toc>:first-child{margin-top:0}
  185. #content #toc>:last-child{margin-bottom:0}
  186. #footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
  187. #footer-text{color:rgba(255,255,255,.8);line-height:1.44}
  188. #content{margin-bottom:.625em}
  189. .sect1{padding-bottom:.625em}
  190. @media screen and (min-width:768px){#content{margin-bottom:1.25em}
  191. .sect1{padding-bottom:1.25em}}
  192. .sect1:last-child{padding-bottom:0}
  193. .sect1+.sect1{border-top:1px solid #e7e7e9}
  194. #content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
  195. #content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
  196. #content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
  197. #content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
  198. #content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
  199. .audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
  200. .admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
  201. table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
  202. .paragraph.lead>p,#preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
  203. table.tableblock #preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:inherit}
  204. .admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
  205. .admonitionblock>table td.icon{text-align:center;width:80px}
  206. .admonitionblock>table td.icon img{max-width:none}
  207. .admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
  208. .admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6)}
  209. .admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
  210. .exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
  211. .exampleblock>.content>:first-child{margin-top:0}
  212. .exampleblock>.content>:last-child{margin-bottom:0}
  213. .sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
  214. .sidebarblock>:first-child{margin-top:0}
  215. .sidebarblock>:last-child{margin-bottom:0}
  216. .sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
  217. .exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
  218. .literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
  219. .sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
  220. .literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;overflow-x:auto;padding:1em;font-size:.8125em}
  221. @media screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}
  222. @media screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}
  223. .literalblock pre.nowrap,.literalblock pre.nowrap pre,.listingblock pre.nowrap,.listingblock pre.nowrap pre{white-space:pre;word-wrap:normal}
  224. .literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
  225. .listingblock pre.highlightjs{padding:0}
  226. .listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
  227. .listingblock pre.prettyprint{border-width:0}
  228. .listingblock>.content{position:relative}
  229. .listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
  230. .listingblock:hover code[data-lang]::before{display:block}
  231. .listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:#999}
  232. .listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
  233. table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
  234. table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45}
  235. table.pyhltable td.code{padding-left:.75em;padding-right:0}
  236. pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #dddddf}
  237. pre.pygments .lineno{display:inline-block;margin-right:.25em}
  238. table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
  239. .quoteblock{margin:0 1em 1.25em 1.5em;display:table}
  240. .quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
  241. .quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
  242. .quoteblock blockquote{margin:0;padding:0;border:0}
  243. .quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
  244. .quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
  245. .quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
  246. .verseblock{margin:0 1em 1.25em}
  247. .verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
  248. .verseblock pre strong{font-weight:400}
  249. .verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
  250. .quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
  251. .quoteblock .attribution br,.verseblock .attribution br{display:none}
  252. .quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
  253. .quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
  254. .quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
  255. .quoteblock.abstract{margin:0 1em 1.25em;display:block}
  256. .quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
  257. .quoteblock.excerpt,.quoteblock .quoteblock{margin:0 0 1.25em;padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
  258. .quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
  259. .quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;text-align:left;margin-right:0}
  260. table.tableblock{max-width:100%;border-collapse:separate}
  261. p.tableblock:last-child{margin-bottom:0}
  262. td.tableblock>.content{margin-bottom:-1.25em}
  263. table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
  264. table.grid-all>thead>tr>.tableblock,table.grid-all>tbody>tr>.tableblock{border-width:0 1px 1px 0}
  265. table.grid-all>tfoot>tr>.tableblock{border-width:1px 1px 0 0}
  266. table.grid-cols>*>tr>.tableblock{border-width:0 1px 0 0}
  267. table.grid-rows>thead>tr>.tableblock,table.grid-rows>tbody>tr>.tableblock{border-width:0 0 1px}
  268. table.grid-rows>tfoot>tr>.tableblock{border-width:1px 0 0}
  269. table.grid-all>*>tr>.tableblock:last-child,table.grid-cols>*>tr>.tableblock:last-child{border-right-width:0}
  270. table.grid-all>tbody>tr:last-child>.tableblock,table.grid-all>thead:last-child>tr>.tableblock,table.grid-rows>tbody>tr:last-child>.tableblock,table.grid-rows>thead:last-child>tr>.tableblock{border-bottom-width:0}
  271. table.frame-all{border-width:1px}
  272. table.frame-sides{border-width:0 1px}
  273. table.frame-topbot,table.frame-ends{border-width:1px 0}
  274. table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd){background:#f8f8f7}
  275. table.stripes-none tr,table.stripes-odd tr:nth-of-type(even){background:none}
  276. th.halign-left,td.halign-left{text-align:left}
  277. th.halign-right,td.halign-right{text-align:right}
  278. th.halign-center,td.halign-center{text-align:center}
  279. th.valign-top,td.valign-top{vertical-align:top}
  280. th.valign-bottom,td.valign-bottom{vertical-align:bottom}
  281. th.valign-middle,td.valign-middle{vertical-align:middle}
  282. table thead th,table tfoot th{font-weight:bold}
  283. tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
  284. tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
  285. p.tableblock>code:only-child{background:none;padding:0}
  286. p.tableblock{font-size:1em}
  287. td>div.verse{white-space:pre}
  288. ol{margin-left:1.75em}
  289. ul li ol{margin-left:1.5em}
  290. dl dd{margin-left:1.125em}
  291. dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
  292. ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
  293. ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
  294. ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
  295. ul.unstyled,ol.unstyled{margin-left:0}
  296. ul.checklist{margin-left:.625em}
  297. ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
  298. ul.checklist li>p:first-child>input[type="checkbox"]:first-child{margin-right:.25em}
  299. ul.inline{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
  300. ul.inline>li{margin-left:1.25em}
  301. .unstyled dl dt{font-weight:400;font-style:normal}
  302. ol.arabic{list-style-type:decimal}
  303. ol.decimal{list-style-type:decimal-leading-zero}
  304. ol.loweralpha{list-style-type:lower-alpha}
  305. ol.upperalpha{list-style-type:upper-alpha}
  306. ol.lowerroman{list-style-type:lower-roman}
  307. ol.upperroman{list-style-type:upper-roman}
  308. ol.lowergreek{list-style-type:lower-greek}
  309. .hdlist>table,.colist>table{border:0;background:none}
  310. .hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
  311. td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
  312. td.hdlist1{font-weight:bold;padding-bottom:1.25em}
  313. .literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
  314. .colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
  315. .colist td:not([class]):first-child img{max-width:none}
  316. .colist td:not([class]):last-child{padding:.25em 0}
  317. .thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
  318. .imageblock.left{margin:.25em .625em 1.25em 0}
  319. .imageblock.right{margin:.25em 0 1.25em .625em}
  320. .imageblock>.title{margin-bottom:0}
  321. .imageblock.thumb,.imageblock.th{border-width:6px}
  322. .imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
  323. .image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
  324. .image.left{margin-right:.625em}
  325. .image.right{margin-left:.625em}
  326. a.image{text-decoration:none;display:inline-block}
  327. a.image object{pointer-events:none}
  328. sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
  329. sup.footnote a,sup.footnoteref a{text-decoration:none}
  330. sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
  331. #footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
  332. #footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
  333. #footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
  334. #footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
  335. #footnotes .footnote:last-of-type{margin-bottom:0}
  336. #content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
  337. .gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
  338. .gist .file-data>table td.line-data{width:99%}
  339. div.unbreakable{page-break-inside:avoid}
  340. .big{font-size:larger}
  341. .small{font-size:smaller}
  342. .underline{text-decoration:underline}
  343. .overline{text-decoration:overline}
  344. .line-through{text-decoration:line-through}
  345. .aqua{color:#00bfbf}
  346. .aqua-background{background-color:#00fafa}
  347. .black{color:#000}
  348. .black-background{background-color:#000}
  349. .blue{color:#0000bf}
  350. .blue-background{background-color:#0000fa}
  351. .fuchsia{color:#bf00bf}
  352. .fuchsia-background{background-color:#fa00fa}
  353. .gray{color:#606060}
  354. .gray-background{background-color:#7d7d7d}
  355. .green{color:#006000}
  356. .green-background{background-color:#007d00}
  357. .lime{color:#00bf00}
  358. .lime-background{background-color:#00fa00}
  359. .maroon{color:#600000}
  360. .maroon-background{background-color:#7d0000}
  361. .navy{color:#000060}
  362. .navy-background{background-color:#00007d}
  363. .olive{color:#606000}
  364. .olive-background{background-color:#7d7d00}
  365. .purple{color:#600060}
  366. .purple-background{background-color:#7d007d}
  367. .red{color:#bf0000}
  368. .red-background{background-color:#fa0000}
  369. .silver{color:#909090}
  370. .silver-background{background-color:#bcbcbc}
  371. .teal{color:#006060}
  372. .teal-background{background-color:#007d7d}
  373. .white{color:#bfbfbf}
  374. .white-background{background-color:#fafafa}
  375. .yellow{color:#bfbf00}
  376. .yellow-background{background-color:#fafa00}
  377. span.icon>.fa{cursor:default}
  378. a span.icon>.fa{cursor:inherit}
  379. .admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
  380. .admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
  381. .admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
  382. .admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
  383. .admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
  384. .admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
  385. .conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
  386. .conum[data-value] *{color:#fff!important}
  387. .conum[data-value]+b{display:none}
  388. .conum[data-value]::after{content:attr(data-value)}
  389. pre .conum[data-value]{position:relative;top:-.125em}
  390. b.conum *{color:inherit!important}
  391. .conum:not([data-value]):empty{display:none}
  392. dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
  393. h1,h2,p,td.content,span.alt{letter-spacing:-.01em}
  394. p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
  395. p,blockquote,dt,td.content,span.alt{font-size:1.0625rem}
  396. p{margin-bottom:1.25rem}
  397. .sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
  398. .exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
  399. .print-only{display:none!important}
  400. @page{margin:1.25cm .75cm}
  401. @media print{*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
  402. html{font-size:80%}
  403. a{color:inherit!important;text-decoration:underline!important}
  404. a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
  405. a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
  406. abbr[title]::after{content:" (" attr(title) ")"}
  407. pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
  408. thead{display:table-header-group}
  409. svg{max-width:100%}
  410. p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
  411. h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
  412. #toc,.sidebarblock,.exampleblock>.content{background:none!important}
  413. #toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
  414. body.book #header{text-align:center}
  415. body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
  416. body.book #header .details{border:0!important;display:block;padding:0!important}
  417. body.book #header .details span:first-child{margin-left:0!important}
  418. body.book #header .details br{display:block}
  419. body.book #header .details br+span::before{content:none!important}
  420. body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
  421. body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
  422. .listingblock code[data-lang]::before{display:block}
  423. #footer{padding:0 .9375em}
  424. .hide-on-print{display:none!important}
  425. .print-only{display:block!important}
  426. .hide-for-print{display:none!important}
  427. .show-for-print{display:inherit!important}}
  428. @media print,amzn-kf8{#header>h1:first-child{margin-top:1.25rem}
  429. .sect1{padding:0!important}
  430. .sect1+.sect1{border:0}
  431. #footer{background:none}
  432. #footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
  433. @media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
  434. /* Zajo's customizations applied on top of the standard asciidoctor css above */
  435. h1{font-size:4em}
  436. h2{font-size:1.74em}
  437. h3,#toctitle,.sidebarblock>.content>.title{font-size:1.5em}
  438. h4{font-size:1.2em}
  439. h5{font-size:1em}
  440. h6{font-size:1em}
  441. h1 code{color:#4101a7; font-size:113%}
  442. h2 code{color:#4101a7; font-size:113%}
  443. h3 code{color:#4101a7; font-size:113%}
  444. h4 code{color:#4101a7; font-size:113%}
  445. h5 code{color:#4101a7; font-size:113%}
  446. #toc {text-align:left}
  447. #toc ul code{font-size:111%}
  448. #toc a:hover code {color:#4101a7}
  449. a:focus{outline:0}
  450. body{text-align:left; background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Istok Web","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
  451. .subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#a0a0a0;font-weight:400;margin-top:0;margin-bottom:.25em}
  452. a{color:#000000;text-decoration:underline;line-height:inherit}
  453. a:hover{color:#4101a7}
  454. a:focus{color:#000000}
  455. h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Quicksand","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#4101a7;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
  456. code{font-family:"Anonymous Pro","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
  457. *:not(pre)>code{font-size:1.09em;font-style:normal!important;letter-spacing:0;padding:0 0;word-spacing:-.15em;background-color:transparent;-webkit-border-radius:0;border-radius:0;line-height:1.45;text-rendering:optimizeLegibility;word-wrap:break-word}
  458. pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Anonymous Pro","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeLegibility;font-size:1.05em}
  459. kbd{font-family:"Anonymous Pro","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
  460. #header>h1:first-child{font-family:"Press Start 2P";color:#ff5100;margin-top:2.25rem;margin-bottom:0;letter-spacing:.3em}
  461. #toc ul{font-family:"Quicksand","DejaVu Sans",sans-serif;list-style-type:none}
  462. #toc a:hover{color:#4101a7}
  463. #toc.toc2{background-color:#f7f8f7}
  464. .admonitionblock td.icon .icon-note::before{content:"\f05a";color:#606060}
  465. .admonitionblock td.icon .icon-tip::before{content:"\f0eb";color:#606060;text-shadow:none}
  466. .admonitionblock td.icon .icon-warning::before{content:"\f071";color:#ff5100}
  467. .admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#ff5100}
  468. .admonitionblock td.icon .icon-important::before{content:"\f06a";color:#ff5100}
  469. .conum[data-value]{display:inline-block;color:#fff!important;background-color:#606060;-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
  470. .exampleblock>.content{background-color:#ffffff;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
  471. .quoteblock blockquote::before{margin-left:-.8em;color:#4101a7}
  472. .quoteblock blockquote{font-family:"Istok Web","DejaVu Serif"; font-size:1.0625rem; padding:0.5em}
  473. </style>
  474. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  475. <style>
  476. /* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
  477. /*pre.CodeRay {background-color:#f7f7f8;}*/
  478. .CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
  479. .CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
  480. .CodeRay .line-numbers strong{color:rgba(0,0,0,.4)}
  481. table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
  482. table.CodeRay td{vertical-align: top;line-height:1.45}
  483. table.CodeRay td.line-numbers{text-align:right}
  484. table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
  485. table.CodeRay td.code{padding:0 0 0 .5em}
  486. table.CodeRay td.code>pre{padding:0}
  487. .CodeRay .debug{color:#fff !important;background:#000080 !important}
  488. .CodeRay .annotation{color:#007}
  489. .CodeRay .attribute-name{color:#000080}
  490. .CodeRay .attribute-value{color:#700}
  491. .CodeRay .binary{color:#509}
  492. .CodeRay .comment{color:#998;font-style:italic}
  493. .CodeRay .char{color:#04d}
  494. .CodeRay .char .content{color:#04d}
  495. .CodeRay .char .delimiter{color:#039}
  496. .CodeRay .class{color:#458;font-weight:bold}
  497. .CodeRay .complex{color:#a08}
  498. .CodeRay .constant,.CodeRay .predefined-constant{color:#008080}
  499. .CodeRay .color{color:#099}
  500. .CodeRay .class-variable{color:#369}
  501. .CodeRay .decorator{color:#b0b}
  502. .CodeRay .definition{color:#099}
  503. .CodeRay .delimiter{color:#000}
  504. .CodeRay .doc{color:#970}
  505. .CodeRay .doctype{color:#34b}
  506. .CodeRay .doc-string{color:#d42}
  507. .CodeRay .escape{color:#666}
  508. .CodeRay .entity{color:#800}
  509. .CodeRay .error{color:#808}
  510. .CodeRay .exception{color:inherit}
  511. .CodeRay .filename{color:#099}
  512. .CodeRay .function{color:#900;font-weight:bold}
  513. .CodeRay .global-variable{color:#008080}
  514. .CodeRay .hex{color:#058}
  515. .CodeRay .integer,.CodeRay .float{color:#099}
  516. .CodeRay .include{color:#555}
  517. .CodeRay .inline{color:#000}
  518. .CodeRay .inline .inline{background:#ccc}
  519. .CodeRay .inline .inline .inline{background:#bbb}
  520. .CodeRay .inline .inline-delimiter{color:#d14}
  521. .CodeRay .inline-delimiter{color:#d14}
  522. .CodeRay .important{color:#555;font-weight:bold}
  523. .CodeRay .interpreted{color:#b2b}
  524. .CodeRay .instance-variable{color:#008080}
  525. .CodeRay .label{color:#970}
  526. .CodeRay .local-variable{color:#963}
  527. .CodeRay .octal{color:#40e}
  528. .CodeRay .predefined{color:#369}
  529. .CodeRay .preprocessor{color:#579}
  530. .CodeRay .pseudo-class{color:#555}
  531. .CodeRay .directive{font-weight:bold}
  532. .CodeRay .type{font-weight:bold}
  533. .CodeRay .predefined-type{color:inherit}
  534. .CodeRay .reserved,.CodeRay .keyword {color:#000;font-weight:bold}
  535. .CodeRay .key{color:#808}
  536. .CodeRay .key .delimiter{color:#606}
  537. .CodeRay .key .char{color:#80f}
  538. .CodeRay .value{color:#088}
  539. .CodeRay .regexp .delimiter{color:#808}
  540. .CodeRay .regexp .content{color:#808}
  541. .CodeRay .regexp .modifier{color:#808}
  542. .CodeRay .regexp .char{color:#d14}
  543. .CodeRay .regexp .function{color:#404;font-weight:bold}
  544. .CodeRay .string{color:#d20}
  545. .CodeRay .string .string .string{background:#ffd0d0}
  546. .CodeRay .string .content{color:#d14}
  547. .CodeRay .string .char{color:#d14}
  548. .CodeRay .string .delimiter{color:#d14}
  549. .CodeRay .shell{color:#d14}
  550. .CodeRay .shell .delimiter{color:#d14}
  551. .CodeRay .symbol{color:#990073}
  552. .CodeRay .symbol .content{color:#a60}
  553. .CodeRay .symbol .delimiter{color:#630}
  554. .CodeRay .tag{color:#008080}
  555. .CodeRay .tag-special{color:#d70}
  556. .CodeRay .variable{color:#036}
  557. .CodeRay .insert{background:#afa}
  558. .CodeRay .delete{background:#faa}
  559. .CodeRay .change{color:#aaf;background:#007}
  560. .CodeRay .head{color:#f8f;background:#505}
  561. .CodeRay .insert .insert{color:#080}
  562. .CodeRay .delete .delete{color:#800}
  563. .CodeRay .change .change{color:#66f}
  564. .CodeRay .head .head{color:#f4f}
  565. </style>
  566. </head>
  567. <body class="article toc2 toc-left">
  568. <div id="header">
  569. <h1>QVM</h1>
  570. <div class="details">
  571. <span id="author" class="author">Generic C&#43;&#43; library for working with Quaternions Vectors and Matrices</span><br>
  572. </div>
  573. <div id="toc" class="toc2">
  574. <div id="toctitle">Table of Contents</div>
  575. <ul class="sectlevel1">
  576. <li><a href="#_abstract">Abstract</a></li>
  577. <li><a href="#tutorial">Tutorial</a>
  578. <ul class="sectlevel2">
  579. <li><a href="#_quaternions_vectors_matrices">Quaternions, Vectors, Matrices</a></li>
  580. <li><a href="#_c_arrays">C Arrays</a></li>
  581. <li><a href="#view_proxy">View proxies</a></li>
  582. <li><a href="#_swizzling">Swizzling</a></li>
  583. <li><a href="#enable_if">SFINAE/enable_if</a></li>
  584. <li><a href="#_interoperability">Interoperability</a>
  585. <ul class="sectlevel3">
  586. <li><a href="#_specifying_return_types_for_binary_operations">Specifying return types for binary operations</a></li>
  587. <li><a href="#_specifying_return_types_for_unary_operations">Specifying return types for unary operations</a></li>
  588. <li><a href="#_converting_between_different_quaternion_vector_and_matrix_types">Converting between different quaternion, vector and matrix types</a></li>
  589. </ul>
  590. </li>
  591. </ul>
  592. </li>
  593. <li><a href="#reference">Reference</a>
  594. <ul class="sectlevel2">
  595. <li><a href="#_header_files">Header Files</a></li>
  596. <li><a href="#type_traits">Type Traits System</a>
  597. <ul class="sectlevel3">
  598. <li><a href="#scalar_requirements">Scalar Requirements</a></li>
  599. <li><a href="#is_scalar"><code>is_scalar</code></a></li>
  600. <li><a href="#scalar_traits"><code>scalar_traits</code></a></li>
  601. <li><a href="#deduce_scalar"><code>deduce_scalar</code></a></li>
  602. <li><a href="#scalar"><code>scalar</code></a></li>
  603. <li><a href="#is_quat"><code>is_quat</code></a></li>
  604. <li><a href="#quat_traits"><code>quat_traits</code></a></li>
  605. <li><a href="#quat_traits_defaults"><code>quat_traits_defaults</code></a></li>
  606. <li><a href="#deduce_quat"><code>deduce_quat</code></a></li>
  607. <li><a href="#deduce_quat2"><code>deduce_quat2</code></a></li>
  608. <li><a href="#is_vec"><code>is_vec</code></a></li>
  609. <li><a href="#vec_traits"><code>vec_traits</code></a></li>
  610. <li><a href="#vec_traits_defaults"><code>vec_traits_defaults</code></a></li>
  611. <li><a href="#deduce_vec"><code>deduce_vec</code></a></li>
  612. <li><a href="#deduce_vec2"><code>deduce_vec2</code></a></li>
  613. <li><a href="#is_mat"><code>is_mat</code></a></li>
  614. <li><a href="#mat_traits"><code>mat_traits</code></a></li>
  615. <li><a href="#mat_traits_defaults"><code>mat_traits_defaults</code></a></li>
  616. <li><a href="#deduce_mat"><code>deduce_mat</code></a></li>
  617. <li><a href="#deduce_mat2"><code>deduce_mat2</code></a></li>
  618. </ul>
  619. </li>
  620. <li><a href="#_built_in_quaternion_vector_and_matrix_types">Built-in Quaternion, Vector and Matrix Types</a>
  621. <ul class="sectlevel3">
  622. <li><a href="#quat"><code>quat</code></a></li>
  623. <li><a href="#vec"><code>vec</code></a></li>
  624. <li><a href="#mat"><code>mat</code></a></li>
  625. </ul>
  626. </li>
  627. <li><a href="#_element_access">Element Access</a>
  628. <ul class="sectlevel3">
  629. <li><a href="#quat_access">Quaternions</a></li>
  630. <li><a href="#vec_access">Vectors</a></li>
  631. <li><a href="#swizzling">Vector Element Swizzling</a></li>
  632. <li><a href="#mat_access">Matrices</a></li>
  633. </ul>
  634. </li>
  635. <li><a href="#_quaternion_operations">Quaternion Operations</a>
  636. <ul class="sectlevel3">
  637. <li><a href="#quat_assign"><code>assign</code></a></li>
  638. <li><a href="#quat_convert_to"><code>convert_to</code></a></li>
  639. <li><a href="#quat_minus_eq"><code>operator-=</code></a></li>
  640. <li><a href="#quat_minus_unary"><code>operator-</code> (unary)</a></li>
  641. <li><a href="#quat_minus"><code>operator-</code> (binary)</a></li>
  642. <li><a href="#quat_plus_eq"><code>operator+=</code></a></li>
  643. <li><a href="#quat_plus"><code>operator+</code></a></li>
  644. <li><a href="#quat_div_eq_scalar"><code>operator/=</code> (scalar)</a></li>
  645. <li><a href="#quat_div_scalar"><code>operator/</code> (scalar)</a></li>
  646. <li><a href="#quat_mul_eq_scalar"><code>operator*=</code> (scalar)</a></li>
  647. <li><a href="#quat_mul_eq"><code>operator*=</code></a></li>
  648. <li><a href="#quat_mul_scalar"><code>operator*</code> (scalar)</a></li>
  649. <li><a href="#quat_mul"><code>operator*</code></a></li>
  650. <li><a href="#quat_eq"><code>operator==</code></a></li>
  651. <li><a href="#quat_neq"><code>operator!=</code></a></li>
  652. <li><a href="#quat_cmp"><code>cmp</code></a></li>
  653. <li><a href="#quat_mag_sqr"><code>mag_sqr</code></a></li>
  654. <li><a href="#quat_mag"><code>mag</code></a></li>
  655. <li><a href="#quat_normalized"><code>normalized</code></a></li>
  656. <li><a href="#quat_normalize"><code>normalize</code></a></li>
  657. <li><a href="#quat_dot"><code>dot</code></a></li>
  658. <li><a href="#conjugate"><code>conjugate</code></a></li>
  659. <li><a href="#quat_inverse"><code>inverse</code></a></li>
  660. <li><a href="#slerp"><code>slerp</code></a></li>
  661. <li><a href="#zero_quat"><code>zero_quat</code></a></li>
  662. <li><a href="#quat_set_zero"><code>set_zero</code></a></li>
  663. <li><a href="#identity_quat"><code>identity_quat</code></a></li>
  664. <li><a href="#quat_set_identity"><code>set_identity</code></a></li>
  665. <li><a href="#rot_quat"><code>rot_quat</code></a></li>
  666. <li><a href="#quat_set_rot"><code>set_rot</code></a></li>
  667. <li><a href="#quat_rotate"><code>rotate</code></a></li>
  668. <li><a href="#rotx_quat"><code>rotx_quat</code></a></li>
  669. <li><a href="#quat_set_rotx"><code>set_rotx</code></a></li>
  670. <li><a href="#quat_rotate_x"><code>rotate_x</code></a></li>
  671. <li><a href="#roty_quat"><code>roty_quat</code></a></li>
  672. <li><a href="#quat_set_roty"><code>set_roty</code></a></li>
  673. <li><a href="#quat_rotate_y"><code>rotate_y</code></a></li>
  674. <li><a href="#rotz_quat"><code>rotz_quat</code></a></li>
  675. <li><a href="#quat_set_rotz"><code>set_rotz</code></a></li>
  676. <li><a href="#quat_rotate_z"><code>rotate_z</code></a></li>
  677. <li><a href="#quat_scalar_cast"><code>scalar_cast</code></a></li>
  678. <li><a href="#qref"><code>qref</code></a></li>
  679. </ul>
  680. </li>
  681. <li><a href="#_vector_operations">Vector Operations</a>
  682. <ul class="sectlevel3">
  683. <li><a href="#vec_assign"><code>assign</code></a></li>
  684. <li><a href="#vec_convert_to"><code>convert_to</code></a></li>
  685. <li><a href="#vec_minus_eq"><code>operator-=</code></a></li>
  686. <li><a href="#vec_minus_unary"><code>operator-</code> (unary)</a></li>
  687. <li><a href="#vec_minus"><code>operator-</code> (binary)</a></li>
  688. <li><a href="#vec_plus_eq"><code>operator+=</code></a></li>
  689. <li><a href="#vec_plus"><code>operator+</code></a></li>
  690. <li><a href="#vec_div_eq_scalar"><code>operator/=</code> (scalar)</a></li>
  691. <li><a href="#vec_div_scalar"><code>operator/</code></a></li>
  692. <li><a href="#vec_mul_eq_scalar"><code>operator*=</code></a></li>
  693. <li><a href="#vec_mul_scalar"><code>operator*</code></a></li>
  694. <li><a href="#vec_eq"><code>operator==</code></a></li>
  695. <li><a href="#vec_neq"><code>operator!=</code></a></li>
  696. <li><a href="#vec_cmp"><code>cmp</code></a></li>
  697. <li><a href="#vec_mag_sqr"><code>mag_sqr</code></a></li>
  698. <li><a href="#vec_mag"><code>mag</code></a></li>
  699. <li><a href="#vec_normalized"><code>normalized</code></a></li>
  700. <li><a href="#vec_normalize"><code>normalize</code></a></li>
  701. <li><a href="#vec_dot"><code>dot</code></a></li>
  702. <li><a href="#vec_cross"><code>cross</code></a></li>
  703. <li><a href="#zero_vec"><code>zero_vec</code></a></li>
  704. <li><a href="#vec_set_zero"><code>set_zero</code></a></li>
  705. <li><a href="#vec_scalar_cast"><code>scalar_cast</code></a></li>
  706. <li><a href="#vref"><code>vref</code></a></li>
  707. </ul>
  708. </li>
  709. <li><a href="#_matrix_operations">Matrix Operations</a>
  710. <ul class="sectlevel3">
  711. <li><a href="#mat_assign"><code>assign</code></a></li>
  712. <li><a href="#mat_convert_to"><code>convert_to</code></a></li>
  713. <li><a href="#mat_minus_eq_scalar"><code>operator-=</code></a></li>
  714. <li><a href="#mat_minus_unary"><code>operator-</code> (unary)</a></li>
  715. <li><a href="#mat_minus"><code>operator-</code></a></li>
  716. <li><a href="#mat_plus_eq_scalar"><code>operator+=</code></a></li>
  717. <li><a href="#mat_plus"><code>operator+</code></a></li>
  718. <li><a href="#mat_div_eq_scalar"><code>operator/=</code> (scalar)</a></li>
  719. <li><a href="#mat_div_scalar"><code>operator/</code> (scalar)</a></li>
  720. <li><a href="#mat_mul_eq"><code>operator*=</code></a></li>
  721. <li><a href="#mat_mul_eq_scalar"><code>operator*=</code> (scalar)</a></li>
  722. <li><a href="#mat_mul"><code>operator*</code></a></li>
  723. <li><a href="#mat_mul_scalar"><code>operator*</code> (scalar)</a></li>
  724. <li><a href="#mat_eq"><code>operator==</code></a></li>
  725. <li><a href="#mat_neq"><code>operator!=</code></a></li>
  726. <li><a href="#mat_cmp"><code>cmp</code></a></li>
  727. <li><a href="#mat_inverse"><code>inverse</code></a></li>
  728. <li><a href="#zero_mat"><code>zero_mat</code></a></li>
  729. <li><a href="#mat_set_zero"><code>set_zero</code></a></li>
  730. <li><a href="#identity_mat"><code>identity_mat</code></a></li>
  731. <li><a href="#mat_set_identity"><code>set_identity</code></a></li>
  732. <li><a href="#rot_mat"><code>rot_mat</code> / Euler angles</a></li>
  733. <li><a href="#mat_set_rot"><code>set_rot</code> / Euler angles</a></li>
  734. <li><a href="#mat_rotate"><code>rotate</code> / Euler angles</a></li>
  735. <li><a href="#rotx_mat"><code>rotx_mat</code></a></li>
  736. <li><a href="#mat_set_rotx"><code>set_rotx</code></a></li>
  737. <li><a href="#mat_rotate_x"><code>rotate_x</code></a></li>
  738. <li><a href="#roty_mat"><code>roty_mat</code></a></li>
  739. <li><a href="#mat_set_roty"><code>set_roty</code></a></li>
  740. <li><a href="#mat_rotate_y"><code>rotate_y</code></a></li>
  741. <li><a href="#rotz_mat"><code>rotz_mat</code></a></li>
  742. <li><a href="#mat_set_rotz"><code>set_rotz</code></a></li>
  743. <li><a href="#mat_rotate_z"><code>rotate_z</code></a></li>
  744. <li><a href="#determinant"><code>determinant</code></a></li>
  745. <li><a href="#perspective_lh"><code>perspective_lh</code></a></li>
  746. <li><a href="#perspective_rh"><code>perspective_rh</code></a></li>
  747. <li><a href="#mat_scalar_cast"><code>scalar_cast</code></a></li>
  748. <li><a href="#mref"><code>mref</code></a></li>
  749. </ul>
  750. </li>
  751. <li><a href="#_quaternion_vector_operations">Quaternion-Vector Operations</a>
  752. <ul class="sectlevel3">
  753. <li><a href="#quat_vec_mul"><code>operator*</code></a></li>
  754. </ul>
  755. </li>
  756. <li><a href="#_matrix_vector_operations">Matrix-Vector Operations</a>
  757. <ul class="sectlevel3">
  758. <li><a href="#mat_vec_mul"><code>operator*</code></a></li>
  759. <li><a href="#transform_vector"><code>transform_vector</code></a></li>
  760. <li><a href="#transform_point"><code>transform_point</code></a></li>
  761. </ul>
  762. </li>
  763. <li><a href="#_matrix_to_matrix_view_proxies">Matrix-to-Matrix View Proxies</a>
  764. <ul class="sectlevel3">
  765. <li><a href="#del_row"><code>del_row</code></a></li>
  766. <li><a href="#del_col"><code>del_col</code></a></li>
  767. <li><a href="#del_row_col"><code>del_row_col</code></a></li>
  768. <li><a href="#neg_row"><code>neg_row</code></a></li>
  769. <li><a href="#neg_col"><code>neg_col</code></a></li>
  770. <li><a href="#swap_rows"><code>swap_rows</code></a></li>
  771. <li><a href="#swap_cols"><code>swap_cols</code></a></li>
  772. <li><a href="#transposed"><code>transposed</code></a></li>
  773. </ul>
  774. </li>
  775. <li><a href="#_vector_to_matrix_view_proxies">Vector-to-Matrix View Proxies</a>
  776. <ul class="sectlevel3">
  777. <li><a href="#col_mat"><code>col_mat</code></a></li>
  778. <li><a href="#row_mat"><code>row_mat</code></a></li>
  779. <li><a href="#translation_mat"><code>translation_mat</code></a></li>
  780. <li><a href="#diag_mat"><code>diag_mat</code></a></li>
  781. </ul>
  782. </li>
  783. <li><a href="#_matrix_to_vector_view_proxies">Matrix-to-Vector View Proxies</a>
  784. <ul class="sectlevel3">
  785. <li><a href="#col"><code>col</code></a></li>
  786. <li><a href="#row"><code>row</code></a></li>
  787. <li><a href="#diag"><code>diag</code></a></li>
  788. <li><a href="#translation"><code>translation</code></a></li>
  789. </ul>
  790. </li>
  791. <li><a href="#_exceptions">Exceptions</a>
  792. <ul class="sectlevel3">
  793. <li><a href="#error"><code>error</code></a></li>
  794. <li><a href="#zero_magnitude_error"><code>zero_magnitude_error</code></a></li>
  795. <li><a href="#zero_determinant_error"><code>zero_determinant_error</code></a></li>
  796. </ul>
  797. </li>
  798. <li><a href="#_macros_and_configuration_boost_qvm">Macros and Configuration: BOOST_QVM_</a>
  799. <ul class="sectlevel3">
  800. <li><a href="#BOOST_QVM_INLINE"><code>INLINE</code></a></li>
  801. <li><a href="#BOOST_QVM_FORCE_INLINE"><code>FORCE_INLINE</code></a></li>
  802. <li><a href="#BOOST_QVM_INLINE_TRIVIAL"><code>INLINE_TRIVIAL</code></a></li>
  803. <li><a href="#BOOST_QVM_INLINE_CRITICAL"><code>INLINE_CRITICAL</code></a></li>
  804. <li><a href="#BOOST_QVM_INLINE_OPERATIONS"><code>INLINE_OPERATIONS</code></a></li>
  805. <li><a href="#BOOST_QVM_INLINE_RECURSION"><code>INLINE_RECURSION</code></a></li>
  806. <li><a href="#BOOST_QVM_ASSERT"><code>ASSERT</code></a></li>
  807. <li><a href="#BOOST_QVM_STATIC_ASSERT"><code>STATIC_ASSERT</code></a></li>
  808. <li><a href="#BOOST_QVM_THROW_EXCEPTION"><code>THROW_EXCEPTION</code></a></li>
  809. </ul>
  810. </li>
  811. </ul>
  812. </li>
  813. <li><a href="#rationale">Design Rationale</a></li>
  814. <li><a href="#_code_generator">Code Generator</a></li>
  815. <li><a href="#_known_quirks_and_issues">Known Quirks and Issues</a>
  816. <ul class="sectlevel2">
  817. <li><a href="#_capturing_view_proxies_with_auto">Capturing View Proxies with <code>auto</code></a></li>
  818. <li><a href="#_binding_qvm_overloads_from_an_unrelated_namespace">Binding QVM Overloads From an Unrelated Namespace</a></li>
  819. <li><a href="#_link_errors_when_calling_math_functions_with_int_arguments">Link Errors When Calling Math Functions with <code>int</code> Arguments</a></li>
  820. </ul>
  821. </li>
  822. <li><a href="#_distribution">Distribution</a></li>
  823. <li><a href="#_portability">Portability</a></li>
  824. <li><a href="#_feedback_support">Feedback / Support</a></li>
  825. <li><a href="#_qa">Q&amp;A</a></li>
  826. </ul>
  827. </div>
  828. </div>
  829. <div id="content">
  830. <div class="sect1">
  831. <h2 id="_abstract">Abstract</h2>
  832. <div class="sectionbody">
  833. <div class="paragraph">
  834. <p>QVM is a generic library for working with Quaternions, Vectors and Matrices of static size. Features:</p>
  835. </div>
  836. <div class="exampleblock">
  837. <div class="content">
  838. <div class="ulist">
  839. <ul>
  840. <li>
  841. <p>Emphasis on 2, 3 and 4-dimensional operations needed in graphics, video games and simulation applications.</p>
  842. </li>
  843. <li>
  844. <p>Free function templates operate on any compatible user-defined quaternion, vector or matrix type.</p>
  845. </li>
  846. <li>
  847. <p>Quaternion, vector and matrix types from different libraries or subsystems can be safely mixed in the same expression.</p>
  848. </li>
  849. <li>
  850. <p>Type-safe mapping between compatible lvalue types with no temporary objects; e.g. transpose remaps the elements, rather than transforming the matrix.</p>
  851. </li>
  852. </ul>
  853. </div>
  854. <div class="paragraph text-right">
  855. <p><a href="https://github.com/boostorg/qvm">GitHub</a> | <a href="#tutorial">Tutorial</a> | <a href="#reference">Reference</a> | <a href="#rationale">Design Rationale</a></p>
  856. </div>
  857. </div>
  858. </div>
  859. </div>
  860. </div>
  861. <div class="sect1">
  862. <h2 id="tutorial">Tutorial</h2>
  863. <div class="sectionbody">
  864. <div class="sect2">
  865. <h3 id="_quaternions_vectors_matrices">Quaternions, Vectors, Matrices</h3>
  866. <div class="paragraph">
  867. <p>Out of the box QVM defines generic yet simple <a href="#quat"><code>quat</code></a>, <a href="#vec"><code>vec</code></a> and <a href="#mat"><code>mat</code></a> types. For example, the following snippet creates a quaternion object that rotates around the X axis:</p>
  868. </div>
  869. <div class="listingblock">
  870. <div class="content">
  871. <pre class="CodeRay highlight nowrap"><code data-lang="c++">quat&lt;float&gt; rx = rotx_quat(3.14159f);</code></pre>
  872. </div>
  873. </div>
  874. <div class="paragraph">
  875. <p>Similarly, a matrix that translates by a given vector can be created as follows:</p>
  876. </div>
  877. <div class="listingblock">
  878. <div class="content">
  879. <pre class="CodeRay highlight nowrap"><code data-lang="c++">vec&lt;float,3&gt; v = {0,0,7};
  880. mat&lt;float,4,4&gt; tr = translation_mat(v);</code></pre>
  881. </div>
  882. </div>
  883. <div class="paragraph">
  884. <p>The usual quaternion, vector and matrix operations work on these QVM types, however the operations are decoupled from any specific type: they work on any suitable type that has been registered by specializing the <a href="#quat_traits"><code>quat_traits</code></a>, <a href="#vec_traits"><code>vec_traits</code></a> and <a href="#mat_traits"><code>mat_traits</code></a> templates.</p>
  885. </div>
  886. <div class="paragraph">
  887. <p>For example, a user-defined 3D vector type <code>float3</code> can be introduced to QVM as follows:</p>
  888. </div>
  889. <div class="listingblock">
  890. <div class="content">
  891. <pre class="CodeRay highlight nowrap"><code data-lang="c++">struct float3 { float a[3]; };
  892. namespace boost { namespace qvm {
  893. template &lt;&gt;
  894. struct vec_traits&lt;float3&gt; {
  895. static int const dim=3;
  896. typedef float scalar_type;
  897. template &lt;int I&gt;
  898. static inline scalar_type &amp; write_element( float3 &amp; v ) {
  899. return v.a[I];
  900. }
  901. template &lt;int I&gt;
  902. static inline scalar_type read_element( float3 const &amp; v ) {
  903. return v.a[I];
  904. }
  905. static inline scalar_type &amp; write_element_idx( int i, float3 &amp; v ) {
  906. return v.a[i];
  907. } //optional
  908. static inline scalar_type read_element_idx( int i, float3 const &amp; v ) {
  909. return v.a[i];
  910. } //optional
  911. };
  912. } }</code></pre>
  913. </div>
  914. </div>
  915. <div class="paragraph">
  916. <p>Equivalently, using the <a href="#vec_traits_defaults"><code>vec_traits_defaults</code></a> template the above can be shortened to:</p>
  917. </div>
  918. <div class="listingblock">
  919. <div class="content">
  920. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  921. template &lt;&gt;
  922. struct vec_traits&lt;float3&gt;: vec_traits_defaults&lt;float3,float,3&gt; {
  923. template &lt;int I&gt;
  924. static inline scalar_type &amp; write_element( float3 &amp; v ) {
  925. return v.a[I];
  926. }
  927. static inline scalar_type &amp; write_element_idx( int i, float3 &amp; v ) {
  928. return v.a[i];
  929. } //optional
  930. };
  931. } }</code></pre>
  932. </div>
  933. </div>
  934. <div class="paragraph">
  935. <p>After a similar specialization of the <a href="#mat_traits"><code>mat_traits</code></a> template for a user-defined 3x3 matrix type <code>float33</code>, the full range of vector and matrix operations defined by QVM headers becomes available automatically:</p>
  936. </div>
  937. <div class="listingblock">
  938. <div class="content">
  939. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float3 v;
  940. X(v) = 0;
  941. Y(v) = 0;
  942. Z(v) = 7;
  943. float vmag = mag(v);
  944. float33 m = rotx_mat&lt;3&gt;(3.14159f);
  945. float3 vrot = m * v;</code></pre>
  946. </div>
  947. </div>
  948. <div class="paragraph">
  949. <p>User-defined quaternion types are similarly introduced to QVM by specializing the <a href="#quat_traits"><code>quat_traits</code></a> template.</p>
  950. </div>
  951. <hr>
  952. </div>
  953. <div class="sect2">
  954. <h3 id="_c_arrays">C Arrays</h3>
  955. <div class="paragraph">
  956. <p>In <a href="#boost/qvm/quat_traits_array.hpp"><code>boost/qvm/quat_traits_array.hpp</code></a>, <a href="#boost/qvm/vec_traits_array.hpp"><code>boost/qvm/vec_traits_array.hpp</code></a> and <a href="#boost/qvm/mat_traits_array.hpp"><code>boost/qvm/mat_traits_array.hpp</code></a> QVM defines appropriate <a href="#quat_traits"><code>quat_traits</code></a>, <a href="#vec_traits"><code>vec_traits</code></a> and <a href="#mat_traits"><code>mat_traits</code></a> specializations that allow QVM functions to operate directly on plain old C arrays:</p>
  957. </div>
  958. <div class="listingblock">
  959. <div class="content">
  960. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float v[3] = {0,0,7};
  961. float3 vrot = rotx_mat&lt;3&gt;(3.14159f) * v;</code></pre>
  962. </div>
  963. </div>
  964. <div class="paragraph">
  965. <p>Naturally, operator overloads cannot kick in if all elements of an expression are of built-in types. The following is still illegal:</p>
  966. </div>
  967. <div class="listingblock">
  968. <div class="content">
  969. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float v[3] = {0,0,7};
  970. v *= 42;</code></pre>
  971. </div>
  972. </div>
  973. <div class="paragraph">
  974. <p>The <a href="#vref"><code>vref</code></a> and <a href="#mref"><code>mref</code></a> function templates can be used to work around this issue:</p>
  975. </div>
  976. <div class="listingblock">
  977. <div class="content">
  978. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float v[3] = {0,0,7};
  979. vref(v) *= 42;</code></pre>
  980. </div>
  981. </div>
  982. <hr>
  983. </div>
  984. <div class="sect2">
  985. <h3 id="view_proxy">View proxies</h3>
  986. <div class="paragraph">
  987. <p>QVM defines various function templates that provide static mapping between (possibly user-defined) quaternion, vector and matrix types. The example below multiplies column 1 (QVM indexes are always zero-based) of the matrix <code>m</code> by a scalar:</p>
  988. </div>
  989. <div class="listingblock">
  990. <div class="content">
  991. <pre class="CodeRay highlight nowrap"><code data-lang="c++">void multiply_column1( float33 &amp; m, float scalar ) {
  992. col&lt;1&gt;(m) *= scalar;
  993. }</code></pre>
  994. </div>
  995. </div>
  996. <div class="paragraph">
  997. <p>The expression <a href="#col"><code>col&lt;1&gt;(m)</code></a> is an lvalue of an unspecified 3D vector type that refers to column 1 of <code>m</code>. Note however that this does not create any temporary objects; instead <code>operator*=</code> above works directly with a reference to <code>m</code>.</p>
  998. </div>
  999. <div class="paragraph">
  1000. <p>Here is another example, multiplying a transposed view of a matrix by a vector of some user-defined type <code>float3</code>:</p>
  1001. </div>
  1002. <div class="listingblock">
  1003. <div class="content">
  1004. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float3 v = {0,0,7};
  1005. float3 vrot = transposed(rotx_mat&lt;3&gt;(3.14159f)) * v;</code></pre>
  1006. </div>
  1007. </div>
  1008. <div class="paragraph">
  1009. <p>In general, the various view proxy functions return references of unspecified, non-copyable types that refer to the original object. They can be assigned from or converted to any compatible vector or matrix type.</p>
  1010. </div>
  1011. <hr>
  1012. </div>
  1013. <div class="sect2">
  1014. <h3 id="_swizzling">Swizzling</h3>
  1015. <div class="paragraph">
  1016. <p>QVM allows accessing vector elements by swizzling, exposing vector views of different dimensions, and/or views with reordered elements. The example below rotates <code>v</code> around the X axis, and stores the resulting vector back in <code>v</code> but with the X and Y elements swapped:</p>
  1017. </div>
  1018. <div class="listingblock">
  1019. <div class="content">
  1020. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float3 v = {0,0,7};
  1021. YXZ(v) = rotx_mat&lt;3&gt;(3.14159f) * v;</code></pre>
  1022. </div>
  1023. </div>
  1024. <div class="paragraph">
  1025. <p>A special case of swizzling provides next-dimension-view of a vector object, adding either 0 or 1 as its last component. Assuming <code>float3</code> is a 3D vector type, and <code>float4</code> is a 4D vector type, the following statements are valid:</p>
  1026. </div>
  1027. <div class="listingblock">
  1028. <div class="content">
  1029. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float3 v = {0,0,7};
  1030. float4 point = XYZ1(v); //{0,0,7,1}
  1031. float4 vector = XYZ0(v); //{0,0,7,0}</code></pre>
  1032. </div>
  1033. </div>
  1034. <div class="paragraph">
  1035. <p>It is also valid for swizzling to address vector elements more than once:</p>
  1036. </div>
  1037. <div class="listingblock">
  1038. <div class="content">
  1039. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float3 v = {0,0,7};
  1040. float4 v1 = ZZZZ(v); //{7,7,7,7}</code></pre>
  1041. </div>
  1042. </div>
  1043. <div class="paragraph">
  1044. <p>QVM defines all permutations of <code>X</code>, <code>Y</code>, <code>Z</code>, <code>W</code> for 1D, 2D, 3D and 4D swizzling, plus each dimension defines variants with 0 or 1 used at any position (if 0 or 1 appear at the first position, the swizzling function name begins with underscore, e.g. <code>_1XY</code>).</p>
  1045. </div>
  1046. <div class="paragraph">
  1047. <p>The swizzling syntax can also be used to bind scalars as vectors. For example:</p>
  1048. </div>
  1049. <div class="listingblock">
  1050. <div class="content">
  1051. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float3 v = _00X(42.0f); //{0,0,42}</code></pre>
  1052. </div>
  1053. </div>
  1054. <hr>
  1055. </div>
  1056. <div class="sect2">
  1057. <h3 id="enable_if">SFINAE/enable_if</h3>
  1058. <div class="paragraph">
  1059. <p>SFINAE stands for Substitution Failure Is Not An Error. This refers to a situation in C&#43;&#43; where an invalid substitution of template parameters (including when those parameters are deduced implicitly as a result of an unqualified call) is not in itself an error.</p>
  1060. </div>
  1061. <div class="paragraph">
  1062. <p>In absence of concepts support, SFINAE can be used to disable function template overloads that would otherwise present a signature that is too generic. More formally, this is supported by the Boost <code>enable_if</code> library.</p>
  1063. </div>
  1064. <div class="paragraph">
  1065. <p>For example, QVM defines <code>operator*</code> overload which works with any user-defined matrix and vector types. The naive approach would be to declare this overload as follows:</p>
  1066. </div>
  1067. <div class="listingblock">
  1068. <div class="content">
  1069. <pre class="CodeRay highlight nowrap"><code data-lang="c++">template &lt;class Matrix,class Vector&gt;
  1070. Vector operator*( Matrix const &amp; m, Vector const &amp; v );</code></pre>
  1071. </div>
  1072. </div>
  1073. <div class="paragraph">
  1074. <p>Even if the function definition might contain code that would compile only for <code>Matrix</code> and <code>Vector</code> types, because the function declaration itself is valid, it will participate in overload rezolutions when multiplying objects of any two types whatsoever. This typically renders overload resolutions ambiguous and the compiler (correctly) issues an error.</p>
  1075. </div>
  1076. <div class="paragraph">
  1077. <p>Using <code>enable_if</code>, QVM declares such overloads in a way that preserves their generic signature but only participate in overload resolutions if the passed parameters make sense depending on the semantics of the operation being defined:</p>
  1078. </div>
  1079. <div class="listingblock">
  1080. <div class="content">
  1081. <pre class="CodeRay highlight nowrap"><code data-lang="c++">template &lt;class A,class B&gt;
  1082. typename enable_if_c&lt;
  1083. is_mat&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp; mat_traits&lt;A&gt;::cols==vec_traits&lt;B&gt;::dim, //Condition
  1084. B&gt;::type //Return type
  1085. operator*( A const &amp; a, B const &amp; b );</code></pre>
  1086. </div>
  1087. </div>
  1088. <div class="paragraph">
  1089. <p>For brevity, function declarations throughout this documentation specify the condition which controls whether they are enabled or not without specifying exactly what <code>enable_if</code> construct is used to achieve this effect.</p>
  1090. </div>
  1091. <hr>
  1092. </div>
  1093. <div class="sect2">
  1094. <h3 id="_interoperability">Interoperability</h3>
  1095. <div class="paragraph">
  1096. <p>An important design goal of QVM is that it works seamlessly with 3rd-party quaternion, vector and matrix types and libraries. Even when such libraries overload the same C&#43;&#43; operators as QVM, it is safe to bring the entire <code>boost::qvm</code> namespace in scope by specifying:</p>
  1097. </div>
  1098. <div class="listingblock">
  1099. <div class="content">
  1100. <pre class="CodeRay highlight nowrap"><code data-lang="c++">using namespace boost::qvm;</code></pre>
  1101. </div>
  1102. </div>
  1103. <div class="paragraph">
  1104. <p>The above using directive does not introduce ambiguities with function and operator overloads defined by a 3rd-party library because:</p>
  1105. </div>
  1106. <div class="ulist">
  1107. <ul>
  1108. <li>
  1109. <p>Most <code>boost::qvm</code> function overloads and all operator overloads use SFINAE/<code>enable_if</code>, which makes them "disappear" unless an expression uses types that have the appropriate QVM-specific type traits defined;</p>
  1110. </li>
  1111. <li>
  1112. <p>Whenever such overloads are compatible with a given expression, their signature is extremely generic, which means that any other (user-defined) compatible overload will be a better match in any overload resolution.</p>
  1113. </li>
  1114. </ul>
  1115. </div>
  1116. <div class="admonitionblock note">
  1117. <table>
  1118. <tr>
  1119. <td class="icon">
  1120. <i class="fa icon-note" title="Note"></i>
  1121. </td>
  1122. <td class="content">
  1123. Bringing the entire boost::qvm namespace in scope may introduce ambiguities when accessing types (as opposed to functions) defined by 3rd-party libraries. In that case, you can safely bring namespace <code>boost::qvm::sfinae</code> in scope instead, which contains only function and operator overloads that use SFINAE/<code>enable_if</code>.
  1124. </td>
  1125. </tr>
  1126. </table>
  1127. </div>
  1128. <div class="sect3">
  1129. <h4 id="_specifying_return_types_for_binary_operations">Specifying return types for binary operations</h4>
  1130. <div class="paragraph">
  1131. <p>Bringing the <code>boost::qvm</code> namespace in scope lets you mix vector and matrix types that come from different APIs into a common, type-safe framework. In this case however, it should be considered what types should be returned by binary operations that return an object by value. For example, if you multiply a 3x3 matrix <code>m1</code> of type <code>user_matrix1</code> by a 3x3 matrix <code>m2</code> of type <code>user_matrix2</code>, what type should that operation return?</p>
  1132. </div>
  1133. <div class="paragraph">
  1134. <p>The answer is that by default, QVM returns some kind of compatible matrix type, so it is always safe to write:</p>
  1135. </div>
  1136. <div class="listingblock">
  1137. <div class="content">
  1138. <pre class="CodeRay highlight nowrap"><code data-lang="c++">auto &amp; m = m1 * m2;</code></pre>
  1139. </div>
  1140. </div>
  1141. <div class="paragraph">
  1142. <p>However, the type deduced by default converts implicitly to any compatible matrix type, so the following is also valid, at the cost of a temporary:</p>
  1143. </div>
  1144. <div class="listingblock">
  1145. <div class="content">
  1146. <pre class="CodeRay highlight nowrap"><code data-lang="c++">user_matrix1 m = m1 * m2;</code></pre>
  1147. </div>
  1148. </div>
  1149. <div class="paragraph">
  1150. <p>While the temporary object can be optimized away by many compilers, it can be avoided altogether by specializing the <a href="#deduce_mat2"><code>deduce_mat2</code></a> template. For example, to specify that multiplying a <code>user_matrix1</code> by a <code>user_matrix2</code> should always produce a <code>user_matrix1</code> object, you could write:</p>
  1151. </div>
  1152. <div class="listingblock">
  1153. <div class="content">
  1154. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1155. template &lt;&gt;
  1156. struct deduce_mat2&lt;user_matrix1,user_matrix2,3,3&gt; {
  1157. typedef user_matrix1 type;
  1158. };
  1159. template &lt;&gt;
  1160. struct deduce_mat2&lt;user_matrix2,user_matrix1,3,3&gt; {
  1161. typedef user_matrix1 type;
  1162. };
  1163. } }</code></pre>
  1164. </div>
  1165. </div>
  1166. <div class="admonitionblock warning">
  1167. <table>
  1168. <tr>
  1169. <td class="icon">
  1170. <i class="fa icon-warning" title="Warning"></i>
  1171. </td>
  1172. <td class="content">
  1173. <div class="paragraph">
  1174. <p>Be mindful of potential ODR violation when using <a href="#deduce_quat2"><code>deduce_quat2</code></a>, <a href="#deduce_vec2"><code>deduce_vec2</code></a> and <a href="#deduce_mat2"><code>deduce_mat2</code></a> in independent libraries. For example, this could happen if <code>lib1</code> defines <code>deduce_vec2&lt;lib1::vec,lib2::vec&gt;::type</code> as <code>lib1::vec</code> and in the same program <code>lib2</code> defines <code>deduce_vec2&lt;lib1::vec,lib2::vec&gt;::type</code> as <code>lib2::vec</code>.</p>
  1175. </div>
  1176. <div class="paragraph">
  1177. <p>It is best to keep such specializations out of <code>lib1</code> and <code>lib2</code>. Of course, it is always safe for <code>lib1</code> and <code>lib2</code> to use <a href="#convert_to"><code>convert_to</code></a> to convert between the <code>lib1::vec</code> and <code>lib2::vec</code> types as needed.</p>
  1178. </div>
  1179. </td>
  1180. </tr>
  1181. </table>
  1182. </div>
  1183. </div>
  1184. <div class="sect3">
  1185. <h4 id="_specifying_return_types_for_unary_operations">Specifying return types for unary operations</h4>
  1186. <div class="paragraph">
  1187. <p>Perhaps surprisingly, unary operations that return an object by value have a similar, though simpler issue. That&#8217;s because the argument they&#8217;re called with may not be copyable, as in:</p>
  1188. </div>
  1189. <div class="listingblock">
  1190. <div class="content">
  1191. <pre class="CodeRay highlight nowrap"><code data-lang="c++">float m[3][3];
  1192. auto &amp; inv = inverse(m);</code></pre>
  1193. </div>
  1194. </div>
  1195. <div class="paragraph">
  1196. <p>Above, the object returned by <a href="#mat_inverse"><code>inverse</code></a> and captured by <code>inv</code> can not be of type <code>float[3][3]</code>, because that type isn&#8217;t copyable. By default, QVM "just works", returning an object of suitable matrix type that is copyable. This deduction process can be controlled, by specializing the <a href="#deduce_mat"><code>deduce_mat</code></a> template.</p>
  1197. </div>
  1198. </div>
  1199. <div class="sect3">
  1200. <h4 id="_converting_between_different_quaternion_vector_and_matrix_types">Converting between different quaternion, vector and matrix types</h4>
  1201. <div class="paragraph">
  1202. <p>Any time you need to create a matrix of a particular C&#43;&#43; type from any other compatible matrix type, you can use the <a href="#convert_to"><code>convert_to</code></a> function:</p>
  1203. </div>
  1204. <div class="listingblock">
  1205. <div class="content">
  1206. <pre class="CodeRay highlight nowrap"><code data-lang="c++">user_matrix2 m=convert_to&lt;user_matrix2&gt;(m1 * m2);</code></pre>
  1207. </div>
  1208. </div>
  1209. </div>
  1210. </div>
  1211. </div>
  1212. </div>
  1213. <div class="sect1">
  1214. <h2 id="reference">Reference</h2>
  1215. <div class="sectionbody">
  1216. <div class="sect2">
  1217. <h3 id="_header_files">Header Files</h3>
  1218. <div class="paragraph">
  1219. <p>QVM is split into multiple headers to allow different compilation units to <code>#include</code> only the components they need. Each function in this document specifies the exact header that must be <code>#included</code> in order to use it.</p>
  1220. </div>
  1221. <div class="paragraph">
  1222. <p>The tables below list commonly used components and the headers they&#8217;re found in. Header names containing a number define functions that only work with objects of that dimension; e.g. <code>vec_operations2.hpp</code> contains only functions for working with 2D vectors.</p>
  1223. </div>
  1224. <div class="paragraph">
  1225. <p>The header <code>boost/qvm/all.hpp</code> is provided for convenience. It includes all other QVM headers.</p>
  1226. </div>
  1227. <table class="tableblock frame-all grid-all stretch">
  1228. <caption class="title">Table 1. Quaternion header files</caption>
  1229. <colgroup>
  1230. <col style="width: 33.3333%;">
  1231. <col style="width: 66.6667%;">
  1232. </colgroup>
  1233. <tbody>
  1234. <tr>
  1235. <td class="tableblock halign-left valign-top"><p class="tableblock">Quaternion traits</p></td>
  1236. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/quat_traits.hpp&gt;
  1237. #include &lt;boost/qvm/quat_traits_array.hpp&gt;
  1238. #include &lt;boost/qvm/deduce_quat.hpp&gt;</pre></div></td>
  1239. </tr>
  1240. <tr>
  1241. <td class="tableblock halign-left valign-top"><p class="tableblock">Quaternion element access</p></td>
  1242. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/quat_access.hpp&gt;</pre></div></td>
  1243. </tr>
  1244. <tr>
  1245. <td class="tableblock halign-left valign-top"><p class="tableblock">Quaternion operations</p></td>
  1246. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/quat_operations.hpp&gt;</pre></div></td>
  1247. </tr>
  1248. <tr>
  1249. <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#quat"><code>quat</code></a> class template</p></td>
  1250. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/quat.hpp&gt;</pre></div></td>
  1251. </tr>
  1252. </tbody>
  1253. </table>
  1254. <table class="tableblock frame-all grid-all stretch">
  1255. <caption class="title">Table 2. Vector header files</caption>
  1256. <colgroup>
  1257. <col style="width: 33.3333%;">
  1258. <col style="width: 66.6667%;">
  1259. </colgroup>
  1260. <tbody>
  1261. <tr>
  1262. <td class="tableblock halign-left valign-top"><p class="tableblock">Vector traits</p></td>
  1263. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/vec_traits.hpp&gt;
  1264. #include &lt;boost/qvm/vec_traits_array.hpp&gt;
  1265. #include &lt;boost/qvm/deduce_vec.hpp&gt;</pre></div></td>
  1266. </tr>
  1267. <tr>
  1268. <td class="tableblock halign-left valign-top"><p class="tableblock">Vector element access</p></td>
  1269. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/vec_access.hpp&gt;</pre></div></td>
  1270. </tr>
  1271. <tr>
  1272. <td class="tableblock halign-left valign-top"><p class="tableblock">Vector <a href="#swizzling">swizzling</a></p></td>
  1273. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/swizzle.hpp&gt;
  1274. #include &lt;boost/qvm/swizzle2.hpp&gt;
  1275. #include &lt;boost/qvm/swizzle3.hpp&gt;
  1276. #include &lt;boost/qvm/swizzle4.hpp&gt;</pre></div></td>
  1277. </tr>
  1278. <tr>
  1279. <td class="tableblock halign-left valign-top"><p class="tableblock">Vector operations</p></td>
  1280. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/vec_operations.hpp&gt;
  1281. #include &lt;boost/qvm/vec_operations2.hpp&gt;
  1282. #include &lt;boost/qvm/vec_operations3.hpp&gt;
  1283. #include &lt;boost/qvm/vec_operations4.hpp&gt;</pre></div></td>
  1284. </tr>
  1285. <tr>
  1286. <td class="tableblock halign-left valign-top"><p class="tableblock">Quaternion-vector operations</p></td>
  1287. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/quat_vec_operations.hpp&gt;</pre></div></td>
  1288. </tr>
  1289. <tr>
  1290. <td class="tableblock halign-left valign-top"><p class="tableblock">Vector-matrix operations</p></td>
  1291. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/vec_mat_operations.hpp&gt;</pre></div></td>
  1292. </tr>
  1293. <tr>
  1294. <td class="tableblock halign-left valign-top"><p class="tableblock">Vector-matrix <a href="#view_proxy">view proxies</a></p></td>
  1295. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/map_vec_mat.hpp&gt;</pre></div></td>
  1296. </tr>
  1297. <tr>
  1298. <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#vec"><code>vec</code></a> class template</p></td>
  1299. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/vec.hpp&gt;</pre></div></td>
  1300. </tr>
  1301. </tbody>
  1302. </table>
  1303. <table class="tableblock frame-all grid-all stretch">
  1304. <caption class="title">Table 3. Matrix header files</caption>
  1305. <colgroup>
  1306. <col style="width: 33.3333%;">
  1307. <col style="width: 66.6667%;">
  1308. </colgroup>
  1309. <tbody>
  1310. <tr>
  1311. <td class="tableblock halign-left valign-top"><p class="tableblock">Matrix traits</p></td>
  1312. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/mat_traits.hpp&gt;
  1313. #include &lt;boost/qvm/mat_traits_array.hpp&gt;
  1314. #include &lt;boost/qvm/deduce_mat.hpp&gt;</pre></div></td>
  1315. </tr>
  1316. <tr>
  1317. <td class="tableblock halign-left valign-top"><p class="tableblock">Matrix element access</p></td>
  1318. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/mat_access.hpp&gt;</pre></div></td>
  1319. </tr>
  1320. <tr>
  1321. <td class="tableblock halign-left valign-top"><p class="tableblock">Matrix operations</p></td>
  1322. <td class="tableblock halign-left valign-top"><div class="literal"><pre>#include &lt;boost/qvm/mat_operations.hpp&gt;
  1323. #include &lt;boost/qvm/mat_operations2.hpp&gt;
  1324. #include &lt;boost/qvm/mat_operations3.hpp&gt;
  1325. #include &lt;boost/qvm/mat_operations4.hpp&gt;</pre></div></td>
  1326. </tr>
  1327. <tr>
  1328. <td class="tableblock halign-left valign-top"><p class="tableblock">Matrix-matrix <a href="#view_proxy">view proxies</a></p></td>
  1329. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/map_mat_mat.hpp&gt;</pre></div></td>
  1330. </tr>
  1331. <tr>
  1332. <td class="tableblock halign-left valign-top"><p class="tableblock">Matrix-vector <a href="#view_proxy">view proxies</a></p></td>
  1333. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/map_mat_vec.hpp&gt;</pre></div></td>
  1334. </tr>
  1335. <tr>
  1336. <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#mat"><code>mat</code></a> class template</p></td>
  1337. <td class="tableblock halign-left valign-top"><div class="literal"><pre> #include &lt;boost/qvm/mat.hpp&gt;</pre></div></td>
  1338. </tr>
  1339. </tbody>
  1340. </table>
  1341. </div>
  1342. <div class="sect2">
  1343. <h3 id="type_traits">Type Traits System</h3>
  1344. <div class="paragraph">
  1345. <p>QVM is designed to work with user-defined quaternion, vector and matrix types, as well as user-defined scalar types. This section formally defines the way such types can be integrated.</p>
  1346. </div>
  1347. <hr>
  1348. <div class="sect3">
  1349. <h4 id="scalar_requirements">Scalar Requirements</h4>
  1350. <div class="paragraph">
  1351. <p>A valid scalar type <code>S</code> must have accessible destructor, default constructor, copy constructor and assignment operator, and must support the following operations:</p>
  1352. </div>
  1353. <div class="listingblock">
  1354. <div class="content">
  1355. <pre class="CodeRay highlight nowrap"><code data-lang="c++">S operator*( S, S );
  1356. S operator/( S, S );
  1357. S operator+( S, S );
  1358. S operator-( S, S );
  1359. S &amp; operator*=( S &amp;, S );
  1360. S &amp; operator/=( S &amp;, S );
  1361. S &amp; operator+=( S &amp;, S );
  1362. S &amp; operator-=( S &amp;, S );
  1363. bool operator==( S, S );
  1364. bool operator!=( S, S );</code></pre>
  1365. </div>
  1366. </div>
  1367. <div class="paragraph">
  1368. <p>In addition, the expression <code>S(0)</code> should construct a scalar of value zero, and <code>S(1)</code> should construct a scalar of value one, or else the <a href="#scalar_traits"><code>scalar_traits</code></a> template must be specialized appropriately.</p>
  1369. </div>
  1370. <hr>
  1371. </div>
  1372. <div class="sect3">
  1373. <h4 id="is_scalar"><code>is_scalar</code></h4>
  1374. <div class="listingblock">
  1375. <div class="title">#include &lt;boost/qvm/scalar_traits.hpp&gt;</div>
  1376. <div class="content">
  1377. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1378. template &lt;class T&gt;
  1379. struct is_scalar {
  1380. static bool const value=false;
  1381. };
  1382. template &lt;&gt; struct is_scalar&lt;char&gt; { static bool const value=true; };
  1383. template &lt;&gt; struct is_scalar&lt;signed char&gt; { static bool const value=true; };
  1384. template &lt;&gt; struct is_scalar&lt;unsigned char&gt; { static bool const value=true; };
  1385. template &lt;&gt; struct is_scalar&lt;signed short&gt; { static bool const value=true; };
  1386. template &lt;&gt; struct is_scalar&lt;unsigned short&gt; { static bool const value=true; };
  1387. template &lt;&gt; struct is_scalar&lt;signed int&gt; { static bool const value=true; };
  1388. template &lt;&gt; struct is_scalar&lt;unsigned int&gt; { static bool const value=true; };
  1389. template &lt;&gt; struct is_scalar&lt;signed long&gt; { static bool const value=true; };
  1390. template &lt;&gt; struct is_scalar&lt;unsigned long&gt; { static bool const value=true; };
  1391. template &lt;&gt; struct is_scalar&lt;float&gt; { static bool const value=true; };
  1392. template &lt;&gt; struct is_scalar&lt;double&gt; { static bool const value=true; };
  1393. template &lt;&gt; struct is_scalar&lt;long double&gt; { static bool const value=true; };
  1394. } }</code></pre>
  1395. </div>
  1396. </div>
  1397. <div class="paragraph">
  1398. <p>This template defines a compile-time boolean constant value which can be used to determine whether a type <code>T</code> is a valid scalar type. It must be specialized together with the <a href="#scalar_traits"><code>scalar_traits</code></a> template in order to introduce a user-defined scalar type to QVM. Such types must satisfy the <a href="#scalar_requirements">scalar requirements</a>.</p>
  1399. </div>
  1400. <hr>
  1401. </div>
  1402. <div class="sect3">
  1403. <h4 id="scalar_traits"><code>scalar_traits</code></h4>
  1404. <div class="listingblock">
  1405. <div class="title">#include &lt;boost/qvm/scalar_traits.hpp&gt;</div>
  1406. <div class="content">
  1407. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1408. template &lt;class Scalar&gt;
  1409. struct scalar_traits {
  1410. BOOST_QVM_INLINE_CRITICAL
  1411. static Scalar value( int v ) {
  1412. return Scalar(v);
  1413. }
  1414. };
  1415. } }</code></pre>
  1416. </div>
  1417. </div>
  1418. <div class="paragraph">
  1419. <p>This template may be specialized for user-defined scalar types to define the appropriate conversion from <code>int</code>; this is primarily used whenever QVM needs to deduce a zero or one value.</p>
  1420. </div>
  1421. <hr>
  1422. </div>
  1423. <div class="sect3">
  1424. <h4 id="deduce_scalar"><code>deduce_scalar</code></h4>
  1425. <div class="listingblock">
  1426. <div class="title">#include &lt;boost/qvm/deduce_scalar.hpp&gt;</div>
  1427. <div class="content">
  1428. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1429. template &lt;class A,class B&gt;
  1430. struct deduce_scalar
  1431. {
  1432. typedef typename impl&lt;A,B&gt;::type type;
  1433. };
  1434. } }</code></pre>
  1435. </div>
  1436. </div>
  1437. <div class="dlist">
  1438. <dl>
  1439. <dt class="hdlist1">Requirements: </dt>
  1440. <dd>
  1441. <p><code>A</code> and <code>B</code> satisfy the <a href="#scalar_requirements">scalar requirements</a>.</p>
  1442. </dd>
  1443. <dt class="hdlist1">Returns: </dt>
  1444. <dd>
  1445. <p>If <code>A</code> and <code>B</code> are the same type, <code>impl&lt;A,B&gt;::type</code> returns that type. Otherwise, <code>impl&lt;A,B&gt;::type</code> is well defined for the following types only: <code>signed</code>/<code>unsigned char</code>, <code>signed</code>/<code>unsigned short</code>, <code>signed</code>/<code>unsigned int</code>, <code>signed</code>/<code>unsigned long</code>, <code>float</code> and <code>double</code>. The deduction logic is as follows:</p>
  1446. <div class="ulist">
  1447. <ul>
  1448. <li>
  1449. <p>if either of <code>A</code> and <code>B</code> is <code>double</code>, the result is <code>double</code>;</p>
  1450. </li>
  1451. <li>
  1452. <p>else, if one of <code>A</code> or <code>B</code> is an integer type and the other is <code>float</code>, the result is <code>float</code>;</p>
  1453. </li>
  1454. <li>
  1455. <p>else, if one of <code>A</code> or <code>B</code> is a signed integer and the other type is unsigned integer, the signed type is changed to unsigned, and then the lesser of the two integers is promoted to the other.</p>
  1456. </li>
  1457. </ul>
  1458. </div>
  1459. </dd>
  1460. </dl>
  1461. </div>
  1462. <div class="admonitionblock note">
  1463. <table>
  1464. <tr>
  1465. <td class="icon">
  1466. <i class="fa icon-note" title="Note"></i>
  1467. </td>
  1468. <td class="content">
  1469. This template is used by generic binary operations that return a scalar, to deduce the return type based on the (possibly different) scalars of their arguments.
  1470. </td>
  1471. </tr>
  1472. </table>
  1473. </div>
  1474. <hr>
  1475. </div>
  1476. <div class="sect3">
  1477. <h4 id="scalar"><code>scalar</code></h4>
  1478. <div class="listingblock">
  1479. <div class="title">#include &lt;boost/qvm/scalar_traits.hpp&gt;</div>
  1480. <div class="content">
  1481. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1482. template &lt;class T&gt;
  1483. struct scalar {
  1484. typedef /*exact definition unspecified*/ type;
  1485. };
  1486. } }</code></pre>
  1487. </div>
  1488. </div>
  1489. <div class="paragraph">
  1490. <p>The expression <a href="#quat_traits"><code>quat_traits&lt;T&gt;::scalar_type</code></a> evaluates to the scalar type of the quaternion type <code>T</code> (if <a href="#is_quat"><code>is_quat&lt;T&gt;::value</code></a> is <code>true</code>).</p>
  1491. </div>
  1492. <div class="paragraph">
  1493. <p>The expression <a href="#vec_traits"><code>vec_traits&lt;T&gt;::scalar_type</code></a> evaluates to the scalar type of the vector type <code>T</code> (if <a href="#is_vec"><code>is_vec&lt;T&gt;::value</code></a> is <code>true</code>).</p>
  1494. </div>
  1495. <div class="paragraph">
  1496. <p>The expression <a href="#mat_traits"><code>mat_traits&lt;T&gt;::scalar_type</code></a> evaluates to the scalar type of the matrix type <code>T</code> (if <a href="#is_mat"><code>is_mat&lt;T&gt;::value</code></a> is <code>true</code>).</p>
  1497. </div>
  1498. <div class="paragraph">
  1499. <p>The expression <code>scalar&lt;T&gt;::type</code> is similar, except that it automatically detects whether <code>T</code> is a vector or a matrix or a quaternion type.</p>
  1500. </div>
  1501. <hr>
  1502. </div>
  1503. <div class="sect3">
  1504. <h4 id="is_quat"><code>is_quat</code></h4>
  1505. <div class="listingblock">
  1506. <div class="title">#include &lt;boost/qvm/quat_traits.hpp&gt;</div>
  1507. <div class="content">
  1508. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1509. template &lt;class T&gt;
  1510. struct is_quat {
  1511. static bool const value = false;
  1512. };
  1513. } }</code></pre>
  1514. </div>
  1515. </div>
  1516. <div class="paragraph">
  1517. <p>This type template defines a compile-time boolean constant value which can be used to determine whether a type <code>T</code> is a quaternion type. For quaternion types, the <a href="#quat_traits"><code>quat_traits</code></a> template can be used to access their elements generically, or to obtain their <code>scalar type</code>.</p>
  1518. </div>
  1519. <hr>
  1520. </div>
  1521. <div class="sect3">
  1522. <h4 id="quat_traits"><code>quat_traits</code></h4>
  1523. <div class="listingblock">
  1524. <div class="title">#include &lt;boost/qvm/quat_traits.hpp&gt;</div>
  1525. <div class="content">
  1526. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1527. template &lt;class Q&gt;
  1528. struct quat_traits {
  1529. /*main template members unspecified*/
  1530. };
  1531. /*
  1532. User-defined (possibly partial) specializations:
  1533. template &lt;&gt;
  1534. struct quat_traits&lt;Q&gt; {
  1535. typedef &lt;&lt;user-defined&gt;&gt; scalar_type;
  1536. template &lt;int I&gt;
  1537. static inline scalar_type read_element( Quaternion const &amp; q );
  1538. template &lt;int I&gt;
  1539. static inline scalar_type &amp; write_element( Quaternion &amp; q );
  1540. };
  1541. */
  1542. } }</code></pre>
  1543. </div>
  1544. </div>
  1545. <div class="paragraph">
  1546. <p>The <code>quat_traits</code> template must be specialized for (user-defined) quaternion types in order to enable quaternion operations defined in QVM headers for objects of those types.</p>
  1547. </div>
  1548. <div class="admonitionblock note">
  1549. <table>
  1550. <tr>
  1551. <td class="icon">
  1552. <i class="fa icon-note" title="Note"></i>
  1553. </td>
  1554. <td class="content">
  1555. QVM quaternion operations do not require that quaternion types are copyable.
  1556. </td>
  1557. </tr>
  1558. </table>
  1559. </div>
  1560. <div class="paragraph">
  1561. <p>The main <code>quat_traits</code> template members are not specified. Valid specializations are required to define the following members:</p>
  1562. </div>
  1563. <div class="ulist">
  1564. <ul>
  1565. <li>
  1566. <p><code>scalar_type</code>: the expression <code>quat_traits&lt;Quaternion&gt;::scalar_type</code> must be a value type which satisfies the <a href="#scalar_requirements"><code>scalar requirements</code></a>.</p>
  1567. </li>
  1568. </ul>
  1569. </div>
  1570. <div class="paragraph">
  1571. <p>In addition, valid specializations of the <code>quat_traits</code> template must define at least one of the following access functions as static members, where <code>q</code> is an object of type <code>Quaternion</code>, and <code>I</code> is compile-time integer constant:</p>
  1572. </div>
  1573. <div class="ulist">
  1574. <ul>
  1575. <li>
  1576. <p><code>read_element</code>: the expression <code>quat_traits&lt;Quaternion&gt;::read_element&lt;I&gt;(q)</code> returns either a copy of or a <code>const</code> reference to the <code>I</code>-th element of <code>q</code>.</p>
  1577. </li>
  1578. <li>
  1579. <p><code>write_element</code>: the expression <code>quat_traits&lt;Quaternion&gt;::write_element&lt;I&gt;(q)</code> returns mutable reference to the <code>I</code>-th element of <code>q</code>.</p>
  1580. </li>
  1581. </ul>
  1582. </div>
  1583. <div class="admonitionblock note">
  1584. <table>
  1585. <tr>
  1586. <td class="icon">
  1587. <i class="fa icon-note" title="Note"></i>
  1588. </td>
  1589. <td class="content">
  1590. For the quaternion <code>a + bi + cj + dk</code>, the elements are assumed to be in the following order: <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>; that is, <code>I</code>=<code>0</code>/<code>1</code>/<code>2</code>/<code>3</code> would access <code>a</code>/<code>b</code>/<code>c</code>/<code>d</code>.
  1591. </td>
  1592. </tr>
  1593. </table>
  1594. </div>
  1595. <div class="paragraph">
  1596. <p>It is illegal to call any of the above functions unless <code>is_quat&lt;Quaternion&gt;::value</code> is true. Even then, quaternion types are allowed to define only a subset of the access functions.</p>
  1597. </div>
  1598. <div class="paragraph">
  1599. <p>Below is an example of a user-defined quaternion type, and its corresponding specialization of the quat_traits template:</p>
  1600. </div>
  1601. <div class="listingblock">
  1602. <div class="content">
  1603. <pre class="CodeRay highlight nowrap"><code data-lang="c++">#include &lt;boost/qvm/quat_traits.hpp&gt;
  1604. struct fquat { float a[4]; };
  1605. namespace boost { namespace qvm {
  1606. template &lt;&gt;
  1607. struct quat_traits&lt;fquat&gt; {
  1608. typedef float scalar_type;
  1609. template &lt;int I&gt;
  1610. static inline scalar_type &amp; write_element( fquat &amp; q ) {
  1611. return q.a[I];
  1612. }
  1613. template &lt;int I&gt;
  1614. static inline scalar_type read_element( fquat const &amp; q ) {
  1615. return q.a[I];
  1616. }
  1617. };
  1618. } }</code></pre>
  1619. </div>
  1620. </div>
  1621. <div class="paragraph">
  1622. <p>Equivalently, using the <a href="#quat_traits_defaults"><code>quat_traits_defaults</code></a> template the above can be shortened to:</p>
  1623. </div>
  1624. <div class="listingblock">
  1625. <div class="content">
  1626. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1627. template &lt;&gt;
  1628. struct quat_traits&lt;fquat&gt;: quat_traits_defaults&lt;fquat,float&gt; {
  1629. template &lt;int I&gt;
  1630. static inline scalar_type &amp; write_element( fquat &amp; q ) {
  1631. return q.a[I];
  1632. }
  1633. };
  1634. } }</code></pre>
  1635. </div>
  1636. </div>
  1637. <hr>
  1638. </div>
  1639. <div class="sect3">
  1640. <h4 id="quat_traits_defaults"><code>quat_traits_defaults</code></h4>
  1641. <div class="listingblock">
  1642. <div class="title">#include &lt;boost/qvm/quat_traits_defaults.hpp&gt;</div>
  1643. <div class="content">
  1644. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1645. template &lt;class QuatType,class ScalarType&gt;
  1646. struct quat_traits_defaults {
  1647. typedef QuatType quat_type;
  1648. typedef ScalarType scalar_type;
  1649. template &lt;int I&gt;
  1650. static BOOST_QVM_INLINE_CRITICAL
  1651. scalar_type read_element( quat_type const &amp; x ) {
  1652. return quat_traits&lt;quat_type&gt;::template
  1653. write_element&lt;I&gt;(const_cast&lt;quat_type &amp;&gt;(x));
  1654. }
  1655. };
  1656. } }</code></pre>
  1657. </div>
  1658. </div>
  1659. <div class="paragraph">
  1660. <p>The <code>quat_traits_defaults</code> template is designed to be used as a public base for user-defined specializations of the <a href="#quat_traits"><code>quat_traits</code></a> template, to easily define the required members. If it is used, the only member that must be defined by the user in a <code>quat_traits</code> specialization is <code>write_element</code>; the <code>quat_traits_defaults</code> base will define <code>read_element</code>, as well as <code>scalar_type</code> automatically.</p>
  1661. </div>
  1662. <hr>
  1663. </div>
  1664. <div class="sect3">
  1665. <h4 id="deduce_quat"><code>deduce_quat</code></h4>
  1666. <div class="listingblock">
  1667. <div class="title">#include &lt;boost/qvm/deduce_quat.hpp&gt;</div>
  1668. <div class="content">
  1669. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1670. template &lt;class Q&gt;
  1671. struct deduce_quat {
  1672. typedef Q type;
  1673. };
  1674. } }</code></pre>
  1675. </div>
  1676. </div>
  1677. <div class="dlist">
  1678. <dl>
  1679. <dt class="hdlist1">Requirements: </dt>
  1680. <dd>
  1681. <div class="ulist">
  1682. <ul>
  1683. <li>
  1684. <p><code><a href="#is_quat">is_quat</a>&lt;Q&gt;::value</code> is <code>true</code>;</p>
  1685. </li>
  1686. <li>
  1687. <p><code><a href="#is_quat">is_quat</a>&lt;deduce_quat&lt;Q&gt;::type&gt;::value</code> must be <code>true</code>;</p>
  1688. </li>
  1689. <li>
  1690. <p><code>deduce_quat&lt;Q&gt;::type</code> must be copyable.</p>
  1691. </li>
  1692. </ul>
  1693. </div>
  1694. </dd>
  1695. </dl>
  1696. </div>
  1697. <div class="paragraph">
  1698. <p>This template is used by QVM whenever it needs to deduce a copyable quaternion type from a single user-supplied function parameter of quaternion type. Note that <code>Q</code> itself may be non-copyable.</p>
  1699. </div>
  1700. <div class="paragraph">
  1701. <p>The main template definition returns <code>Q</code>, which means that it is suitable only for copyable quaternion types. QVM also defines (partial) specializations for the non-copyable quaternion types it produces. Users can define other (partial) specializations for their own types.</p>
  1702. </div>
  1703. <div class="paragraph">
  1704. <p>A typical use of the <code>deduce_quat</code> template is for specifying the preferred quaternion type to be returned by the generic function template overloads in QVM depending on the type of their arguments.</p>
  1705. </div>
  1706. <hr>
  1707. </div>
  1708. <div class="sect3">
  1709. <h4 id="deduce_quat2"><code>deduce_quat2</code></h4>
  1710. <div class="listingblock">
  1711. <div class="title">#include &lt;boost/qvm/deduce_quat.hpp&gt;</div>
  1712. <div class="content">
  1713. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1714. template &lt;class A,class B&gt;
  1715. struct deduce_quat2 {
  1716. typedef /*unspecified*/ type;
  1717. };
  1718. } }</code></pre>
  1719. </div>
  1720. </div>
  1721. <div class="dlist">
  1722. <dl>
  1723. <dt class="hdlist1">Requirements: </dt>
  1724. <dd>
  1725. <div class="ulist">
  1726. <ul>
  1727. <li>
  1728. <p>Both <code><a href="#scalar">scalar</a>&lt;A&gt;::type</code> and <code>scalar&lt;B&gt;::type</code> are well defined;</p>
  1729. </li>
  1730. <li>
  1731. <p><code><a href="#is_quat">is_quat</a>&lt;A&gt;::value</code> || <code>is_quat&lt;B&gt;::value</code> is <code>true</code>;</p>
  1732. </li>
  1733. <li>
  1734. <p><code>is_quat&lt;deduce_quat2&lt;A,B&gt;::type&gt;::value</code> must be <code>true</code>;</p>
  1735. </li>
  1736. <li>
  1737. <p><code>deduce_quat2&lt;A,B&gt;::type</code> must be copyable.</p>
  1738. </li>
  1739. </ul>
  1740. </div>
  1741. </dd>
  1742. </dl>
  1743. </div>
  1744. <div class="paragraph">
  1745. <p>This template is used by QVM whenever it needs to deduce a quaternion type from the types of two user-supplied function parameters. The returned type must have accessible copy constructor (the <code>A</code> and <code>B</code> types themselves could be non-copyable, and either one of them may not be a quaternion type.)</p>
  1746. </div>
  1747. <div class="paragraph">
  1748. <p>The main template definition returns an unspecified quaternion type with <a href="#quat_traits"><code>scalar_type</code></a> obtained by <code><a href="#deduce_scalar">deduce_scalar</a>&lt;A,B&gt;::type</code>, except if <code>A</code> and <code>B</code> are the same quaternion type <code>Q</code>, in which case <code>Q</code> is returned, which is only suitable for copyable types. QVM also defines (partial) specializations for the non-copyable quaternion types it produces. Users can define other (partial) specializations for their own types.</p>
  1749. </div>
  1750. <div class="paragraph">
  1751. <p>A typical use of the <code>deduce_quat2</code> template is for specifying the preferred quaternion type to be returned by the generic function template overloads in QVM depending on the type of their arguments.</p>
  1752. </div>
  1753. <hr>
  1754. </div>
  1755. <div class="sect3">
  1756. <h4 id="is_vec"><code>is_vec</code></h4>
  1757. <div class="listingblock">
  1758. <div class="title">#include &lt;boost/qvm/vec_traits.hpp&gt;</div>
  1759. <div class="content">
  1760. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1761. template &lt;class T&gt;
  1762. struct is_vec {
  1763. static bool const value = false;
  1764. };
  1765. } }</code></pre>
  1766. </div>
  1767. </div>
  1768. <div class="paragraph">
  1769. <p>This type template defines a compile-time boolean constant value which can be used to determine whether a type <code>T</code> is a vector type. For vector types, the <a href="#vec_traits"><code>vec_traits</code></a> template can be used to access their elements generically, or to obtain their dimension and <code>scalar type</code>.</p>
  1770. </div>
  1771. <hr>
  1772. </div>
  1773. <div class="sect3">
  1774. <h4 id="vec_traits"><code>vec_traits</code></h4>
  1775. <div class="listingblock">
  1776. <div class="title">#include &lt;boost/qvm/vec_traits.hpp&gt;</div>
  1777. <div class="content">
  1778. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1779. template &lt;class V&gt;
  1780. struct vec_traits {
  1781. /*main template members unspecified*/
  1782. };
  1783. /*
  1784. User-defined (possibly partial) specializations:
  1785. template &lt;&gt;
  1786. struct vec_traits&lt;V&gt; {
  1787. static int const dim = &lt;&lt;user-defined&gt;&gt;;
  1788. typedef &lt;&lt;user-defined&gt;&gt; scalar_type;
  1789. template &lt;int I&gt;
  1790. static inline scalar_type read_element( Vector const &amp; v );
  1791. template &lt;int I&gt;
  1792. static inline scalar_type &amp; write_element( Vector &amp; v );
  1793. static inline scalar_type read_element_idx( int i, Vector const &amp; v );
  1794. static inline scalar_type &amp; write_element_idx( int i, Vector &amp; v );
  1795. };
  1796. */
  1797. } }</code></pre>
  1798. </div>
  1799. </div>
  1800. <div class="paragraph">
  1801. <p>The <code>vec_traits</code> template must be specialized for (user-defined) vector types in order to enable vector and matrix operations defined in QVM headers for objects of those types.</p>
  1802. </div>
  1803. <div class="admonitionblock note">
  1804. <table>
  1805. <tr>
  1806. <td class="icon">
  1807. <i class="fa icon-note" title="Note"></i>
  1808. </td>
  1809. <td class="content">
  1810. QVM vector operations do not require that vector types are copyable.
  1811. </td>
  1812. </tr>
  1813. </table>
  1814. </div>
  1815. <div class="paragraph">
  1816. <p>The main <code>vec_traits</code> template members are not specified. Valid specializations are required to define the following members:</p>
  1817. </div>
  1818. <div class="ulist">
  1819. <ul>
  1820. <li>
  1821. <p><code>dim</code>: the expression <code>vec_traits&lt;Vector&gt;::dim</code> must evaluate to a compile-time integer constant greater than 0 that specifies the vector size.</p>
  1822. </li>
  1823. <li>
  1824. <p><code>scalar_type</code>: the expression <code>vec_traits&lt;Vector&gt;::scalar_type</code> must be a value type which satisfies the <a href="#scalar_requirements"><code>scalar requirements</code></a>.</p>
  1825. </li>
  1826. </ul>
  1827. </div>
  1828. <div class="paragraph">
  1829. <p>In addition, valid specializations of the <code>vec_traits</code> template may define the following access functions as static members, where <code>v</code> is an object of type <code>Vector</code>, <code>I</code> is a compile-time integer constant, and <code>i</code> is a variable of type <code>int</code>:</p>
  1830. </div>
  1831. <div class="ulist">
  1832. <ul>
  1833. <li>
  1834. <p><code>read_element</code>: the expression <code>vec_traits&lt;Vector&gt;::read_element&lt;I&gt;(v)</code> returns either a copy of or a const reference to the <code>I</code>-th element of <code>v</code>.</p>
  1835. </li>
  1836. <li>
  1837. <p><code>write_element</code>: the expression <code>vec_traits&lt;Vector&gt;::write_element&lt;I&gt;(v)</code> returns mutable reference to the <code>I</code>-th element of <code>v</code>.</p>
  1838. </li>
  1839. <li>
  1840. <p><code>read_element_idx</code>: the expression <code>vec_traits&lt;Vector&gt;::read_element_idx(i,v)</code> returns either a copy of or a <code>const</code> reference to the <code>i</code>-th element of <code>v</code>.</p>
  1841. </li>
  1842. <li>
  1843. <p><code>write_element_idx</code>: the expression <code>vec_traits&lt;Vector&gt;::write_element_idx(i,v)</code> returns mutable reference to the <code>i</code>-th element of <code>v</code>.</p>
  1844. </li>
  1845. </ul>
  1846. </div>
  1847. <div class="paragraph">
  1848. <p>It is illegal to call any of the above functions unless <code>is_vec&lt;Vector&gt;::value</code> is true. Even then, vector types are allowed to define only a subset of the access functions. The general requirements are:</p>
  1849. </div>
  1850. <div class="ulist">
  1851. <ul>
  1852. <li>
  1853. <p>At least one of <code>read_element</code> or <code>write_element</code> must be defined;</p>
  1854. </li>
  1855. <li>
  1856. <p>If <code>read_element_idx</code> is defined, <code>read_element</code> must also be defined;</p>
  1857. </li>
  1858. <li>
  1859. <p>If <code>write_element_idx</code> is defined, <code>write_element</code> must also be defined.</p>
  1860. </li>
  1861. </ul>
  1862. </div>
  1863. <div class="paragraph">
  1864. <p>Below is an example of a user-defined 3D vector type, and its corresponding specialization of the <code>vec_traits</code> template:</p>
  1865. </div>
  1866. <div class="listingblock">
  1867. <div class="content">
  1868. <pre class="CodeRay highlight nowrap"><code data-lang="c++">#include &lt;boost/qvm/vec_traits.hpp&gt;
  1869. struct float3 { float a[3]; };
  1870. namespace boost { namespace qvm {
  1871. template &lt;&gt;
  1872. struct vec_traits&lt;float3&gt; {
  1873. static int const dim=3;
  1874. typedef float scalar_type;
  1875. template &lt;int I&gt;
  1876. static inline scalar_type &amp; write_element( float3 &amp; v ) {
  1877. return v.a[I];
  1878. }
  1879. template &lt;int I&gt;
  1880. static inline scalar_type read_element( float3 const &amp; v ) {
  1881. return v.a[I];
  1882. }
  1883. static inline scalar_type &amp; write_element_idx( int i, float3 &amp; v ) {
  1884. return v.a[i];
  1885. } //optional
  1886. static inline scalar_type read_element_idx( int i, float3 const &amp; v ) {
  1887. return v.a[i];
  1888. } //optional
  1889. };
  1890. } }</code></pre>
  1891. </div>
  1892. </div>
  1893. <div class="paragraph">
  1894. <p>Equivalently, using the <a href="#vec_traits_defaults"><code>vec_traits_defaults</code></a> template the above can be shortened to:</p>
  1895. </div>
  1896. <div class="listingblock">
  1897. <div class="content">
  1898. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1899. template &lt;&gt;
  1900. struct vec_traits&lt;float3&gt;: vec_traits_defaults&lt;float3,float,3&gt;
  1901. {
  1902. template &lt;int I&gt;
  1903. static inline scalar_type &amp; write_element( float3 &amp; v ) {
  1904. return v.a[I];
  1905. }
  1906. static inline scalar_type &amp; write_element_idx( int i, float3 &amp; v ) {
  1907. return v.a[i];
  1908. } //optional
  1909. };
  1910. } }</code></pre>
  1911. </div>
  1912. </div>
  1913. <hr>
  1914. </div>
  1915. <div class="sect3">
  1916. <h4 id="vec_traits_defaults"><code>vec_traits_defaults</code></h4>
  1917. <div class="listingblock">
  1918. <div class="title">#include &lt;boost/qvm/vec_traits_defaults.hpp&gt;</div>
  1919. <div class="content">
  1920. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1921. template &lt;class VecType,class ScalarType,int Dim&gt;
  1922. struct vec_traits_defaults {
  1923. typedef VecType vec_type;
  1924. typedef ScalarType scalar_type;
  1925. static int const dim=Dim;
  1926. template &lt;int I&gt;
  1927. static BOOST_QVM_INLINE_CRITICAL
  1928. scalar_type write_element( vec_type const &amp; x ) {
  1929. return vec_traits&lt;vec_type&gt;::template write_element&lt;I&gt;(const_cast&lt;vec_type &amp;&gt;(x));
  1930. }
  1931. static BOOST_QVM_INLINE_CRITICAL
  1932. scalar_type read_element_idx( int i, vec_type const &amp; x ) {
  1933. return vec_traits&lt;vec_type&gt;::write_element_idx(i,const_cast&lt;vec_type &amp;&gt;(x));
  1934. }
  1935. protected:
  1936. static BOOST_QVM_INLINE_TRIVIAL
  1937. scalar_type &amp; write_element_idx( int i, vec_type &amp; m ) {
  1938. /* unspecified */
  1939. }
  1940. };
  1941. } }</code></pre>
  1942. </div>
  1943. </div>
  1944. <div class="paragraph">
  1945. <p>The <code>vec_traits_defaults</code> template is designed to be used as a public base for user-defined specializations of the <a href="#vec_traits"><code>vec_traits</code></a> template, to easily define the required members. If it is used, the only member that must be defined by the user in a <code>vec_traits</code> specialization is <code>write_element</code>; the <code>vec_traits_defaults</code> base will define <code>read_element</code>, as well as <code>scalar_type</code> and <code>dim</code> automatically.</p>
  1946. </div>
  1947. <div class="paragraph">
  1948. <p>Optionally, the user may also define <code>write_element_idx</code>, in which case the <code>vec_traits_defaults</code> base will provide a suitable <code>read_element_idx</code> definition automatically. If not, <code>vec_traits_defaults</code> defines a protected implementation of <code>write_element_idx</code> which may be made publicly available by the deriving <code>vec_traits</code> specialization in case the vector type for which it is being specialized can not be indexed efficiently. This <code>write_element_idx</code> function is less efficient (using meta-programming), implemented in terms of the required user-defined <code>write_element</code>.</p>
  1949. </div>
  1950. <hr>
  1951. </div>
  1952. <div class="sect3">
  1953. <h4 id="deduce_vec"><code>deduce_vec</code></h4>
  1954. <div class="listingblock">
  1955. <div class="title">#include &lt;boost/qvm/deduce_vec.hpp&gt;</div>
  1956. <div class="content">
  1957. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  1958. template &lt;class V, int Dim=vec_traits&lt;Vector&gt;::dim&gt;
  1959. struct deduce_vec {
  1960. typedef /*unspecified*/ type;
  1961. };
  1962. } }</code></pre>
  1963. </div>
  1964. </div>
  1965. <div class="dlist">
  1966. <dl>
  1967. <dt class="hdlist1">Requirements: </dt>
  1968. <dd>
  1969. <div class="ulist">
  1970. <ul>
  1971. <li>
  1972. <p><code><a href="#is_vec">is_vec</a>&lt;V&gt;::value</code> is <code>true</code>;</p>
  1973. </li>
  1974. <li>
  1975. <p><code>is_vec&lt;deduce_vec&lt;V&gt;::type&gt;::value</code> must be <code>true</code>;</p>
  1976. </li>
  1977. <li>
  1978. <p><code>deduce_vec&lt;V&gt;::type</code> must be copyable;</p>
  1979. </li>
  1980. <li>
  1981. <p><code>vec_traits&lt;deduce_vec&lt;V&gt;::type&gt;::dim==Dim</code>.</p>
  1982. </li>
  1983. </ul>
  1984. </div>
  1985. </dd>
  1986. </dl>
  1987. </div>
  1988. <div class="paragraph">
  1989. <p>This template is used by QVM whenever it needs to deduce a copyable vector type of certain dimension from a single user-supplied function parameter of vector type. The returned type must have accessible copy constructor. Note that <code>V</code> may be non-copyable.</p>
  1990. </div>
  1991. <div class="paragraph">
  1992. <p>The main template definition returns an unspecified copyable vector type of size <code>Dim</code>, except if <code><a href="#vec_traits">vec_traits</a>&lt;V&gt;::dim==Dim</code>, in which case it returns <code>V</code>, which is suitable only if <code>V</code> is a copyable type. QVM also defines (partial) specializations for the non-copyable vector types it produces. Users can define other (partial) specializations for their own types.</p>
  1993. </div>
  1994. <div class="paragraph">
  1995. <p>A typical use of the <code>deduce_vec</code> template is for specifying the preferred vector type to be returned by the generic function template overloads in QVM depending on the type of their arguments.</p>
  1996. </div>
  1997. <hr>
  1998. </div>
  1999. <div class="sect3">
  2000. <h4 id="deduce_vec2"><code>deduce_vec2</code></h4>
  2001. <div class="listingblock">
  2002. <div class="title">#include &lt;boost/qvm/deduce_vec.hpp&gt;</div>
  2003. <div class="content">
  2004. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2005. template &lt;class A,class B,int Dim&gt;
  2006. struct deduce_vec2 {
  2007. typedef /*unspecified*/ type;
  2008. };
  2009. } }</code></pre>
  2010. </div>
  2011. </div>
  2012. <div class="dlist">
  2013. <dl>
  2014. <dt class="hdlist1">Requirements: </dt>
  2015. <dd>
  2016. <div class="ulist">
  2017. <ul>
  2018. <li>
  2019. <p>Both <code><a href="#scalar">scalar</a>&lt;A&gt;::type</code> and <code>scalar&lt;B&gt;::type</code> are well defined;</p>
  2020. </li>
  2021. <li>
  2022. <p><code><a href="#is_vec">is_vec</a>&lt;A&gt;::value || is_vec&lt;B&gt;::value</code> is <code>true</code>;</p>
  2023. </li>
  2024. <li>
  2025. <p><code>is_vec&lt;deduce_vec2&lt;A,B&gt;::type&gt;::value</code> must be <code>true</code>;</p>
  2026. </li>
  2027. <li>
  2028. <p><code>deduce_vec2&lt;A,B&gt;::type</code> must be copyable;</p>
  2029. </li>
  2030. <li>
  2031. <p><code>vec_traits&lt;deduce_vec2&lt;A,B&gt;::type&gt;::dim==Dim</code>.</p>
  2032. </li>
  2033. </ul>
  2034. </div>
  2035. </dd>
  2036. </dl>
  2037. </div>
  2038. <div class="paragraph">
  2039. <p>This template is used by QVM whenever it needs to deduce a vector type of certain dimension from the types of two user-supplied function parameters. The returned type must have accessible copy constructor (the <code>A</code> and <code>B</code> types themselves could be non-copyable, and either one of them may not be a vector type.)</p>
  2040. </div>
  2041. <div class="paragraph">
  2042. <p>The main template definition returns an unspecified vector type of the requested dimension with <a href="#vec_traits"><code>scalar_type</code></a> obtained by <code><a href="#deduce_scalar">deduce_scalar</a>&lt;A,B&gt;::type</code>, except if <code>A</code> and <code>B</code> are the same vector type <code>V</code> of dimension <code>Dim</code>, in which case <code>V</code> is returned, which is only suitable for copyable types. QVM also defines (partial) specializations for the non-copyable vector types it produces. Users can define other (partial) specializations for their own types.</p>
  2043. </div>
  2044. <div class="paragraph">
  2045. <p>A typical use of the <code>deduce_vec2</code> template is for specifying the preferred vector type to be returned by the generic function template overloads in QVM depending on the type of their arguments.</p>
  2046. </div>
  2047. <hr>
  2048. </div>
  2049. <div class="sect3">
  2050. <h4 id="is_mat"><code>is_mat</code></h4>
  2051. <div class="listingblock">
  2052. <div class="title">#include &lt;boost/qvm/mat_traits.hpp&gt;</div>
  2053. <div class="content">
  2054. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2055. template &lt;class T&gt;
  2056. struct is_mat {
  2057. static bool const value = false;
  2058. };
  2059. } }</code></pre>
  2060. </div>
  2061. </div>
  2062. <div class="paragraph">
  2063. <p>This type template defines a compile-time boolean constant value which can be used to determine whether a type <code>T</code> is a matrix type. For matrix types, the <a href="#mat_traits"><code>mat_traits</code></a> template can be used to access their elements generically, or to obtain their dimensions and scalar type.</p>
  2064. </div>
  2065. <hr>
  2066. </div>
  2067. <div class="sect3">
  2068. <h4 id="mat_traits"><code>mat_traits</code></h4>
  2069. <div class="listingblock">
  2070. <div class="title">#include &lt;boost/qvm/mat_traits.hpp&gt;</div>
  2071. <div class="content">
  2072. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2073. template &lt;class M&gt;
  2074. struct mat_traits {
  2075. /*main template members unspecified*/
  2076. };
  2077. /*
  2078. User-defined (possibly partial) specializations:
  2079. template &lt;&gt;
  2080. struct mat_traits&lt;M&gt; {
  2081. static int const rows = &lt;&lt;user-defined&gt;&gt;;
  2082. static int const cols = &lt;&lt;user-defined&gt;&gt;;
  2083. typedef &lt;&lt;user-defined&gt;&gt; scalar_type;
  2084. template &lt;int R,int C&gt;
  2085. static inline scalar_type read_element( Matrix const &amp; m );
  2086. template &lt;int R,int C&gt;
  2087. static inline scalar_type &amp; write_element( Matrix &amp; m );
  2088. static inline scalar_typeread_element_idx( int r, int c, Matrix const &amp; m );
  2089. static inline scalar_type &amp; write_element_idx( int r, int c, Matrix &amp; m );
  2090. };
  2091. */
  2092. } }</code></pre>
  2093. </div>
  2094. </div>
  2095. <div class="paragraph">
  2096. <p>The <code>mat_traits</code> template must be specialized for (user-defined) matrix types in order to enable vector and matrix operations defined in QVM headers for objects of those types.</p>
  2097. </div>
  2098. <div class="admonitionblock note">
  2099. <table>
  2100. <tr>
  2101. <td class="icon">
  2102. <i class="fa icon-note" title="Note"></i>
  2103. </td>
  2104. <td class="content">
  2105. The matrix operations defined by QVM do not require matrix types to be copyable.
  2106. </td>
  2107. </tr>
  2108. </table>
  2109. </div>
  2110. <div class="paragraph">
  2111. <p>The main <code>mat_traits</code> template members are not specified. Valid specializations are required to define the following members:</p>
  2112. </div>
  2113. <div class="ulist">
  2114. <ul>
  2115. <li>
  2116. <p><code>rows</code>: the expression <code>mat_traits&lt;Matrix&gt;::rows</code> must evaluate to a compile-time integer constant greater than 0 that specifies the number of rows in a matrix.</p>
  2117. </li>
  2118. <li>
  2119. <p><code>cols</code> must evaluate to a compile-time integer constant greater than 0 that specifies the number of columns in a matrix.</p>
  2120. </li>
  2121. <li>
  2122. <p><code>scalar_type</code>: the expression <code>mat_traits&lt;Matrix&gt;::scalar_type</code> must be a value type which satisfies the scalar requirements.</p>
  2123. </li>
  2124. </ul>
  2125. </div>
  2126. <div class="paragraph">
  2127. <p>In addition, valid specializations of the <code>mat_traits</code> template may define the following access functions as static members, where <code>m</code> is an object of type <code>Matrix</code>, <code>R</code> and <code>C</code> are compile-time integer constants, and <code>r</code> and <code>c</code> are variables of type <code>int</code>:</p>
  2128. </div>
  2129. <div class="ulist">
  2130. <ul>
  2131. <li>
  2132. <p><code>read_element</code>: the expression <code>mat_traits&lt;Matrix&gt;::read_element&lt;R,C&gt;(m)</code> returns either a copy of or a const reference to the element at row <code>R</code> and column <code>C</code> of <code>m</code>.</p>
  2133. </li>
  2134. <li>
  2135. <p><code>write_element</code>: the expression <code>mat_traits&lt;Matrix&gt;::write_element&lt;R,C&gt;(m)</code> returns mutable reference to the element at row <code>R</code> and column <code>C</code> of <code>m</code>.</p>
  2136. </li>
  2137. <li>
  2138. <p><code>read_element_idx</code>: the expression <code>mat_traits&lt;Matrix&gt;::read_element_idx(r,c,m)</code> returns either a copy of or a const reference to the element at row <code>r</code> and column <code>c</code> of <code>m</code>.</p>
  2139. </li>
  2140. <li>
  2141. <p><code>write_element_idx</code>: the expression <code>mat_traits&lt;Matrix&gt;::write_element_idx(r,c,m)</code> returns mutable reference to the element at row <code>r</code> and column <code>c</code> of <code>m</code>.</p>
  2142. </li>
  2143. </ul>
  2144. </div>
  2145. <div class="paragraph">
  2146. <p>It is illegal to call any of the above functions unless <code>is_mat&lt;Matrix&gt;::value</code> is true. Even then, matrix types are allowed to define only a subset of the access functions. The general requirements are:</p>
  2147. </div>
  2148. <div class="ulist">
  2149. <ul>
  2150. <li>
  2151. <p>At least one of <code>read_element</code> or <code>write_element</code> must be defined;</p>
  2152. </li>
  2153. <li>
  2154. <p>If <code>read_element_idx</code> is defined, <code>read_element</code> must also be defined;</p>
  2155. </li>
  2156. <li>
  2157. <p>If <code>write_element_idx</code> is defined, <code>write_element</code> must also be defined.</p>
  2158. </li>
  2159. </ul>
  2160. </div>
  2161. <div class="paragraph">
  2162. <p>Below is an example of a user-defined 3x3 matrix type, and its corresponding specialization of the <code>mat_traits</code> template:</p>
  2163. </div>
  2164. <div class="listingblock">
  2165. <div class="content">
  2166. <pre class="CodeRay highlight nowrap"><code data-lang="c++">#include &lt;boost/qvm/mat_traits.hpp&gt;
  2167. struct float33 { float a[3][3]; };
  2168. namespace boost { namespace qvm {
  2169. template &lt;&gt;
  2170. struct mat_traits&lt;float33&gt; {
  2171. static int const rows=3;
  2172. static int const cols=3;
  2173. typedef float scalar_type;
  2174. template &lt;int R,int C&gt;
  2175. static inline scalar_type &amp; write_element( float33 &amp; m ) {
  2176. return m.a[R][C];
  2177. }
  2178. template &lt;int R,int C&gt;
  2179. static inline scalar_type read_element( float33 const &amp; m ) {
  2180. return m.a[R][C];
  2181. }
  2182. static inline scalar_type &amp; write_element_idx( int r, int c, float33 &amp; m ) {
  2183. return m.a[r][c];
  2184. }
  2185. static inline scalar_type read_element_idx( int r, int c, float33 const &amp; m ) {
  2186. return m.a[r][c];
  2187. }
  2188. };
  2189. } }</code></pre>
  2190. </div>
  2191. </div>
  2192. <div class="paragraph">
  2193. <p>Equivalently, we could use the &lt;&lt;mat_traits_defaults,<code>mat_traits_defaults</code> template to shorten the above to:</p>
  2194. </div>
  2195. <div class="listingblock">
  2196. <div class="content">
  2197. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2198. template &lt;&gt;
  2199. struct mat_traits&lt;float33&gt;: mat_traits_defaults&lt;float33,float,3,3&gt; {
  2200. template &lt;int R,int C&gt; static inline scalar_type &amp; write_element( float33 &amp; m ) { return m.a[R][C]; }
  2201. static inline scalar_type &amp; write_element_idx( int r, int c, float33 &amp; m ) {
  2202. return m.a[r][c];
  2203. }
  2204. };
  2205. } }</code></pre>
  2206. </div>
  2207. </div>
  2208. <hr>
  2209. </div>
  2210. <div class="sect3">
  2211. <h4 id="mat_traits_defaults"><code>mat_traits_defaults</code></h4>
  2212. <div class="listingblock">
  2213. <div class="title">#include &lt;boost/qvm/mat_traits_defaults.hpp&gt;</div>
  2214. <div class="content">
  2215. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2216. template &lt;class MatType,class ScalarType,int Rows,int Cols&gt;
  2217. struct mat_traits_defaults
  2218. {
  2219. typedef MatType mat_type;
  2220. typedef ScalarType scalar_type;
  2221. static int const rows=Rows;
  2222. static int const cols=Cols;
  2223. template &lt;int Row,int Col&gt;
  2224. static BOOST_QVM_INLINE_CRITICAL
  2225. scalar_type write_element( mat_type const &amp; x ) {
  2226. return mat_traits&lt;mat_type&gt;::template write_element&lt;Row,Col&gt;(const_cast&lt;mat_type &amp;&gt;(x));
  2227. }
  2228. static BOOST_QVM_INLINE_CRITICAL
  2229. scalar_type read_element_idx( int r, int c, mat_type const &amp; x ) {
  2230. return mat_traits&lt;mat_type&gt;::write_element_idx(r,c,const_cast&lt;mat_type &amp;&gt;(x));
  2231. }
  2232. protected:
  2233. static BOOST_QVM_INLINE_TRIVIAL
  2234. scalar_type &amp; write_element_idx( int r, int c, mat_type &amp; m ) {
  2235. /* unspecified */
  2236. }
  2237. };
  2238. } }</code></pre>
  2239. </div>
  2240. </div>
  2241. <div class="paragraph">
  2242. <p>The <code>mat_traits_defaults</code> template is designed to be used as a public base for user-defined specializations of the <a href="#mat_traits"><code>mat_traits</code></a> template, to easily define the required members. If it is used, the only member that must be defined by the user in a <code>mat_traits</code> specialization is <code>write_element</code>; the <code>mat_traits_defaults</code> base will define <code>read_element</code>, as well as <code>scalar_type</code>, <code>rows</code> and <code>cols</code> automatically.</p>
  2243. </div>
  2244. <div class="paragraph">
  2245. <p>Optionally, the user may also define <code>write_element_idx</code>, in which case the <code>mat_traits_defaults</code> base will provide a suitable <code>read_element_idx</code> definition automatically. Otherwise, <code>mat_traits_defaults</code> defines a protected implementation of <code>write_element_idx</code> which may be made publicly available by the deriving <code>mat_traits</code> specialization in case the matrix type for which it is being specialized can not be indexed efficiently. This <code>write_element_idx</code> function is less efficient (using meta-programming), implemented in terms of the required user-defined <code>write_element</code>.</p>
  2246. </div>
  2247. <hr>
  2248. </div>
  2249. <div class="sect3">
  2250. <h4 id="deduce_mat"><code>deduce_mat</code></h4>
  2251. <div class="listingblock">
  2252. <div class="title">#include &lt;boost/qvm/deduce_mat.hpp&gt;</div>
  2253. <div class="content">
  2254. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2255. template &lt;
  2256. class M,
  2257. int Rows=mat_traits&lt;Matrix&gt;::rows,
  2258. int Cols=mat_traits&lt;Matrix&gt;::cols&gt;
  2259. struct deduce_mat {
  2260. typedef /*unspecified*/ type;
  2261. };
  2262. } }</code></pre>
  2263. </div>
  2264. </div>
  2265. <div class="dlist">
  2266. <dl>
  2267. <dt class="hdlist1">Requirements: </dt>
  2268. <dd>
  2269. <div class="ulist">
  2270. <ul>
  2271. <li>
  2272. <p><code><a href="#is_mat">is_mat</a>&lt;M&gt;::value</code> is <code>true</code>;</p>
  2273. </li>
  2274. <li>
  2275. <p><code>is_mat&lt;deduce_mat&lt;M&gt;::type&gt;::value</code> must be <code>true</code>;</p>
  2276. </li>
  2277. <li>
  2278. <p><code>deduce_mat&lt;M&gt;::type</code> must be copyable;</p>
  2279. </li>
  2280. <li>
  2281. <p><code><a href="#mat_traits">mat_traits</a>&lt;deduce_mat&lt;M&gt;::type&gt;::rows==Rows</code>;</p>
  2282. </li>
  2283. <li>
  2284. <p><code>mat_traits&lt;deduce_mat&lt;M&gt;::type&gt;::cols==Cols</code>.</p>
  2285. </li>
  2286. </ul>
  2287. </div>
  2288. </dd>
  2289. </dl>
  2290. </div>
  2291. <div class="paragraph">
  2292. <p>This template is used by QVM whenever it needs to deduce a copyable matrix type of certain dimensions from a single user-supplied function parameter of matrix type. The returned type must have accessible copy constructor. Note that M itself may be non-copyable.</p>
  2293. </div>
  2294. <div class="paragraph">
  2295. <p>The main template definition returns an unspecified copyable matrix type of size <code>Rows</code> x <code>Cols</code>, except if <code><a href="#mat_traits">mat_traits</a>&lt;M&gt;::rows==Rows &amp;&amp; mat_traits&lt;M&gt;::cols==Cols</code>, in which case it returns <code>M</code>, which is suitable only if <code>M</code> is a copyable type. QVM also defines (partial) specializations for the non-copyable matrix types it produces. Users can define other (partial) specializations for their own types.</p>
  2296. </div>
  2297. <div class="paragraph">
  2298. <p>A typical use of the deduce_mat template is for specifying the preferred matrix type to be returned by the generic function template overloads in QVM depending on the type of their arguments.</p>
  2299. </div>
  2300. <hr>
  2301. </div>
  2302. <div class="sect3">
  2303. <h4 id="deduce_mat2"><code>deduce_mat2</code></h4>
  2304. <div class="listingblock">
  2305. <div class="title">#include &lt;boost/qvm/deduce_mat.hpp&gt;</div>
  2306. <div class="content">
  2307. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2308. template &lt;class A,class B,int Rows,int Cols&gt;
  2309. struct deduce_mat2 {
  2310. typedef /*unspecified*/ type;
  2311. };
  2312. } }</code></pre>
  2313. </div>
  2314. </div>
  2315. <div class="dlist">
  2316. <dl>
  2317. <dt class="hdlist1">Requirements: </dt>
  2318. <dd>
  2319. <div class="ulist">
  2320. <ul>
  2321. <li>
  2322. <p>Both <code><a href="#scalar">scalar</a>&lt;A&gt;::type</code> and <code>scalar&lt;B&gt;::type</code> are well defined;</p>
  2323. </li>
  2324. <li>
  2325. <p><code><a href="#is_mat">is_mat</a>&lt;A&gt;::value || is_mat&lt;B&gt;::value</code> is <code>true</code>;</p>
  2326. </li>
  2327. <li>
  2328. <p><code>is_mat&lt;deduce_mat2&lt;A,B&gt;::type&gt;::value</code> must be <code>true</code>;</p>
  2329. </li>
  2330. <li>
  2331. <p><code>deduce_mat2&lt;A,B&gt;::type</code> must be copyable;</p>
  2332. </li>
  2333. <li>
  2334. <p><code><a href="#mat_traits">mat_traits</a>&lt;deduce_mat2&lt;A,B&gt;::type&gt;::rows==Rows</code>;</p>
  2335. </li>
  2336. <li>
  2337. <p><code>mat_traits&lt;deduce_mat2&lt;A,B&gt;::type&gt;::cols==Cols</code>.</p>
  2338. </li>
  2339. </ul>
  2340. </div>
  2341. </dd>
  2342. </dl>
  2343. </div>
  2344. <div class="paragraph">
  2345. <p>This template is used by QVM whenever it needs to deduce a matrix type of certain dimensions from the types of two user-supplied function parameters. The returned type must have accessible copy constructor (the <code>A</code> and <code>B</code> types themselves could be non-copyable, and either one of them may be a non-matrix type.)</p>
  2346. </div>
  2347. <div class="paragraph">
  2348. <p>The main template definition returns an unspecified matrix type of the requested dimensions with <a href="#mat_traits"><code>scalar_type</code></a> obtained by <code><a href="#deduce_scalar">deduce_scalar</a>&lt;A,B&gt;::type</code>, except if <code>A</code> and <code>B</code> are the same matrix type <code>M</code> of dimensions <code>Rows</code> x <code>Cols</code>, in which case <code>M</code> is returned, which is only suitable for copyable types. QVM also defines (partial) specializations for the non-copyable matrix types it produces. Users can define other (partial) specializations for their own types.</p>
  2349. </div>
  2350. <div class="paragraph">
  2351. <p>A typical use of the <code>deduce_mat2</code> template is for specifying the preferred matrix type to be returned by the generic function template overloads in QVM depending on the type of their arguments.</p>
  2352. </div>
  2353. <hr>
  2354. </div>
  2355. </div>
  2356. <div class="sect2">
  2357. <h3 id="_built_in_quaternion_vector_and_matrix_types">Built-in Quaternion, Vector and Matrix Types</h3>
  2358. <div class="paragraph">
  2359. <p>QVM defines several class templates (together with appropriate specializations of <a href="#quat_traits"><code>quat_traits</code></a>, <a href="#vec_traits"><code>vec_traits</code></a> and <a href="#mat_traits"><code>mat_traits</code></a> templates) which can be used as generic quaternion, vector and matrix types. Using these types directly wouldn&#8217;t be typical though, the main design goal of QVM is to allow users to plug in their own quaternion, vector and matrix types.</p>
  2360. </div>
  2361. <div class="sect3">
  2362. <h4 id="quat"><code>quat</code></h4>
  2363. <div class="listingblock">
  2364. <div class="title">#include &lt;boost/qvm/quat.hpp&gt;</div>
  2365. <div class="content">
  2366. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2367. template &lt;class T&gt;
  2368. struct quat {
  2369. T a[4];
  2370. template &lt;class R&gt;
  2371. operator R() const {
  2372. R r;
  2373. assign(r,*this);
  2374. return r;
  2375. }
  2376. };
  2377. template &lt;class Quaternion&gt;
  2378. struct quat_traits;
  2379. template &lt;class T&gt;
  2380. struct quat_traits&lt; quat&lt;T&gt; &gt; {
  2381. typedef T scalar_type;
  2382. template &lt;int I&gt;
  2383. static scalar_type read_element( quat&lt;T&gt; const &amp; x ) {
  2384. return x.a[I];
  2385. }
  2386. template &lt;int I&gt;
  2387. static scalar_type &amp; write_element( quat&lt;T&gt; &amp; x ) {
  2388. return x.a[I];
  2389. }
  2390. };
  2391. } }</code></pre>
  2392. </div>
  2393. </div>
  2394. <div class="paragraph">
  2395. <p>This is a simple quaternion type. It converts to any other quaternion type.</p>
  2396. </div>
  2397. <div class="paragraph">
  2398. <p>The partial specialization of the <a href="#quat_traits"><code>quat_traits</code></a> template makes the <code>quat</code> template compatible with the generic operations defined by QVM.</p>
  2399. </div>
  2400. <hr>
  2401. </div>
  2402. <div class="sect3">
  2403. <h4 id="vec"><code>vec</code></h4>
  2404. <div class="listingblock">
  2405. <div class="title">#include &lt;boost/qvm/vec.hpp&gt;</div>
  2406. <div class="content">
  2407. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2408. template &lt;class T,int Dim&gt;
  2409. struct vec {
  2410. T a[Dim];
  2411. template &lt;class R&gt;
  2412. operator R() const {
  2413. R r;
  2414. assign(r,*this);
  2415. return r;
  2416. }
  2417. };
  2418. template &lt;class Vector&gt;
  2419. struct vec_traits;
  2420. template &lt;class T,int Dim&gt;
  2421. struct vec_traits&lt; vec&lt;T,Dim&gt; &gt; {
  2422. typedef T scalar_type;
  2423. static int const dim=Dim;
  2424. template &lt;int I&gt;
  2425. static scalar_type read_element( vec&lt;T,Dim&gt; const &amp; x ) {
  2426. return x.a[I];
  2427. }
  2428. template &lt;int I&gt;
  2429. static scalar_type &amp; write_element( vec&lt;T,Dim&gt; &amp; x ) {
  2430. return x.a[I];
  2431. }
  2432. static scalar_type read_element_idx( int i, vec&lt;T,Dim&gt; const &amp; x ) {
  2433. return x.a[i];
  2434. }
  2435. static scalar_type &amp; write_element_idx( int i, vec&lt;T,Dim&gt; &amp; x ) {
  2436. return x.a[i];
  2437. }
  2438. };
  2439. } }</code></pre>
  2440. </div>
  2441. </div>
  2442. <div class="paragraph">
  2443. <p>This is a simple vector type. It converts to any other vector type of compatible size.</p>
  2444. </div>
  2445. <div class="paragraph">
  2446. <p>The partial specialization of the <a href="#vec_traits"><code>vec_traits</code></a> template makes the <code>vec</code> template compatible with the generic operations defined by QVM.</p>
  2447. </div>
  2448. <hr>
  2449. </div>
  2450. <div class="sect3">
  2451. <h4 id="mat"><code>mat</code></h4>
  2452. <div class="listingblock">
  2453. <div class="title">#include &lt;boost/qvm/mat.hpp&gt;</div>
  2454. <div class="content">
  2455. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2456. template &lt;class T,int Rows,int Cols&gt;
  2457. struct mat {
  2458. T a[Rows][Cols];
  2459. template &lt;class R&gt;
  2460. operator R() const {
  2461. R r;
  2462. assign(r,*this);
  2463. return r;
  2464. }
  2465. };
  2466. template &lt;class Matrix&gt;
  2467. struct mat_traits;
  2468. template &lt;class T,int Rows,int Cols&gt;
  2469. struct mat_traits&lt; mat&lt;T,Rows,Cols&gt; &gt; {
  2470. typedef T scalar_type;
  2471. static int const rows=Rows;
  2472. static int const cols=Cols;
  2473. template &lt;int Row,int Col&gt;
  2474. static scalar_type read_element( mat&lt;T,Rows,Cols&gt; const &amp; x ) {
  2475. return x.a[Row][Col];
  2476. }
  2477. template &lt;int Row,int Col&gt;
  2478. static scalar_type &amp; write_element( mat&lt;T,Rows,Cols&gt; &amp; x ) {
  2479. return x.a[Row][Col];
  2480. }
  2481. static scalar_type read_element_idx( int row, int col, mat&lt;T,Rows,Cols&gt; const &amp; x ) {
  2482. return x.a[row][col];
  2483. }
  2484. static scalar_type &amp; write_element_idx( int row, int col, mat&lt;T,Rows,Cols&gt; &amp; x ) {
  2485. return x.a[row][col];
  2486. }
  2487. };
  2488. } }</code></pre>
  2489. </div>
  2490. </div>
  2491. <div class="paragraph">
  2492. <p>This is a simple matrix type. It converts to any other matrix type of compatible size.</p>
  2493. </div>
  2494. <div class="paragraph">
  2495. <p>The partial specialization of the <a href="#mat_traits"><code>mat_traits</code></a> template makes the <code>mat</code> template compatible with the generic operations defined by QVM.</p>
  2496. </div>
  2497. <hr>
  2498. </div>
  2499. </div>
  2500. <div class="sect2">
  2501. <h3 id="_element_access">Element Access</h3>
  2502. <div class="sect3">
  2503. <h4 id="quat_access">Quaternions</h4>
  2504. <div class="listingblock">
  2505. <div class="title">#include &lt;boost/qvm/quat_access.hpp&gt;</div>
  2506. <div class="content">
  2507. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2508. //Only enabled if:
  2509. // is_quat&lt;Q&gt;::value
  2510. template &lt;class Q&gt; -unspecified-return-type- S( Q &amp; q );
  2511. template &lt;class Q&gt; -unspecified-return-type- V( Q &amp; q );
  2512. template &lt;class Q&gt; -unspecified-return-type- X( Q &amp; q );
  2513. template &lt;class Q&gt; -unspecified-return-type- Y( Q &amp; q );
  2514. template &lt;class Q&gt; -unspecified-return-type- Z( Q &amp; q );
  2515. } }</code></pre>
  2516. </div>
  2517. </div>
  2518. <div class="paragraph">
  2519. <p>An expression of the form <code>S(q)</code> can be used to access the scalar component of the quaternion <code>q</code>. For example,</p>
  2520. </div>
  2521. <div class="listingblock">
  2522. <div class="content">
  2523. <pre class="CodeRay highlight nowrap"><code data-lang="c++">S(q) *= 42;</code></pre>
  2524. </div>
  2525. </div>
  2526. <div class="paragraph">
  2527. <p>multiplies the scalar component of <code>q</code> by the scalar 42.</p>
  2528. </div>
  2529. <div class="paragraph">
  2530. <p>An expression of the form <code>V(q)</code> can be used to access the vector component of the quaternion <code>q</code>. For example,</p>
  2531. </div>
  2532. <div class="listingblock">
  2533. <div class="content">
  2534. <pre class="CodeRay highlight nowrap"><code data-lang="c++">V(q) *= 42</code></pre>
  2535. </div>
  2536. </div>
  2537. <div class="paragraph">
  2538. <p>multiplies the vector component of <code>q</code> by the scalar 42.</p>
  2539. </div>
  2540. <div class="paragraph">
  2541. <p>The <code>X</code>, <code>Y</code> and <code>Z</code> elements of the vector component can also be accessed directly using <code>X(q)</code>, <code>Y(q)</code> and <code>Z(q)</code>.</p>
  2542. </div>
  2543. <div class="admonitionblock tip">
  2544. <table>
  2545. <tr>
  2546. <td class="icon">
  2547. <i class="fa icon-tip" title="Tip"></i>
  2548. </td>
  2549. <td class="content">
  2550. The return types are lvalues.
  2551. </td>
  2552. </tr>
  2553. </table>
  2554. </div>
  2555. </div>
  2556. <div class="sect3">
  2557. <h4 id="vec_access">Vectors</h4>
  2558. <div class="listingblock">
  2559. <div class="title">#include &lt;boost/qvm/vec_access.hpp&gt;</div>
  2560. <div class="content">
  2561. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2562. //Only enabled if:
  2563. // is_vec&lt;V&gt;::value
  2564. template &lt;int I,class V&gt; -unspecified-return-type- A( V &amp; v );
  2565. template &lt;class V&gt; -unspecified-return-type- A0( V &amp; v );
  2566. template &lt;class V&gt; -unspecified-return-type- A1( V &amp; v );
  2567. ...
  2568. template &lt;class V&gt; -unspecified-return-type- A9( V &amp; v );
  2569. template &lt;class V&gt; -unspecified-return-type- X( V &amp; v );
  2570. template &lt;class V&gt; -unspecified-return-type- Y( V &amp; v );
  2571. template &lt;class V&gt; -unspecified-return-type- Z( V &amp; v );
  2572. template &lt;class V&gt; -unspecified-return-type- W( V &amp; v );
  2573. } }</code></pre>
  2574. </div>
  2575. </div>
  2576. <div class="paragraph">
  2577. <p>An expression of the form of <code>A&lt;I&gt;(v)</code> can be used to access the <code>I</code>-th element a vector object <code>v</code>. For example, the expression:</p>
  2578. </div>
  2579. <div class="listingblock">
  2580. <div class="content">
  2581. <pre class="CodeRay highlight nowrap"><code data-lang="c++">A&lt;1&gt;(v) *= 42;</code></pre>
  2582. </div>
  2583. </div>
  2584. <div class="paragraph">
  2585. <p>can be used to multiply the element at index 1 (indexing in QVM is always zero-based) of a vector <code>v</code> by 42.</p>
  2586. </div>
  2587. <div class="paragraph">
  2588. <p>For convenience, there are also non-template overloads for <code>I</code> from 0 to 9; an alternative way to write the above expression is:</p>
  2589. </div>
  2590. <div class="listingblock">
  2591. <div class="content">
  2592. <pre class="CodeRay highlight nowrap"><code data-lang="c++">A1(v) *= 42;</code></pre>
  2593. </div>
  2594. </div>
  2595. <div class="paragraph">
  2596. <p><code>X</code>, <code>Y</code>, <code>Z</code> and <code>W</code> act the same as <code>A0</code>/<code>A1</code>/<code>A2</code>/<code>A3</code>; yet another alternative way to write the above expression is:</p>
  2597. </div>
  2598. <div class="listingblock">
  2599. <div class="content">
  2600. <pre class="CodeRay highlight nowrap"><code data-lang="c++">Y(v) *= 42;</code></pre>
  2601. </div>
  2602. </div>
  2603. <div class="admonitionblock tip">
  2604. <table>
  2605. <tr>
  2606. <td class="icon">
  2607. <i class="fa icon-tip" title="Tip"></i>
  2608. </td>
  2609. <td class="content">
  2610. The return types are lvalues.
  2611. </td>
  2612. </tr>
  2613. </table>
  2614. </div>
  2615. </div>
  2616. <div class="sect3">
  2617. <h4 id="swizzling">Vector Element Swizzling</h4>
  2618. <div class="listingblock">
  2619. <div class="title">#include &lt;boost/qvm/swizzle.hpp&gt;</div>
  2620. <div class="content">
  2621. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2622. //*** Accessing vector elements by swizzling ***
  2623. //2D view proxies, only enabled if:
  2624. // is_vec&lt;V&gt;::value
  2625. template &lt;class V&gt; -unspecified-2D-vector-type- XX( V &amp; v );
  2626. template &lt;class V&gt; -unspecified-2D-vector-type- XY( V &amp; v );
  2627. template &lt;class V&gt; -unspecified-2D-vector-type- XZ( V &amp; v );
  2628. template &lt;class V&gt; -unspecified-2D-vector-type- XW( V &amp; v );
  2629. template &lt;class V&gt; -unspecified-2D-vector-type- X0( V &amp; v );
  2630. template &lt;class V&gt; -unspecified-2D-vector-type- X1( V &amp; v );
  2631. template &lt;class V&gt; -unspecified-2D-vector-type- YX( V &amp; v );
  2632. template &lt;class V&gt; -unspecified-2D-vector-type- YY( V &amp; v );
  2633. template &lt;class V&gt; -unspecified-2D-vector-type- YZ( V &amp; v );
  2634. template &lt;class V&gt; -unspecified-2D-vector-type- YW( V &amp; v );
  2635. template &lt;class V&gt; -unspecified-2D-vector-type- Y0( V &amp; v );
  2636. template &lt;class V&gt; -unspecified-2D-vector-type- Y1( V &amp; v );
  2637. template &lt;class V&gt; -unspecified-2D-vector-type- ZX( V &amp; v );
  2638. template &lt;class V&gt; -unspecified-2D-vector-type- ZY( V &amp; v );
  2639. template &lt;class V&gt; -unspecified-2D-vector-type- ZZ( V &amp; v );
  2640. template &lt;class V&gt; -unspecified-2D-vector-type- ZW( V &amp; v );
  2641. template &lt;class V&gt; -unspecified-2D-vector-type- Z0( V &amp; v );
  2642. template &lt;class V&gt; -unspecified-2D-vector-type- Z1( V &amp; v );
  2643. template &lt;class V&gt; -unspecified-2D-vector-type- WX( V &amp; v );
  2644. template &lt;class V&gt; -unspecified-2D-vector-type- WY( V &amp; v );
  2645. template &lt;class V&gt; -unspecified-2D-vector-type- WZ( V &amp; v );
  2646. template &lt;class V&gt; -unspecified-2D-vector-type- WW( V &amp; v );
  2647. template &lt;class V&gt; -unspecified-2D-vector-type- W0( V &amp; v );
  2648. template &lt;class V&gt; -unspecified-2D-vector-type- W1( V &amp; v );
  2649. ...
  2650. //2D view proxies, only enabled if:
  2651. // is_scalar&lt;S&gt;::value
  2652. template &lt;class S&gt; -unspecified-2D-vector-type- X0( S &amp; s );
  2653. template &lt;class S&gt; -unspecified-2D-vector-type- X1( S &amp; s );
  2654. template &lt;class S&gt; -unspecified-2D-vector-type- XX( S &amp; s );
  2655. ...
  2656. -unspecified-2D-vector-type- _00();
  2657. -unspecified-2D-vector-type- _01();
  2658. -unspecified-2D-vector-type- _10();
  2659. -unspecified-2D-vector-type- _11();
  2660. //3D view proxies, only enabled if:
  2661. // is_vec&lt;V&gt;::value
  2662. template &lt;class V&gt; -unspecified-3D-vector-type- XXX( V &amp; v );
  2663. ...
  2664. template &lt;class V&gt; -unspecified-3D-vector-type- XXW( V &amp; v );
  2665. template &lt;class V&gt; -unspecified-3D-vector-type- XX0( V &amp; v );
  2666. template &lt;class V&gt; -unspecified-3D-vector-type- XX1( V &amp; v );
  2667. template &lt;class V&gt; -unspecified-3D-vector-type- XYX( V &amp; v );
  2668. ...
  2669. template &lt;class V&gt; -unspecified-3D-vector-type- XY1( V &amp; v );
  2670. ...
  2671. template &lt;class V&gt; -unspecified-3D-vector-type- WW1( V &amp; v );
  2672. ...
  2673. //3D view proxies, only enabled if:
  2674. // is_scalar&lt;S&gt;::value
  2675. template &lt;class S&gt; -unspecified-3D-vector-type- X00( S &amp; s );
  2676. template &lt;class S&gt; -unspecified-3D-vector-type- X01( S &amp; s );
  2677. ...
  2678. template &lt;class S&gt; -unspecified-3D-vector-type- XXX( S &amp; s );
  2679. template &lt;class S&gt; -unspecified-3D-vector-type- XX0( S &amp; s );
  2680. ...
  2681. -unspecified-3D-vector-type- _000();
  2682. -unspecified-3D-vector-type- _001();
  2683. -unspecified-3D-vector-type- _010();
  2684. ...
  2685. -unspecified-3D-vector-type- _111();
  2686. //4D view proxies, only enabled if:
  2687. // is_vec&lt;V&gt;::value
  2688. template &lt;class V&gt; -unspecified-4D-vector-type- XXXX( V &amp; v );
  2689. ...
  2690. template &lt;class V&gt; -unspecified-4D-vector-type- XXXW( V &amp; v );
  2691. template &lt;class V&gt; -unspecified-4D-vector-type- XXX0( V &amp; v );
  2692. template &lt;class V&gt; -unspecified-4D-vector-type- XXX1( V &amp; v );
  2693. template &lt;class V&gt; -unspecified-4D-vector-type- XXYX( V &amp; v );
  2694. ...
  2695. template &lt;class V&gt; -unspecified-4D-vector-type- XXY1( V &amp; v );
  2696. ...
  2697. template &lt;class V&gt; -unspecified-4D-vector-type- WWW1( V &amp; v );
  2698. ...
  2699. //4D view proxies, only enabled if:
  2700. // is_scalar&lt;S&gt;::value
  2701. template &lt;class S&gt; -unspecified-4D-vector-type- X000( S &amp; s );
  2702. template &lt;class S&gt; -unspecified-4D-vector-type- X001( S &amp; s );
  2703. ...
  2704. template &lt;class S&gt; -unspecified-4D-vector-type- XXXX( S &amp; s );
  2705. template &lt;class S&gt; -unspecified-4D-vector-type- XX00( S &amp; s );
  2706. ...
  2707. -unspecified-4D-vector-type- _0000();
  2708. -unspecified-4D-vector-type- _0001();
  2709. -unspecified-4D-vector-type- _0010();
  2710. ...
  2711. -unspecified-4D-vector-type- _1111();
  2712. } }</code></pre>
  2713. </div>
  2714. </div>
  2715. <div class="paragraph">
  2716. <p>Swizzling allows zero-overhead direct access to a (possibly rearranged) subset of the elements of 2D, 3D and 4D vectors. For example, if <code>v</code> is a 4D vector, the expression <code>YX(v) is a 2D view proxy whose `X</code> element refers to the <code>Y</code> element of <code>v</code>, and whose <code>Y</code> element refers to the <code>X</code> element of <code>v</code>. Like other view proxies <code>YX</code> is an lvalue, that is, if <code>v2</code> is a 2D vector, one could write:</p>
  2717. </div>
  2718. <div class="listingblock">
  2719. <div class="content">
  2720. <pre class="CodeRay highlight nowrap"><code data-lang="c++">YX(v) = v2;</code></pre>
  2721. </div>
  2722. </div>
  2723. <div class="paragraph">
  2724. <p>The above will leave the <code>Z</code> and <code>W</code> elements of <code>v</code> unchanged but assign the <code>Y</code> element of <code>v2</code> to the <code>X</code> element of <code>v</code> and the <code>X</code> element of <code>v2</code> to the <code>Y</code> element of <code>v</code>.</p>
  2725. </div>
  2726. <div class="paragraph">
  2727. <p>All permutations of <code>X</code>, <code>Y</code>, <code>Z</code>, <code>W</code>, <code>0</code>, <code>1</code> for 2D, 3D and 4D swizzling are available (if the first character of the swizzle identifier is <code>0</code> or <code>1</code>, it is preceded by a <code>_</code>, for example <code>_11XY</code>).</p>
  2728. </div>
  2729. <div class="paragraph">
  2730. <p>It is valid to use the same vector element more than once: the expression <code>ZZZ(v)</code> is a 3D vector whose <code>X</code>, <code>Y</code> and <code>Z</code> elements all refer to the <code>Z</code> element of <code>v</code>.</p>
  2731. </div>
  2732. <div class="paragraph">
  2733. <p>Finally, scalars can be "swizzled" to access them as vectors: the expression <code>_0X01(42.0f)</code> is a 4D vector with <code>X</code>=0, <code>Y</code>=42.0, <code>Z</code>=0, <code>W</code>=1.</p>
  2734. </div>
  2735. </div>
  2736. <div class="sect3">
  2737. <h4 id="mat_access">Matrices</h4>
  2738. <div class="listingblock">
  2739. <div class="title">#include &lt;boost/qvm/mat_access.hpp&gt;</div>
  2740. <div class="content">
  2741. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2742. //Only enabled if:
  2743. // is_quat&lt;Q&gt;::value
  2744. template &lt;int R,int C,class M&gt; -unspecified-return-type- A( M &amp; m );
  2745. template &lt;class M&gt; -unspecified-return-type- A00( M &amp; m );
  2746. template &lt;class M&gt; -unspecified-return-type- A01( M &amp; m );
  2747. ...
  2748. template &lt;class M&gt; -unspecified-return-type- A09( M &amp; m );
  2749. template &lt;class M&gt; -unspecified-return-type- A10( M &amp; m );
  2750. ...
  2751. template &lt;class M&gt; -unspecified-return-type- A99( M &amp; m );
  2752. } }</code></pre>
  2753. </div>
  2754. </div>
  2755. <div class="paragraph">
  2756. <p>An expression of the form <code>A&lt;R,C&gt;(m)</code> can be used to access the element at row <code>R</code> and column <code>C</code> of a matrix object <code>m</code>. For example, the expression:</p>
  2757. </div>
  2758. <div class="listingblock">
  2759. <div class="content">
  2760. <pre class="CodeRay highlight nowrap"><code data-lang="c++">A&lt;4,2&gt;(m) *= 42;</code></pre>
  2761. </div>
  2762. </div>
  2763. <div class="paragraph">
  2764. <p>can be used to multiply the element at row 4 and column 2 of a matrix <code>m</code> by 42.</p>
  2765. </div>
  2766. <div class="paragraph">
  2767. <p>For convenience, there are also non-template overloads for <code>R</code> from <code>0</code> to <code>9</code> and <code>C</code> from <code>0</code> to <code>9</code>; an alternative way to write the above expression is:</p>
  2768. </div>
  2769. <div class="listingblock">
  2770. <div class="content">
  2771. <pre class="CodeRay highlight nowrap"><code data-lang="c++">A42(m) *= 42;</code></pre>
  2772. </div>
  2773. </div>
  2774. <div class="admonitionblock tip">
  2775. <table>
  2776. <tr>
  2777. <td class="icon">
  2778. <i class="fa icon-tip" title="Tip"></i>
  2779. </td>
  2780. <td class="content">
  2781. The return types are lvalues.
  2782. </td>
  2783. </tr>
  2784. </table>
  2785. </div>
  2786. <hr>
  2787. </div>
  2788. </div>
  2789. <div class="sect2">
  2790. <h3 id="_quaternion_operations">Quaternion Operations</h3>
  2791. <div class="sect3">
  2792. <h4 id="quat_assign"><code>assign</code></h4>
  2793. <div class="listingblock">
  2794. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  2795. <div class="content">
  2796. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2797. //Only enabled if:
  2798. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  2799. template &lt;class A,class B&gt;
  2800. A &amp; assign( A &amp; a, B const &amp; b );
  2801. } }</code></pre>
  2802. </div>
  2803. </div>
  2804. <div class="dlist">
  2805. <dl>
  2806. <dt class="hdlist1">Effects: </dt>
  2807. <dd>
  2808. <p>Copies all elements of the quaternion <code>b</code> to the quaternion <code>a</code>.</p>
  2809. </dd>
  2810. <dt class="hdlist1">Returns: </dt>
  2811. <dd>
  2812. <p><code>a</code>.</p>
  2813. </dd>
  2814. </dl>
  2815. </div>
  2816. <hr>
  2817. </div>
  2818. <div class="sect3">
  2819. <h4 id="quat_convert_to"><code>convert_to</code></h4>
  2820. <div class="listingblock">
  2821. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  2822. <div class="content">
  2823. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2824. //Only enabled if:
  2825. // is_quat&lt;R&gt;::value &amp;&amp; is_quat&lt;A&gt;::value
  2826. template &lt;class R,class A&gt;
  2827. R convert_to( A const &amp; a );
  2828. //Only enabled if:
  2829. // is_quat&lt;R&gt;::value &amp;&amp; is_mat&lt;A&gt;::value &amp;&amp;
  2830. // mat_traits&lt;A&gt;::rows==3 &amp;&amp; mat_traits&lt;A&gt;::cols==3
  2831. template &lt;class R,class A&gt;
  2832. R convert_to( A const &amp; m );
  2833. } }</code></pre>
  2834. </div>
  2835. </div>
  2836. <div class="dlist">
  2837. <dl>
  2838. <dt class="hdlist1">Requirements: </dt>
  2839. <dd>
  2840. <p><code>R</code> must be copyable.</p>
  2841. </dd>
  2842. <dt class="hdlist1">Effects: </dt>
  2843. <dd>
  2844. <div class="ulist">
  2845. <ul>
  2846. <li>
  2847. <p>The first overload is equivalent to: <code>R r; assign(r,a); return r;</code></p>
  2848. </li>
  2849. <li>
  2850. <p>The second overload assumes that <code>m</code> is an orthonormal rotation matrix and converts it to a quaternion that performs the same rotation.</p>
  2851. </li>
  2852. </ul>
  2853. </div>
  2854. </dd>
  2855. </dl>
  2856. </div>
  2857. <hr>
  2858. </div>
  2859. <div class="sect3">
  2860. <h4 id="quat_minus_eq"><code>operator-=</code></h4>
  2861. <div class="listingblock">
  2862. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  2863. <div class="content">
  2864. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2865. //Only enabled if:
  2866. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  2867. template &lt;class A,class B&gt;
  2868. A &amp; operator-=( A &amp; a, B const &amp; b );
  2869. } }</code></pre>
  2870. </div>
  2871. </div>
  2872. <div class="dlist">
  2873. <dl>
  2874. <dt class="hdlist1">Effects: </dt>
  2875. <dd>
  2876. <p>Subtracts the elements of <code>b</code> from the corresponding elements of <code>a</code>.</p>
  2877. </dd>
  2878. <dt class="hdlist1">Returns: </dt>
  2879. <dd>
  2880. <p><code>a</code>.</p>
  2881. </dd>
  2882. </dl>
  2883. </div>
  2884. <hr>
  2885. </div>
  2886. <div class="sect3">
  2887. <h4 id="quat_minus_unary"><code>operator-</code> (unary)</h4>
  2888. <div class="listingblock">
  2889. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  2890. <div class="content">
  2891. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2892. //Only enabled if: is_quat&lt;A&gt;::value
  2893. template &lt;class A&gt;
  2894. typename deduce_quat&lt;A&gt;::type
  2895. operator-( A const &amp; a );
  2896. } }</code></pre>
  2897. </div>
  2898. </div>
  2899. <div class="dlist">
  2900. <dl>
  2901. <dt class="hdlist1">Returns: </dt>
  2902. <dd>
  2903. <p>A quaternion of the negated elements of <code>a</code>.</p>
  2904. </dd>
  2905. </dl>
  2906. </div>
  2907. <div class="admonitionblock note">
  2908. <table>
  2909. <tr>
  2910. <td class="icon">
  2911. <i class="fa icon-note" title="Note"></i>
  2912. </td>
  2913. <td class="content">
  2914. The <a href="#deduce_quat"><code>deduce_quat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  2915. </td>
  2916. </tr>
  2917. </table>
  2918. </div>
  2919. <hr>
  2920. </div>
  2921. <div class="sect3">
  2922. <h4 id="quat_minus"><code>operator-</code> (binary)</h4>
  2923. <div class="listingblock">
  2924. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  2925. <div class="content">
  2926. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2927. //Only enabled if:
  2928. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  2929. template &lt;class A,class B&gt;
  2930. typename deduce_quat2&lt;A,B&gt;::type
  2931. operator-( A const &amp; a, B const &amp; b );
  2932. } }</code></pre>
  2933. </div>
  2934. </div>
  2935. <div class="dlist">
  2936. <dl>
  2937. <dt class="hdlist1">Returns: </dt>
  2938. <dd>
  2939. <p>A quaternion with elements equal to the elements of <code>b</code> subtracted from the corresponding elements of <code>a</code>.</p>
  2940. </dd>
  2941. </dl>
  2942. </div>
  2943. <div class="admonitionblock note">
  2944. <table>
  2945. <tr>
  2946. <td class="icon">
  2947. <i class="fa icon-note" title="Note"></i>
  2948. </td>
  2949. <td class="content">
  2950. The <a href="#deduce_quat2"><code>deduce_quat2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  2951. </td>
  2952. </tr>
  2953. </table>
  2954. </div>
  2955. <hr>
  2956. </div>
  2957. <div class="sect3">
  2958. <h4 id="quat_plus_eq"><code>operator+=</code></h4>
  2959. <div class="listingblock">
  2960. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  2961. <div class="content">
  2962. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2963. //Only enabled if:
  2964. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  2965. template &lt;class A,class B&gt;
  2966. A &amp; operator+=( A &amp; a, B const &amp; b );
  2967. } }</code></pre>
  2968. </div>
  2969. </div>
  2970. <div class="dlist">
  2971. <dl>
  2972. <dt class="hdlist1">Effects: </dt>
  2973. <dd>
  2974. <p>Adds the elements of <code>b</code> to the corresponding elements of <code>a</code>.</p>
  2975. </dd>
  2976. <dt class="hdlist1">Returns: </dt>
  2977. <dd>
  2978. <p><code>a</code>.</p>
  2979. </dd>
  2980. </dl>
  2981. </div>
  2982. <hr>
  2983. </div>
  2984. <div class="sect3">
  2985. <h4 id="quat_plus"><code>operator+</code></h4>
  2986. <div class="listingblock">
  2987. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  2988. <div class="content">
  2989. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  2990. //Only enabled if:
  2991. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value &amp;&amp;
  2992. template &lt;class A,class B&gt;
  2993. typename deduce_quat2&lt;A,B&gt;::type
  2994. operator+( A const &amp; a, B const &amp; b );
  2995. } }</code></pre>
  2996. </div>
  2997. </div>
  2998. <div class="dlist">
  2999. <dl>
  3000. <dt class="hdlist1">Returns: </dt>
  3001. <dd>
  3002. <p>A quaternion with elements equal to the elements of <code>a</code> added to the corresponding elements of <code>b</code>.</p>
  3003. </dd>
  3004. </dl>
  3005. </div>
  3006. <div class="admonitionblock note">
  3007. <table>
  3008. <tr>
  3009. <td class="icon">
  3010. <i class="fa icon-note" title="Note"></i>
  3011. </td>
  3012. <td class="content">
  3013. The <a href="#deduce_quat2"><code>deduce_quat2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  3014. </td>
  3015. </tr>
  3016. </table>
  3017. </div>
  3018. <hr>
  3019. </div>
  3020. <div class="sect3">
  3021. <h4 id="quat_div_eq_scalar"><code>operator/=</code> (scalar)</h4>
  3022. <div class="listingblock">
  3023. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3024. <div class="content">
  3025. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3026. //Only enabled if: is_quat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  3027. template &lt;class A,class B&gt;
  3028. A &amp; operator/=( A &amp; a, B b );
  3029. } }</code></pre>
  3030. </div>
  3031. </div>
  3032. <div class="dlist">
  3033. <dl>
  3034. <dt class="hdlist1">Effects: </dt>
  3035. <dd>
  3036. <p>This operation divides a quaternion by a scalar.</p>
  3037. </dd>
  3038. <dt class="hdlist1">Returns: </dt>
  3039. <dd>
  3040. <p><code>a</code>.</p>
  3041. </dd>
  3042. </dl>
  3043. </div>
  3044. <hr>
  3045. </div>
  3046. <div class="sect3">
  3047. <h4 id="quat_div_scalar"><code>operator/</code> (scalar)</h4>
  3048. <div class="listingblock">
  3049. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3050. <div class="content">
  3051. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3052. //Only enabled if: is_quat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  3053. template &lt;class A,class B&gt;
  3054. typename deduce_quat&lt;A&gt;::type
  3055. operator/( A const &amp; a, B b );
  3056. } }</code></pre>
  3057. </div>
  3058. </div>
  3059. <div class="dlist">
  3060. <dl>
  3061. <dt class="hdlist1">Returns: </dt>
  3062. <dd>
  3063. <p>A quaternion that is the result of dividing the quaternion <code>a</code> by the scalar <code>b</code>.</p>
  3064. </dd>
  3065. </dl>
  3066. </div>
  3067. <div class="admonitionblock note">
  3068. <table>
  3069. <tr>
  3070. <td class="icon">
  3071. <i class="fa icon-note" title="Note"></i>
  3072. </td>
  3073. <td class="content">
  3074. The <a href="#deduce_quat"><code>deduce_quat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  3075. </td>
  3076. </tr>
  3077. </table>
  3078. </div>
  3079. <hr>
  3080. </div>
  3081. <div class="sect3">
  3082. <h4 id="quat_mul_eq_scalar"><code>operator*=</code> (scalar)</h4>
  3083. <div class="listingblock">
  3084. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3085. <div class="content">
  3086. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3087. //Only enabled if: is_quat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  3088. template &lt;class A,class B&gt;
  3089. A &amp; operator*=( A &amp; a, B b );
  3090. } }</code></pre>
  3091. </div>
  3092. </div>
  3093. <div class="dlist">
  3094. <dl>
  3095. <dt class="hdlist1">Effects: </dt>
  3096. <dd>
  3097. <p>This operation multiplies the quaternion <code>a</code> by the scalar <code>b</code>.</p>
  3098. </dd>
  3099. <dt class="hdlist1">Returns: </dt>
  3100. <dd>
  3101. <p><code>a</code>.</p>
  3102. </dd>
  3103. </dl>
  3104. </div>
  3105. <hr>
  3106. </div>
  3107. <div class="sect3">
  3108. <h4 id="quat_mul_eq"><code>operator*=</code></h4>
  3109. <div class="listingblock">
  3110. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3111. <div class="content">
  3112. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3113. //Only enabled if:
  3114. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  3115. template &lt;class A,class B&gt;
  3116. A &amp; operator*=( A &amp; a, B const &amp; b );
  3117. } }</code></pre>
  3118. </div>
  3119. </div>
  3120. <div class="dlist">
  3121. <dl>
  3122. <dt class="hdlist1">Effects: </dt>
  3123. <dd>
  3124. <p>As if:</p>
  3125. <div class="listingblock">
  3126. <div class="content">
  3127. <pre class="CodeRay highlight nowrap"><code data-lang="c++">A tmp(a);
  3128. a = tmp * b;
  3129. return a;</code></pre>
  3130. </div>
  3131. </div>
  3132. </dd>
  3133. </dl>
  3134. </div>
  3135. <hr>
  3136. </div>
  3137. <div class="sect3">
  3138. <h4 id="quat_mul_scalar"><code>operator*</code> (scalar)</h4>
  3139. <div class="listingblock">
  3140. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3141. <div class="content">
  3142. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3143. //Only enabled if: is_quat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  3144. template &lt;class A,class B&gt;
  3145. typename deduce_quat&lt;A&gt;::type
  3146. operator*( A const &amp; a, B b );
  3147. } }</code></pre>
  3148. </div>
  3149. </div>
  3150. <div class="dlist">
  3151. <dl>
  3152. <dt class="hdlist1">Returns: </dt>
  3153. <dd>
  3154. <p>A quaternion that is the result of multiplying the quaternion <code>a</code> by the scalar <code>b</code>.</p>
  3155. </dd>
  3156. </dl>
  3157. </div>
  3158. <div class="admonitionblock note">
  3159. <table>
  3160. <tr>
  3161. <td class="icon">
  3162. <i class="fa icon-note" title="Note"></i>
  3163. </td>
  3164. <td class="content">
  3165. The <a href="#deduce_quat"><code>deduce_quat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  3166. </td>
  3167. </tr>
  3168. </table>
  3169. </div>
  3170. <hr>
  3171. </div>
  3172. <div class="sect3">
  3173. <h4 id="quat_mul"><code>operator*</code></h4>
  3174. <div class="listingblock">
  3175. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3176. <div class="content">
  3177. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3178. //Only enabled if:
  3179. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  3180. template &lt;class A,class B&gt;
  3181. typename deduce_quat2&lt;A,B&gt;::type
  3182. operator*( A const &amp; a, B const &amp; b );
  3183. } }</code></pre>
  3184. </div>
  3185. </div>
  3186. <div class="dlist">
  3187. <dl>
  3188. <dt class="hdlist1">Returns: </dt>
  3189. <dd>
  3190. <p>The result of multiplying the quaternions <code>a</code> and <code>b</code>.</p>
  3191. </dd>
  3192. </dl>
  3193. </div>
  3194. <div class="admonitionblock note">
  3195. <table>
  3196. <tr>
  3197. <td class="icon">
  3198. <i class="fa icon-note" title="Note"></i>
  3199. </td>
  3200. <td class="content">
  3201. The <a href="#deduce_quat2"><code>deduce_quat2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  3202. </td>
  3203. </tr>
  3204. </table>
  3205. </div>
  3206. <hr>
  3207. </div>
  3208. <div class="sect3">
  3209. <h4 id="quat_eq"><code>operator==</code></h4>
  3210. <div class="listingblock">
  3211. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3212. <div class="content">
  3213. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3214. //Only enabled if:
  3215. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  3216. template &lt;class A,class B&gt;
  3217. bool operator==( A const &amp; a, B const &amp; b );
  3218. } }</code></pre>
  3219. </div>
  3220. </div>
  3221. <div class="dlist">
  3222. <dl>
  3223. <dt class="hdlist1">Returns: </dt>
  3224. <dd>
  3225. <p><code>true</code> if each element of <code>a</code> compares equal to its corresponding element of <code>b</code>, <code>false</code> otherwise.</p>
  3226. </dd>
  3227. </dl>
  3228. </div>
  3229. <hr>
  3230. </div>
  3231. <div class="sect3">
  3232. <h4 id="quat_neq"><code>operator!=</code></h4>
  3233. <div class="listingblock">
  3234. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3235. <div class="content">
  3236. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3237. //Only enabled if:
  3238. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  3239. template &lt;class A,class B&gt;
  3240. bool operator!=( A const &amp; a, B const &amp; b );
  3241. } }</code></pre>
  3242. </div>
  3243. </div>
  3244. <div class="dlist">
  3245. <dl>
  3246. <dt class="hdlist1">Returns: </dt>
  3247. <dd>
  3248. <p><code>!(a == b)</code>.</p>
  3249. </dd>
  3250. </dl>
  3251. </div>
  3252. <hr>
  3253. </div>
  3254. <div class="sect3">
  3255. <h4 id="quat_cmp"><code>cmp</code></h4>
  3256. <div class="listingblock">
  3257. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3258. <div class="content">
  3259. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3260. //Only enabled if:
  3261. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  3262. template &lt;class A,class B,class Cmp&gt;
  3263. bool cmp( A const &amp; a, B const &amp; b, Cmp pred );
  3264. } }</code></pre>
  3265. </div>
  3266. </div>
  3267. <div class="dlist">
  3268. <dl>
  3269. <dt class="hdlist1">Returns: </dt>
  3270. <dd>
  3271. <p>Similar to <a href="#quat_eq"><code>operator==</code></a>, except that it uses the binary predicate <code>pred</code> to compare the individual quaternion elements.</p>
  3272. </dd>
  3273. </dl>
  3274. </div>
  3275. <hr>
  3276. </div>
  3277. <div class="sect3">
  3278. <h4 id="quat_mag_sqr"><code>mag_sqr</code></h4>
  3279. <div class="listingblock">
  3280. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3281. <div class="content">
  3282. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3283. //Only enabled if: is_quat&lt;A&gt;::value
  3284. template &lt;class A&gt;
  3285. typename quat_traits&lt;A&gt;::scalar_type
  3286. mag_sqr( A const &amp; a );
  3287. } }</code></pre>
  3288. </div>
  3289. </div>
  3290. <div class="dlist">
  3291. <dl>
  3292. <dt class="hdlist1">Returns: </dt>
  3293. <dd>
  3294. <p>The squared magnitude of the quaternion <code>a</code>.</p>
  3295. </dd>
  3296. </dl>
  3297. </div>
  3298. <hr>
  3299. </div>
  3300. <div class="sect3">
  3301. <h4 id="quat_mag"><code>mag</code></h4>
  3302. <div class="listingblock">
  3303. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3304. <div class="content">
  3305. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3306. //Only enabled if: is_quat&lt;A&gt;::value
  3307. template &lt;class A&gt;
  3308. typename quat_traits&lt;A&gt;::scalar_type
  3309. mag( A const &amp; a );
  3310. } }</code></pre>
  3311. </div>
  3312. </div>
  3313. <div class="dlist">
  3314. <dl>
  3315. <dt class="hdlist1">Returns: </dt>
  3316. <dd>
  3317. <p>The magnitude of the quaternion <code>a</code>.</p>
  3318. </dd>
  3319. </dl>
  3320. </div>
  3321. <hr>
  3322. </div>
  3323. <div class="sect3">
  3324. <h4 id="quat_normalized"><code>normalized</code></h4>
  3325. <div class="listingblock">
  3326. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3327. <div class="content">
  3328. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3329. //Only enabled if: is_quat&lt;A&gt;::value
  3330. template &lt;class A&gt;
  3331. typename deduce_quat&lt;A&gt;::type
  3332. normalized( A const &amp; a );
  3333. } }</code></pre>
  3334. </div>
  3335. </div>
  3336. <div class="dlist">
  3337. <dl>
  3338. <dt class="hdlist1">Effects: </dt>
  3339. <dd>
  3340. <p>As if:</p>
  3341. <div class="listingblock">
  3342. <div class="content">
  3343. <pre class="CodeRay highlight nowrap"><code data-lang="c++">typename deduce_quat&lt;A&gt;::type tmp;
  3344. assign(tmp,a);
  3345. normalize(tmp);
  3346. return tmp;</code></pre>
  3347. </div>
  3348. </div>
  3349. </dd>
  3350. </dl>
  3351. </div>
  3352. <div class="admonitionblock note">
  3353. <table>
  3354. <tr>
  3355. <td class="icon">
  3356. <i class="fa icon-note" title="Note"></i>
  3357. </td>
  3358. <td class="content">
  3359. The <a href="#deduce_quat"><code>deduce_quat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  3360. </td>
  3361. </tr>
  3362. </table>
  3363. </div>
  3364. <hr>
  3365. </div>
  3366. <div class="sect3">
  3367. <h4 id="quat_normalize"><code>normalize</code></h4>
  3368. <div class="listingblock">
  3369. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3370. <div class="content">
  3371. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3372. //Only enabled if: is_quat&lt;A&gt;::value
  3373. template &lt;class A&gt;
  3374. void normalize( A &amp; a );
  3375. } }</code></pre>
  3376. </div>
  3377. </div>
  3378. <div class="dlist">
  3379. <dl>
  3380. <dt class="hdlist1">Effects: </dt>
  3381. <dd>
  3382. <p>Normalizes <code>a</code>.</p>
  3383. </dd>
  3384. <dt class="hdlist1">Postcondition: </dt>
  3385. <dd>
  3386. <p><code>mag(a)==scalar_traits&lt;typename quat_traits&lt;A&gt;::scalar_type&gt;::value(1).</code></p>
  3387. </dd>
  3388. <dt class="hdlist1">Throws: </dt>
  3389. <dd>
  3390. <p>If the magnitude of <code>a</code> is zero, throws <a href="#zero_magnitude_error"><code>zero_magnitude_error</code></a>.</p>
  3391. </dd>
  3392. </dl>
  3393. </div>
  3394. <hr>
  3395. </div>
  3396. <div class="sect3">
  3397. <h4 id="quat_dot"><code>dot</code></h4>
  3398. <div class="listingblock">
  3399. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3400. <div class="content">
  3401. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3402. //Only enabled if:
  3403. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value
  3404. template &lt;class A,class B&gt;
  3405. typename deduce_scalar&lt;A,B&gt;::type
  3406. dot( A const &amp; a, B const &amp; b );
  3407. } }</code></pre>
  3408. </div>
  3409. </div>
  3410. <div class="dlist">
  3411. <dl>
  3412. <dt class="hdlist1">Returns: </dt>
  3413. <dd>
  3414. <p>The dot product of the quaternions <code>a</code> and <code>b</code>.</p>
  3415. </dd>
  3416. </dl>
  3417. </div>
  3418. <div class="admonitionblock note">
  3419. <table>
  3420. <tr>
  3421. <td class="icon">
  3422. <i class="fa icon-note" title="Note"></i>
  3423. </td>
  3424. <td class="content">
  3425. The <a href="#deduce_scalar"><code>deduce_scalar</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  3426. </td>
  3427. </tr>
  3428. </table>
  3429. </div>
  3430. <hr>
  3431. </div>
  3432. <div class="sect3">
  3433. <h4 id="conjugate"><code>conjugate</code></h4>
  3434. <div class="listingblock">
  3435. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3436. <div class="content">
  3437. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3438. //Only enabled if: is_quat&lt;A&gt;::value
  3439. template &lt;class A&gt;
  3440. typename deduce_quat&lt;A&gt;::type
  3441. conjugate( A const &amp; a );
  3442. } }</code></pre>
  3443. </div>
  3444. </div>
  3445. <div class="dlist">
  3446. <dl>
  3447. <dt class="hdlist1">Returns: </dt>
  3448. <dd>
  3449. <p>Computes the conjugate of <code>a</code>.</p>
  3450. </dd>
  3451. </dl>
  3452. </div>
  3453. <div class="admonitionblock note">
  3454. <table>
  3455. <tr>
  3456. <td class="icon">
  3457. <i class="fa icon-note" title="Note"></i>
  3458. </td>
  3459. <td class="content">
  3460. The <a href="#deduce_quat"><code>deduce_quat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  3461. </td>
  3462. </tr>
  3463. </table>
  3464. </div>
  3465. <hr>
  3466. </div>
  3467. <div class="sect3">
  3468. <h4 id="quat_inverse"><code>inverse</code></h4>
  3469. <div class="listingblock">
  3470. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3471. <div class="content">
  3472. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3473. //Only enabled if: is_quat&lt;A&gt;::value
  3474. template &lt;class A&gt;
  3475. typename deduce_quat&lt;A&gt;::type
  3476. inverse( A const &amp; a );
  3477. } }</code></pre>
  3478. </div>
  3479. </div>
  3480. <div class="dlist">
  3481. <dl>
  3482. <dt class="hdlist1">Returns: </dt>
  3483. <dd>
  3484. <p>Computes the multiplicative inverse of <code>a</code>, or the conjugate-to-norm ratio.</p>
  3485. </dd>
  3486. <dt class="hdlist1">Throws: </dt>
  3487. <dd>
  3488. <p>If the magnitude of <code>a</code> is zero, throws <a href="#zero_magnitude_error"><code>zero_magnitude_error</code></a>.</p>
  3489. </dd>
  3490. </dl>
  3491. </div>
  3492. <div class="admonitionblock tip">
  3493. <table>
  3494. <tr>
  3495. <td class="icon">
  3496. <i class="fa icon-tip" title="Tip"></i>
  3497. </td>
  3498. <td class="content">
  3499. If <code>a</code> is known to be unit length, <code>conjugate</code> is equivalent to <a href="#quat_inverse"><code>inverse</code></a>, yet it is faster to compute.
  3500. </td>
  3501. </tr>
  3502. </table>
  3503. </div>
  3504. <div class="admonitionblock note">
  3505. <table>
  3506. <tr>
  3507. <td class="icon">
  3508. <i class="fa icon-note" title="Note"></i>
  3509. </td>
  3510. <td class="content">
  3511. The <a href="#deduce_quat"><code>deduce_quat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  3512. </td>
  3513. </tr>
  3514. </table>
  3515. </div>
  3516. <hr>
  3517. </div>
  3518. <div class="sect3">
  3519. <h4 id="slerp"><code>slerp</code></h4>
  3520. <div class="listingblock">
  3521. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3522. <div class="content">
  3523. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3524. //Only enabled if:
  3525. // is_quat&lt;A&gt;::value &amp;&amp; is_quat&lt;B&gt;::value &amp;&amp; is_scalar&lt;C&gt;
  3526. template &lt;class A,class B,class C&gt;
  3527. typename deduce_quat2&lt;A,B&gt; &gt;::type
  3528. slerp( A const &amp; a, B const &amp; b, C c );
  3529. } }</code></pre>
  3530. </div>
  3531. </div>
  3532. <div class="dlist">
  3533. <dl>
  3534. <dt class="hdlist1">Preconditions: </dt>
  3535. <dd>
  3536. <p><code>t&gt;=0 &amp;&amp; t&lt;=1</code>.</p>
  3537. </dd>
  3538. <dt class="hdlist1">Returns: </dt>
  3539. <dd>
  3540. <p>A quaternion that is the result of Spherical Linear Interpolation of the quaternions <code>a</code> and <code>b</code> and the interpolation parameter <code>c</code>. When <code>slerp</code> is applied to unit quaternions, the quaternion path maps to a path through 3D rotations in a standard way. The effect is a rotation with uniform angular velocity around a fixed rotation axis.</p>
  3541. </dd>
  3542. </dl>
  3543. </div>
  3544. <div class="admonitionblock note">
  3545. <table>
  3546. <tr>
  3547. <td class="icon">
  3548. <i class="fa icon-note" title="Note"></i>
  3549. </td>
  3550. <td class="content">
  3551. The <a href="#deduce_quat2"><code>deduce_quat2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  3552. </td>
  3553. </tr>
  3554. </table>
  3555. </div>
  3556. <hr>
  3557. </div>
  3558. <div class="sect3">
  3559. <h4 id="zero_quat"><code>zero_quat</code></h4>
  3560. <div class="listingblock">
  3561. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3562. <div class="content">
  3563. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3564. template &lt;class T&gt;
  3565. -unspecified-return-type- zero_quat();
  3566. } }</code></pre>
  3567. </div>
  3568. </div>
  3569. <div class="dlist">
  3570. <dl>
  3571. <dt class="hdlist1">Returns: </dt>
  3572. <dd>
  3573. <p>A read-only quaternion of unspecified type with <a href="#scalar_traits"><code>scalar_type</code></a> <code>T</code>, with all elements equal to <a href="#scalar_traits"><code>scalar_traits&lt;T&gt;::value(0)</code></a>.</p>
  3574. </dd>
  3575. </dl>
  3576. </div>
  3577. <hr>
  3578. </div>
  3579. <div class="sect3">
  3580. <h4 id="quat_set_zero"><code>set_zero</code></h4>
  3581. <div class="listingblock">
  3582. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3583. <div class="content">
  3584. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3585. //Only enabled if: is_quat&lt;A&gt;::value
  3586. template &lt;class A&gt;
  3587. void set_zero( A &amp; a );
  3588. } }</code></pre>
  3589. </div>
  3590. </div>
  3591. <div class="dlist">
  3592. <dl>
  3593. <dt class="hdlist1">Effects: </dt>
  3594. <dd>
  3595. <p>As if:</p>
  3596. <div class="listingblock">
  3597. <div class="content">
  3598. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(a,
  3599. zero_quat&lt;typename quat_traits&lt;A&gt;::scalar_type&gt;());</code></pre>
  3600. </div>
  3601. </div>
  3602. </dd>
  3603. </dl>
  3604. </div>
  3605. <hr>
  3606. </div>
  3607. <div class="sect3">
  3608. <h4 id="identity_quat"><code>identity_quat</code></h4>
  3609. <div class="listingblock">
  3610. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3611. <div class="content">
  3612. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3613. template &lt;class S&gt;
  3614. -unspecified-return-type- identity_quat();
  3615. } }</code></pre>
  3616. </div>
  3617. </div>
  3618. <div class="dlist">
  3619. <dl>
  3620. <dt class="hdlist1">Returns: </dt>
  3621. <dd>
  3622. <p>An identity quaternion with scalar type <code>S</code>.</p>
  3623. </dd>
  3624. </dl>
  3625. </div>
  3626. <hr>
  3627. </div>
  3628. <div class="sect3">
  3629. <h4 id="quat_set_identity"><code>set_identity</code></h4>
  3630. <div class="listingblock">
  3631. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3632. <div class="content">
  3633. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3634. //Only enabled if: is_quat&lt;A&gt;::value
  3635. template &lt;class A&gt;
  3636. void set_identity( A &amp; a );
  3637. } }</code></pre>
  3638. </div>
  3639. </div>
  3640. <div class="dlist">
  3641. <dl>
  3642. <dt class="hdlist1">Effects: </dt>
  3643. <dd>
  3644. <p>As if:</p>
  3645. <div class="listingblock">
  3646. <div class="content">
  3647. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  3648. a,
  3649. identity_quat&lt;typename quat_traits&lt;A&gt;::scalar_type&gt;());</code></pre>
  3650. </div>
  3651. </div>
  3652. </dd>
  3653. </dl>
  3654. </div>
  3655. <hr>
  3656. </div>
  3657. <div class="sect3">
  3658. <h4 id="rot_quat"><code>rot_quat</code></h4>
  3659. <div class="listingblock">
  3660. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3661. <div class="content">
  3662. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3663. //Only enabled if:
  3664. // is_vec&lt;A&gt;::value &amp;&amp; vec_traits&lt;A&gt;::dim==3
  3665. template &lt;class A&gt;
  3666. -unspecified-return-type- rot_quat( A const &amp; axis, typename vec_traits&lt;A&gt;::scalar_type angle );
  3667. } }</code></pre>
  3668. </div>
  3669. </div>
  3670. <div class="dlist">
  3671. <dl>
  3672. <dt class="hdlist1">Returns: </dt>
  3673. <dd>
  3674. <p>A quaternion of unspecified type which performs a rotation around the <code>axis</code> at <code>angle</code> radians.</p>
  3675. </dd>
  3676. <dt class="hdlist1">Throws: </dt>
  3677. <dd>
  3678. <p>In case the axis vector has zero magnitude, throws <a href="#zero_magnitude_error"><code>zero_magnitude_error</code></a>.</p>
  3679. </dd>
  3680. </dl>
  3681. </div>
  3682. <div class="admonitionblock note">
  3683. <table>
  3684. <tr>
  3685. <td class="icon">
  3686. <i class="fa icon-note" title="Note"></i>
  3687. </td>
  3688. <td class="content">
  3689. The <code>rot_quat</code> function is not a <a href="#view_proxy">view proxy</a>; it returns a temp object.
  3690. </td>
  3691. </tr>
  3692. </table>
  3693. </div>
  3694. <hr>
  3695. </div>
  3696. <div class="sect3">
  3697. <h4 id="quat_set_rot"><code>set_rot</code></h4>
  3698. <div class="listingblock">
  3699. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3700. <div class="content">
  3701. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3702. //Only enabled if:
  3703. // is_quat&lt;A&gt;::value &amp;&amp;
  3704. // is_vec&lt;B&gt;::value &amp;&amp; vec_traits&lt;B&gt;::dim==3
  3705. template &lt;class A&gt;
  3706. void set_rot( A &amp; a, B const &amp; axis, typename vec_traits&lt;B&gt;::scalar_type angle );
  3707. } }</code></pre>
  3708. </div>
  3709. </div>
  3710. <div class="dlist">
  3711. <dl>
  3712. <dt class="hdlist1">Effects: </dt>
  3713. <dd>
  3714. <p>As if:</p>
  3715. <div class="listingblock">
  3716. <div class="content">
  3717. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  3718. a,
  3719. rot_quat(axis,angle));</code></pre>
  3720. </div>
  3721. </div>
  3722. </dd>
  3723. </dl>
  3724. </div>
  3725. <hr>
  3726. </div>
  3727. <div class="sect3">
  3728. <h4 id="quat_rotate"><code>rotate</code></h4>
  3729. <div class="listingblock">
  3730. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3731. <div class="content">
  3732. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3733. //Only enabled if:
  3734. // is_quat&lt;A&gt;::value &amp;&amp;
  3735. // is_vec&lt;B&gt;::value &amp;&amp; vec_traits&lt;B&gt;::dim==3
  3736. template &lt;class A,class B&gt;
  3737. void rotate( A &amp; a, B const &amp; axis, typename quat_traits&lt;A&gt;::scalar_type angle );
  3738. } }</code></pre>
  3739. </div>
  3740. </div>
  3741. <div class="dlist">
  3742. <dl>
  3743. <dt class="hdlist1">Effects: </dt>
  3744. <dd>
  3745. <p>As if: <code>a *= <a href="#rot_quat">rot_quat</a>(axis,angle)</code>.</p>
  3746. </dd>
  3747. </dl>
  3748. </div>
  3749. <hr>
  3750. </div>
  3751. <div class="sect3">
  3752. <h4 id="rotx_quat"><code>rotx_quat</code></h4>
  3753. <div class="listingblock">
  3754. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3755. <div class="content">
  3756. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3757. template &lt;class Angle&gt;
  3758. -unspecified-return-type- rotx_quat( Angle const &amp; angle );
  3759. } }</code></pre>
  3760. </div>
  3761. </div>
  3762. <div class="dlist">
  3763. <dl>
  3764. <dt class="hdlist1">Returns: </dt>
  3765. <dd>
  3766. <p>A <a href="#view_proxy">view proxy</a> quaternion of unspecified type and scalar type <code>Angle</code>, which performs a rotation around the X axis at <code>angle</code> radians.</p>
  3767. </dd>
  3768. </dl>
  3769. </div>
  3770. <hr>
  3771. </div>
  3772. <div class="sect3">
  3773. <h4 id="quat_set_rotx"><code>set_rotx</code></h4>
  3774. <div class="listingblock">
  3775. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3776. <div class="content">
  3777. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3778. //Only enabled if: is_quat&lt;A&gt;::value
  3779. template &lt;class A&gt;
  3780. void set_rotx( A &amp; a, typename quat_traits&lt;A&gt;::scalar_type angle );
  3781. } }</code></pre>
  3782. </div>
  3783. </div>
  3784. <div class="dlist">
  3785. <dl>
  3786. <dt class="hdlist1">Effects: </dt>
  3787. <dd>
  3788. <p>As if:</p>
  3789. <div class="listingblock">
  3790. <div class="content">
  3791. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  3792. a,
  3793. rotx_quat(angle));</code></pre>
  3794. </div>
  3795. </div>
  3796. </dd>
  3797. </dl>
  3798. </div>
  3799. <hr>
  3800. </div>
  3801. <div class="sect3">
  3802. <h4 id="quat_rotate_x"><code>rotate_x</code></h4>
  3803. <div class="listingblock">
  3804. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3805. <div class="content">
  3806. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3807. //Only enabled if: is_quat&lt;A&gt;::value
  3808. template &lt;class A&gt;
  3809. void rotate_x( A &amp; a, typename quat_traits&lt;A&gt;::scalar_type angle );
  3810. } }</code></pre>
  3811. </div>
  3812. </div>
  3813. <div class="dlist">
  3814. <dl>
  3815. <dt class="hdlist1">Effects: </dt>
  3816. <dd>
  3817. <p>As if: <code>a *= <a href="#rotx_quat">rotx_quat</a>(angle)</code>.</p>
  3818. </dd>
  3819. </dl>
  3820. </div>
  3821. <hr>
  3822. </div>
  3823. <div class="sect3">
  3824. <h4 id="roty_quat"><code>roty_quat</code></h4>
  3825. <div class="listingblock">
  3826. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3827. <div class="content">
  3828. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3829. template &lt;class Angle&gt;
  3830. -unspecified-return-type- roty_quat( Angle const &amp; angle );
  3831. } }</code></pre>
  3832. </div>
  3833. </div>
  3834. <div class="dlist">
  3835. <dl>
  3836. <dt class="hdlist1">Returns: </dt>
  3837. <dd>
  3838. <p>A <a href="#view_proxy">view proxy</a> quaternion of unspecified type and scalar type <code>Angle</code>, which performs a rotation around the Y axis at <code>angle</code> radians.</p>
  3839. </dd>
  3840. </dl>
  3841. </div>
  3842. <hr>
  3843. </div>
  3844. <div class="sect3">
  3845. <h4 id="quat_set_roty"><code>set_roty</code></h4>
  3846. <div class="listingblock">
  3847. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3848. <div class="content">
  3849. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3850. //Only enabled if: is_quat&lt;A&gt;::value
  3851. template &lt;class A&gt;
  3852. void set_rotz( A &amp; a, typename quat_traits&lt;A&gt;::scalar_type angle );
  3853. } }</code></pre>
  3854. </div>
  3855. </div>
  3856. <div class="dlist">
  3857. <dl>
  3858. <dt class="hdlist1">Effects: </dt>
  3859. <dd>
  3860. <p>As if:</p>
  3861. <div class="listingblock">
  3862. <div class="content">
  3863. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  3864. a,
  3865. roty_quat(angle));</code></pre>
  3866. </div>
  3867. </div>
  3868. </dd>
  3869. </dl>
  3870. </div>
  3871. <hr>
  3872. </div>
  3873. <div class="sect3">
  3874. <h4 id="quat_rotate_y"><code>rotate_y</code></h4>
  3875. <div class="listingblock">
  3876. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3877. <div class="content">
  3878. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3879. //Only enabled if: is_quat&lt;A&gt;::value
  3880. template &lt;class A&gt;
  3881. void rotate_y( A &amp; a, typename quat_traits&lt;A&gt;::scalar_type angle );
  3882. } }</code></pre>
  3883. </div>
  3884. </div>
  3885. <div class="dlist">
  3886. <dl>
  3887. <dt class="hdlist1">Effects: </dt>
  3888. <dd>
  3889. <p>As if: <code>a *= <a href="#roty_quat">roty_quat</a>(angle)</code>.</p>
  3890. </dd>
  3891. </dl>
  3892. </div>
  3893. <hr>
  3894. </div>
  3895. <div class="sect3">
  3896. <h4 id="rotz_quat"><code>rotz_quat</code></h4>
  3897. <div class="listingblock">
  3898. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3899. <div class="content">
  3900. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3901. template &lt;class Angle&gt;
  3902. -unspecified-return-type- rotz_quat( Angle const &amp; angle );
  3903. } }</code></pre>
  3904. </div>
  3905. </div>
  3906. <div class="dlist">
  3907. <dl>
  3908. <dt class="hdlist1">Returns: </dt>
  3909. <dd>
  3910. <p>A <a href="#view_proxy">view proxy</a> quaternion of unspecified type and scalar type <code>Angle</code>, which performs a rotation around the Z axis at <code>angle</code> radians.</p>
  3911. </dd>
  3912. </dl>
  3913. </div>
  3914. <hr>
  3915. </div>
  3916. <div class="sect3">
  3917. <h4 id="quat_set_rotz"><code>set_rotz</code></h4>
  3918. <div class="listingblock">
  3919. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3920. <div class="content">
  3921. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3922. //Only enabled if: is_quat&lt;A&gt;::value
  3923. template &lt;class A&gt;
  3924. void set_rotz( A &amp; a, typename quat_traits&lt;A&gt;::scalar_type angle );
  3925. } }</code></pre>
  3926. </div>
  3927. </div>
  3928. <div class="dlist">
  3929. <dl>
  3930. <dt class="hdlist1">Effects: </dt>
  3931. <dd>
  3932. <p>As if:</p>
  3933. <div class="listingblock">
  3934. <div class="content">
  3935. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  3936. a,
  3937. rotz_quat(angle));</code></pre>
  3938. </div>
  3939. </div>
  3940. </dd>
  3941. </dl>
  3942. </div>
  3943. <hr>
  3944. </div>
  3945. <div class="sect3">
  3946. <h4 id="quat_rotate_z"><code>rotate_z</code></h4>
  3947. <div class="listingblock">
  3948. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3949. <div class="content">
  3950. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3951. //Only enabled if: is_quat&lt;A&gt;::value
  3952. template &lt;class A&gt;
  3953. void rotate_z( A &amp; a, typename quat_traits&lt;A&gt;::scalar_type angle );
  3954. } }</code></pre>
  3955. </div>
  3956. </div>
  3957. <div class="dlist">
  3958. <dl>
  3959. <dt class="hdlist1">Effects: </dt>
  3960. <dd>
  3961. <p>As if: <code>a *= <a href="#rotz_quat">rotz_quat</a>(angle)</code>.</p>
  3962. </dd>
  3963. </dl>
  3964. </div>
  3965. <hr>
  3966. </div>
  3967. <div class="sect3">
  3968. <h4 id="quat_scalar_cast"><code>scalar_cast</code></h4>
  3969. <div class="listingblock">
  3970. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3971. <div class="content">
  3972. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3973. //Only enabled if: is_quat&lt;A&gt;::value
  3974. template &lt;class Scalar,class A&gt;
  3975. -unspecified-return_type- scalar_cast( A const &amp; a );
  3976. } }</code></pre>
  3977. </div>
  3978. </div>
  3979. <div class="dlist">
  3980. <dl>
  3981. <dt class="hdlist1">Returns: </dt>
  3982. <dd>
  3983. <p>A read-only <a href="#view_proxy">view proxy</a> of <code>a</code> that looks like a quaternion of the same dimensions as <code>a</code>, but with <a href="#quat_traits"><code>scalar_type</code></a> <code>Scalar</code> and elements constructed from the corresponding elements of <code>a</code>.</p>
  3984. </dd>
  3985. </dl>
  3986. </div>
  3987. <hr>
  3988. </div>
  3989. <div class="sect3">
  3990. <h4 id="qref"><code>qref</code></h4>
  3991. <div class="listingblock">
  3992. <div class="title">#include &lt;boost/qvm/quat_operations.hpp&gt;</div>
  3993. <div class="content">
  3994. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  3995. //Only enabled if: is_quat&lt;A&gt;::value
  3996. template &lt;class A&gt;
  3997. -unspecified-return-type- qref( A &amp; a );
  3998. } }</code></pre>
  3999. </div>
  4000. </div>
  4001. <div class="dlist">
  4002. <dl>
  4003. <dt class="hdlist1">Returns: </dt>
  4004. <dd>
  4005. <p>An identity view proxy of <code>a</code>; that is, it simply accesses the elements of <code>a</code>.</p>
  4006. </dd>
  4007. </dl>
  4008. </div>
  4009. <div class="admonitionblock tip">
  4010. <table>
  4011. <tr>
  4012. <td class="icon">
  4013. <i class="fa icon-tip" title="Tip"></i>
  4014. </td>
  4015. <td class="content">
  4016. <code>qref</code> allows calling QVM operations when <code>a</code> is of built-in type, for example a plain old C array.
  4017. </td>
  4018. </tr>
  4019. </table>
  4020. </div>
  4021. <hr>
  4022. </div>
  4023. </div>
  4024. <div class="sect2">
  4025. <h3 id="_vector_operations">Vector Operations</h3>
  4026. <div class="sect3">
  4027. <h4 id="vec_assign"><code>assign</code></h4>
  4028. <div class="listingblock">
  4029. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4030. <div class="content">
  4031. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4032. //Only enabled if:
  4033. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4034. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4035. template &lt;class A,class B&gt;
  4036. A &amp; assign( A &amp; a, B const &amp; b );
  4037. } }</code></pre>
  4038. </div>
  4039. </div>
  4040. <div class="dlist">
  4041. <dl>
  4042. <dt class="hdlist1">Effects: </dt>
  4043. <dd>
  4044. <p>Copies all elements of the vector <code>b</code> to the vector <code>a</code>.</p>
  4045. </dd>
  4046. <dt class="hdlist1">Returns: </dt>
  4047. <dd>
  4048. <p><code>a</code>.</p>
  4049. </dd>
  4050. </dl>
  4051. </div>
  4052. <hr>
  4053. </div>
  4054. <div class="sect3">
  4055. <h4 id="vec_convert_to"><code>convert_to</code></h4>
  4056. <div class="listingblock">
  4057. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4058. <div class="content">
  4059. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4060. //Only enabled if:
  4061. // is_vec&lt;R&gt;::value &amp;&amp; is_vec&lt;A&gt;::value &amp;&amp;
  4062. // vec_traits&lt;R&gt;::dim==vec_traits&lt;A&gt;::dim
  4063. template &lt;class R,class A&gt;
  4064. R convert_to( A const &amp; a );
  4065. } }</code></pre>
  4066. </div>
  4067. </div>
  4068. <div class="dlist">
  4069. <dl>
  4070. <dt class="hdlist1">Requirements: </dt>
  4071. <dd>
  4072. <p><code>R</code> must be copyable.</p>
  4073. </dd>
  4074. <dt class="hdlist1">Effects: </dt>
  4075. <dd>
  4076. <p>As if: <code>R r; assign(r,a); return r;</code></p>
  4077. </dd>
  4078. </dl>
  4079. </div>
  4080. <hr>
  4081. </div>
  4082. <div class="sect3">
  4083. <h4 id="vec_minus_eq"><code>operator-=</code></h4>
  4084. <div class="listingblock">
  4085. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4086. <div class="content">
  4087. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4088. //Only enabled if:
  4089. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4090. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4091. template &lt;class A,class B&gt;
  4092. A &amp; operator-=( A &amp; a, B const &amp; b );
  4093. } }</code></pre>
  4094. </div>
  4095. </div>
  4096. <div class="dlist">
  4097. <dl>
  4098. <dt class="hdlist1">Effects: </dt>
  4099. <dd>
  4100. <p>Subtracts the elements of <code>b</code> from the corresponding elements of <code>a</code>.</p>
  4101. </dd>
  4102. <dt class="hdlist1">Returns: </dt>
  4103. <dd>
  4104. <p><code>a</code>.</p>
  4105. </dd>
  4106. </dl>
  4107. </div>
  4108. <hr>
  4109. </div>
  4110. <div class="sect3">
  4111. <h4 id="vec_minus_unary"><code>operator-</code> (unary)</h4>
  4112. <div class="paragraph">
  4113. <p>operator-(vec)</p>
  4114. </div>
  4115. <div class="listingblock">
  4116. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4117. <div class="content">
  4118. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4119. //Only enabled if: is_vec&lt;A&gt;::value
  4120. template &lt;class A&gt;
  4121. typename deduce_vec&lt;A&gt;::type
  4122. operator-( A const &amp; a );
  4123. } }</code></pre>
  4124. </div>
  4125. </div>
  4126. <div class="dlist">
  4127. <dl>
  4128. <dt class="hdlist1">Returns: </dt>
  4129. <dd>
  4130. <p>A vector of the negated elements of <code>a</code>.</p>
  4131. </dd>
  4132. </dl>
  4133. </div>
  4134. <div class="admonitionblock note">
  4135. <table>
  4136. <tr>
  4137. <td class="icon">
  4138. <i class="fa icon-note" title="Note"></i>
  4139. </td>
  4140. <td class="content">
  4141. The <a href="#deduce_vec"><code>deduce_vec</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  4142. </td>
  4143. </tr>
  4144. </table>
  4145. </div>
  4146. <hr>
  4147. </div>
  4148. <div class="sect3">
  4149. <h4 id="vec_minus"><code>operator-</code> (binary)</h4>
  4150. <div class="listingblock">
  4151. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4152. <div class="content">
  4153. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4154. //Only enabled if:
  4155. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4156. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4157. template &lt;class A,class B&gt;
  4158. typename deduce_vec2&lt;A,B,vec_traits&lt;A&gt;::dim&gt;::type
  4159. operator-( A const &amp; a, B const &amp; b );
  4160. } }</code></pre>
  4161. </div>
  4162. </div>
  4163. <div class="dlist">
  4164. <dl>
  4165. <dt class="hdlist1">Returns: </dt>
  4166. <dd>
  4167. <p>A vector of the same size as <code>a</code> and <code>b</code>, with elements the elements of <code>b</code> subtracted from the corresponding elements of <code>a</code>.</p>
  4168. </dd>
  4169. </dl>
  4170. </div>
  4171. <div class="admonitionblock note">
  4172. <table>
  4173. <tr>
  4174. <td class="icon">
  4175. <i class="fa icon-note" title="Note"></i>
  4176. </td>
  4177. <td class="content">
  4178. The <a href="#deduce_vec2"><code>deduce_vec2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  4179. </td>
  4180. </tr>
  4181. </table>
  4182. </div>
  4183. <hr>
  4184. </div>
  4185. <div class="sect3">
  4186. <h4 id="vec_plus_eq"><code>operator+=</code></h4>
  4187. <div class="listingblock">
  4188. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4189. <div class="content">
  4190. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4191. //Only enabled if:
  4192. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4193. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4194. template &lt;class A,class B&gt;
  4195. A &amp; operator+=( A &amp; a, B const &amp; b );
  4196. } }</code></pre>
  4197. </div>
  4198. </div>
  4199. <div class="dlist">
  4200. <dl>
  4201. <dt class="hdlist1">Effects: </dt>
  4202. <dd>
  4203. <p>Adds the elements of <code>b</code> to the corresponding elements of <code>a</code>.</p>
  4204. </dd>
  4205. <dt class="hdlist1">Returns: </dt>
  4206. <dd>
  4207. <p><code>a</code>.</p>
  4208. </dd>
  4209. </dl>
  4210. </div>
  4211. <hr>
  4212. </div>
  4213. <div class="sect3">
  4214. <h4 id="vec_plus"><code>operator+</code></h4>
  4215. <div class="listingblock">
  4216. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4217. <div class="content">
  4218. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4219. //Only enabled if:
  4220. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4221. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4222. template &lt;class A,class B&gt;
  4223. typename deduce_vec2&lt;A,B,vec_traits&lt;A&gt;::dim&gt;::type
  4224. operator+( A const &amp; a, B const &amp; b );
  4225. } }</code></pre>
  4226. </div>
  4227. </div>
  4228. <div class="dlist">
  4229. <dl>
  4230. <dt class="hdlist1">Returns: </dt>
  4231. <dd>
  4232. <p>A vector of the same size as <code>a</code> and <code>b</code>, with elements the elements of <code>b</code> added to the corresponding elements of <code>a</code>.</p>
  4233. </dd>
  4234. </dl>
  4235. </div>
  4236. <div class="admonitionblock note">
  4237. <table>
  4238. <tr>
  4239. <td class="icon">
  4240. <i class="fa icon-note" title="Note"></i>
  4241. </td>
  4242. <td class="content">
  4243. The <a href="#deduce_vec2"><code>deduce_vec2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  4244. </td>
  4245. </tr>
  4246. </table>
  4247. </div>
  4248. <hr>
  4249. </div>
  4250. <div class="sect3">
  4251. <h4 id="vec_div_eq_scalar"><code>operator/=</code> (scalar)</h4>
  4252. <div class="listingblock">
  4253. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4254. <div class="content">
  4255. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4256. //Only enabled if: is_vec&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  4257. template &lt;class A,class B&gt;
  4258. A &amp; operator/=( A &amp; a, B b );
  4259. } }</code></pre>
  4260. </div>
  4261. </div>
  4262. <div class="dlist">
  4263. <dl>
  4264. <dt class="hdlist1">Effects: </dt>
  4265. <dd>
  4266. <p>This operation divides a vector by a scalar.</p>
  4267. </dd>
  4268. <dt class="hdlist1">Returns: </dt>
  4269. <dd>
  4270. <p><code>a</code>.</p>
  4271. </dd>
  4272. </dl>
  4273. </div>
  4274. <hr>
  4275. </div>
  4276. <div class="sect3">
  4277. <h4 id="vec_div_scalar"><code>operator/</code></h4>
  4278. <div class="listingblock">
  4279. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4280. <div class="content">
  4281. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4282. //Only enabled if: is_vec&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  4283. template &lt;class A,class B&gt;
  4284. typename deduce_vec&lt;A&gt;::type
  4285. operator/( A const &amp; a, B b );
  4286. } }</code></pre>
  4287. </div>
  4288. </div>
  4289. <div class="dlist">
  4290. <dl>
  4291. <dt class="hdlist1">Returns: </dt>
  4292. <dd>
  4293. <p>A vector that is the result of dividing the vector <code>a</code> by the scalar <code>b</code>.</p>
  4294. </dd>
  4295. </dl>
  4296. </div>
  4297. <div class="admonitionblock note">
  4298. <table>
  4299. <tr>
  4300. <td class="icon">
  4301. <i class="fa icon-note" title="Note"></i>
  4302. </td>
  4303. <td class="content">
  4304. The <a href="#deduce_vec"><code>deduce_vec</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  4305. </td>
  4306. </tr>
  4307. </table>
  4308. </div>
  4309. <hr>
  4310. </div>
  4311. <div class="sect3">
  4312. <h4 id="vec_mul_eq_scalar"><code>operator*=</code></h4>
  4313. <div class="listingblock">
  4314. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4315. <div class="content">
  4316. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4317. //Only enabled if: is_vec&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  4318. template &lt;class A,class B&gt;
  4319. A &amp; operator*=( A &amp; a, B b );
  4320. } }</code></pre>
  4321. </div>
  4322. </div>
  4323. <div class="dlist">
  4324. <dl>
  4325. <dt class="hdlist1">Effects: </dt>
  4326. <dd>
  4327. <p>This operation multiplies the vector <code>a</code> by the scalar <code>b</code>.</p>
  4328. </dd>
  4329. <dt class="hdlist1">Returns: </dt>
  4330. <dd>
  4331. <p><code>a</code>.</p>
  4332. </dd>
  4333. </dl>
  4334. </div>
  4335. <hr>
  4336. </div>
  4337. <div class="sect3">
  4338. <h4 id="vec_mul_scalar"><code>operator*</code></h4>
  4339. <div class="listingblock">
  4340. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4341. <div class="content">
  4342. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4343. //Only enabled if: is_vec&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  4344. template &lt;class A&gt;
  4345. typename deduce_vec&lt;A&gt;::type
  4346. operator*( A const &amp; a, B b );
  4347. } }</code></pre>
  4348. </div>
  4349. </div>
  4350. <div class="dlist">
  4351. <dl>
  4352. <dt class="hdlist1">Returns: </dt>
  4353. <dd>
  4354. <p>A vector that is the result of multiplying the vector <code>a</code> by the scalar <code>b</code>.</p>
  4355. </dd>
  4356. </dl>
  4357. </div>
  4358. <div class="admonitionblock note">
  4359. <table>
  4360. <tr>
  4361. <td class="icon">
  4362. <i class="fa icon-note" title="Note"></i>
  4363. </td>
  4364. <td class="content">
  4365. The <a href="#deduce_vec"><code>deduce_vec</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  4366. </td>
  4367. </tr>
  4368. </table>
  4369. </div>
  4370. <hr>
  4371. </div>
  4372. <div class="sect3">
  4373. <h4 id="vec_eq"><code>operator==</code></h4>
  4374. <div class="listingblock">
  4375. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4376. <div class="content">
  4377. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4378. //Only enabled if:
  4379. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4380. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4381. template &lt;class A,class B&gt;
  4382. bool operator==( A const &amp; a, B const &amp; b );
  4383. } }</code></pre>
  4384. </div>
  4385. </div>
  4386. <div class="dlist">
  4387. <dl>
  4388. <dt class="hdlist1">Returns: </dt>
  4389. <dd>
  4390. <p><code>true</code> if each element of <code>a</code> compares equal to its corresponding element of <code>b</code>, <code>false</code> otherwise.</p>
  4391. </dd>
  4392. </dl>
  4393. </div>
  4394. <hr>
  4395. </div>
  4396. <div class="sect3">
  4397. <h4 id="vec_neq"><code>operator!=</code></h4>
  4398. <div class="listingblock">
  4399. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4400. <div class="content">
  4401. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4402. //Only enabled if:
  4403. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4404. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4405. template &lt;class A,class B&gt;
  4406. bool operator!=( A const &amp; a, B const &amp; b );
  4407. } }</code></pre>
  4408. </div>
  4409. </div>
  4410. <div class="dlist">
  4411. <dl>
  4412. <dt class="hdlist1">Returns: </dt>
  4413. <dd>
  4414. <p><code>!(a == b)</code>.</p>
  4415. </dd>
  4416. </dl>
  4417. </div>
  4418. <hr>
  4419. </div>
  4420. <div class="sect3">
  4421. <h4 id="vec_cmp"><code>cmp</code></h4>
  4422. <div class="listingblock">
  4423. <div class="content">
  4424. <pre class="nowrap">.#include &lt;boost/qvm/mat_operations.hpp&gt;
  4425. namespace boost
  4426. {
  4427. namespace qvm
  4428. {
  4429. //Only enabled if:
  4430. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  4431. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  4432. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  4433. template &lt;class A,class B,class Cmp&gt;
  4434. bool cmp( A const &amp; a, B const &amp; b, Cmp pred );
  4435. } }</pre>
  4436. </div>
  4437. </div>
  4438. <div class="dlist">
  4439. <dl>
  4440. <dt class="hdlist1">Returns: </dt>
  4441. <dd>
  4442. <p>Similar to <a href="#vec_eq"><code>operator==</code></a>, except that the individual elements of <code>a</code> and <code>b</code> are passed to the binary predicate <code>pred</code> for comparison.</p>
  4443. </dd>
  4444. </dl>
  4445. </div>
  4446. <hr>
  4447. </div>
  4448. <div class="sect3">
  4449. <h4 id="vec_mag_sqr"><code>mag_sqr</code></h4>
  4450. <div class="listingblock">
  4451. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4452. <div class="content">
  4453. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4454. //Only enabled if:
  4455. // is_vec&lt;A&gt;::value
  4456. template &lt;class A&gt;
  4457. typename vec_traits&lt;A&gt;::scalar_type
  4458. mag_sqr( A const &amp; a );
  4459. } }</code></pre>
  4460. </div>
  4461. </div>
  4462. <div class="dlist">
  4463. <dl>
  4464. <dt class="hdlist1">Returns: </dt>
  4465. <dd>
  4466. <p>The squared magnitude of the vector <code>a</code>.</p>
  4467. </dd>
  4468. </dl>
  4469. </div>
  4470. <hr>
  4471. </div>
  4472. <div class="sect3">
  4473. <h4 id="vec_mag"><code>mag</code></h4>
  4474. <div class="listingblock">
  4475. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4476. <div class="content">
  4477. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4478. //Only enabled if:
  4479. // is_vec&lt;A&gt;::value
  4480. template &lt;class A&gt;
  4481. typename vec_traits&lt;A&gt;::scalar_type
  4482. mag( A const &amp; a );
  4483. } }</code></pre>
  4484. </div>
  4485. </div>
  4486. <div class="dlist">
  4487. <dl>
  4488. <dt class="hdlist1">Returns: </dt>
  4489. <dd>
  4490. <p>The magnitude of the vector <code>a</code>.</p>
  4491. </dd>
  4492. </dl>
  4493. </div>
  4494. <hr>
  4495. </div>
  4496. <div class="sect3">
  4497. <h4 id="vec_normalized"><code>normalized</code></h4>
  4498. <div class="listingblock">
  4499. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4500. <div class="content">
  4501. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4502. //Only enabled if:
  4503. // is_vec&lt;A&gt;::value
  4504. template &lt;class A&gt;
  4505. typename deduce_vec&lt;A&gt;::type
  4506. normalized( A const &amp; a );
  4507. } }</code></pre>
  4508. </div>
  4509. </div>
  4510. <div class="dlist">
  4511. <dl>
  4512. <dt class="hdlist1">Effects: </dt>
  4513. <dd>
  4514. <p>As if:</p>
  4515. <div class="listingblock">
  4516. <div class="content">
  4517. <pre class="CodeRay highlight nowrap"><code data-lang="c++">typename deduce_vec&lt;A&gt;::type tmp;
  4518. assign(tmp,a);
  4519. normalize(tmp);
  4520. return tmp;</code></pre>
  4521. </div>
  4522. </div>
  4523. </dd>
  4524. </dl>
  4525. </div>
  4526. <div class="admonitionblock note">
  4527. <table>
  4528. <tr>
  4529. <td class="icon">
  4530. <i class="fa icon-note" title="Note"></i>
  4531. </td>
  4532. <td class="content">
  4533. The <a href="#deduce_vec"><code>deduce_vec</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  4534. </td>
  4535. </tr>
  4536. </table>
  4537. </div>
  4538. <hr>
  4539. </div>
  4540. <div class="sect3">
  4541. <h4 id="vec_normalize"><code>normalize</code></h4>
  4542. <div class="listingblock">
  4543. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4544. <div class="content">
  4545. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4546. //Only enabled if:
  4547. // is_vec&lt;A&gt;::value
  4548. template &lt;class A&gt;
  4549. void normalize( A &amp; a );
  4550. } }</code></pre>
  4551. </div>
  4552. </div>
  4553. <div class="dlist">
  4554. <dl>
  4555. <dt class="hdlist1">Effects: </dt>
  4556. <dd>
  4557. <p>Normalizes <code>a</code>.</p>
  4558. </dd>
  4559. </dl>
  4560. </div>
  4561. <div class="paragraph">
  4562. <p>Postcondition:</p>
  4563. </div>
  4564. <div class="paragraph">
  4565. <p><code>mag(a)==<a href="#scalar_traits">scalar_traits</a>&lt;typename <a href="#vec_traits">vec_traits&lt;A&gt;::scalar_type</a>&gt;::value(1)</code>.</p>
  4566. </div>
  4567. <div class="dlist">
  4568. <dl>
  4569. <dt class="hdlist1">Throws: </dt>
  4570. <dd>
  4571. <p>If the magnitude of <code>a</code> is zero, throws <a href="#zero_magnitude_error"><code>zero_magnitude_error</code></a>.</p>
  4572. </dd>
  4573. </dl>
  4574. </div>
  4575. <hr>
  4576. </div>
  4577. <div class="sect3">
  4578. <h4 id="vec_dot"><code>dot</code></h4>
  4579. <div class="listingblock">
  4580. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4581. <div class="content">
  4582. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4583. //Only enabled if:
  4584. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4585. // vec_traits&lt;A&gt;::dim==vec_traits&lt;B&gt;::dim
  4586. template &lt;class A,class B&gt;
  4587. typename deduce_scalar&lt;A,B&gt;::type
  4588. dot( A const &amp; a, B const &amp; b );
  4589. } }</code></pre>
  4590. </div>
  4591. </div>
  4592. <div class="dlist">
  4593. <dl>
  4594. <dt class="hdlist1">Returns: </dt>
  4595. <dd>
  4596. <p>The dot product of the vectors <code>a</code> and <code>b</code>.</p>
  4597. </dd>
  4598. </dl>
  4599. </div>
  4600. <div class="admonitionblock note">
  4601. <table>
  4602. <tr>
  4603. <td class="icon">
  4604. <i class="fa icon-note" title="Note"></i>
  4605. </td>
  4606. <td class="content">
  4607. The <a href="#deduce_scalar"><code>deduce_scalar</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  4608. </td>
  4609. </tr>
  4610. </table>
  4611. </div>
  4612. <hr>
  4613. </div>
  4614. <div class="sect3">
  4615. <h4 id="vec_cross"><code>cross</code></h4>
  4616. <div class="listingblock">
  4617. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4618. <div class="content">
  4619. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4620. //Only enabled if:
  4621. // is_vec&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  4622. // vec_traits&lt;A&gt;::dim==3 &amp;&amp; vec_traits&lt;B&gt;::dim==3
  4623. template &lt;class A,class B&gt;
  4624. typename deduce_vec2&lt;A,B,3&gt;::type
  4625. cross( A const &amp; a, B const &amp; b );
  4626. } }</code></pre>
  4627. </div>
  4628. </div>
  4629. <div class="dlist">
  4630. <dl>
  4631. <dt class="hdlist1">Returns: </dt>
  4632. <dd>
  4633. <p>The cross product of the vectors <code>a</code> and <code>b</code>.</p>
  4634. </dd>
  4635. </dl>
  4636. </div>
  4637. <div class="admonitionblock note">
  4638. <table>
  4639. <tr>
  4640. <td class="icon">
  4641. <i class="fa icon-note" title="Note"></i>
  4642. </td>
  4643. <td class="content">
  4644. The <a href="#deduce_vec2"><code>deduce_vec2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  4645. </td>
  4646. </tr>
  4647. </table>
  4648. </div>
  4649. <hr>
  4650. </div>
  4651. <div class="sect3">
  4652. <h4 id="zero_vec"><code>zero_vec</code></h4>
  4653. <div class="listingblock">
  4654. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4655. <div class="content">
  4656. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4657. template &lt;class T,int S&gt;
  4658. -unspecified-return-type- zero_vec();
  4659. } }</code></pre>
  4660. </div>
  4661. </div>
  4662. <div class="dlist">
  4663. <dl>
  4664. <dt class="hdlist1">Returns: </dt>
  4665. <dd>
  4666. <p>A read-only vector of unspecified type with <a href="#vec_traits"><code>scalar_type</code></a> <code>T</code> and size <code>S</code>, with all elements equal to <a href="#scalar_traits"><code>scalar_traits&lt;T&gt;::value(0)</code></a>.</p>
  4667. </dd>
  4668. </dl>
  4669. </div>
  4670. <hr>
  4671. </div>
  4672. <div class="sect3">
  4673. <h4 id="vec_set_zero"><code>set_zero</code></h4>
  4674. <div class="listingblock">
  4675. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4676. <div class="content">
  4677. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4678. //Only enabled if:
  4679. // is_vec&lt;A&gt;::value
  4680. template &lt;class A&gt;
  4681. void set_zero( A &amp; a );
  4682. } }</code></pre>
  4683. </div>
  4684. </div>
  4685. <div class="dlist">
  4686. <dl>
  4687. <dt class="hdlist1">Effects: </dt>
  4688. <dd>
  4689. <p>As if:</p>
  4690. <div class="listingblock">
  4691. <div class="content">
  4692. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(a,
  4693. zero_vec&lt;
  4694. typename vec_traits&lt;A&gt;::scalar_type,
  4695. vec_traits&lt;A&gt;::dim&gt;());</code></pre>
  4696. </div>
  4697. </div>
  4698. </dd>
  4699. </dl>
  4700. </div>
  4701. <hr>
  4702. </div>
  4703. <div class="sect3">
  4704. <h4 id="vec_scalar_cast"><code>scalar_cast</code></h4>
  4705. <div class="listingblock">
  4706. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4707. <div class="content">
  4708. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4709. //Only enabled if: is_vec&lt;A&gt;::value
  4710. template &lt;class Scalar,class A&gt;
  4711. -unspecified-return_type- scalar_cast( A const &amp; a );
  4712. } }</code></pre>
  4713. </div>
  4714. </div>
  4715. <div class="dlist">
  4716. <dl>
  4717. <dt class="hdlist1">Returns: </dt>
  4718. <dd>
  4719. <p>A read-only <a href="#view_proxy">view proxy</a> of <code>a</code> that looks like a vector of the same dimensions as <code>a</code>, but with <a href="#vec_traits"><code>scalar_type</code></a> <code>Scalar</code> and elements constructed from the corresponding elements of <code>a</code>.</p>
  4720. </dd>
  4721. </dl>
  4722. </div>
  4723. <hr>
  4724. </div>
  4725. <div class="sect3">
  4726. <h4 id="vref"><code>vref</code></h4>
  4727. <div class="listingblock">
  4728. <div class="title">#include &lt;boost/qvm/vec_operations.hpp&gt;</div>
  4729. <div class="content">
  4730. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4731. //Only enabled if: is_vec&lt;A&gt;::value
  4732. template &lt;class A&gt;
  4733. -unspecified-return-type- vref( A &amp; a );
  4734. } }</code></pre>
  4735. </div>
  4736. </div>
  4737. <div class="dlist">
  4738. <dl>
  4739. <dt class="hdlist1">Returns: </dt>
  4740. <dd>
  4741. <p>An identity <a href="#view_proxy">view proxy</a> of <code>a</code>; that is, it simply accesses the elements of <code>a</code>.</p>
  4742. </dd>
  4743. </dl>
  4744. </div>
  4745. <div class="admonitionblock tip">
  4746. <table>
  4747. <tr>
  4748. <td class="icon">
  4749. <i class="fa icon-tip" title="Tip"></i>
  4750. </td>
  4751. <td class="content">
  4752. <code>vref</code> allows calling QVM operations when <code>a</code> is of built-in type, for example a plain old C array.
  4753. </td>
  4754. </tr>
  4755. </table>
  4756. </div>
  4757. <hr>
  4758. </div>
  4759. </div>
  4760. <div class="sect2">
  4761. <h3 id="_matrix_operations">Matrix Operations</h3>
  4762. <div class="sect3">
  4763. <h4 id="mat_assign"><code>assign</code></h4>
  4764. <div class="listingblock">
  4765. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4766. <div class="content">
  4767. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4768. //Only enabled if:
  4769. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  4770. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  4771. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  4772. template &lt;class A,class B&gt;
  4773. A &amp; assign( A &amp; a, B const &amp; b );
  4774. } }</code></pre>
  4775. </div>
  4776. </div>
  4777. <div class="dlist">
  4778. <dl>
  4779. <dt class="hdlist1">Effects: </dt>
  4780. <dd>
  4781. <p>Copies all elements of the matrix <code>b</code> to the matrix <code>a</code>.</p>
  4782. </dd>
  4783. <dt class="hdlist1">Returns: </dt>
  4784. <dd>
  4785. <p><code>a</code>.</p>
  4786. </dd>
  4787. </dl>
  4788. </div>
  4789. <hr>
  4790. </div>
  4791. <div class="sect3">
  4792. <h4 id="mat_convert_to"><code>convert_to</code></h4>
  4793. <div class="listingblock">
  4794. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4795. <div class="content">
  4796. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4797. //Only enabled if:
  4798. // is_mat&lt;R&gt;::value &amp;&amp; is_mat&lt;A&gt;::value &amp;&amp;
  4799. // mat_traits&lt;R&gt;::rows==mat_traits&lt;A&gt;::rows &amp;&amp;
  4800. // mat_traits&lt;R&gt;::cols==mat_traits&lt;A&gt;::cols
  4801. template &lt;class R,class A&gt;
  4802. R convert_to( A const &amp; a );
  4803. } }</code></pre>
  4804. </div>
  4805. </div>
  4806. <div class="dlist">
  4807. <dl>
  4808. <dt class="hdlist1">Requirements: </dt>
  4809. <dd>
  4810. <p><code>R</code> must be copyable.</p>
  4811. </dd>
  4812. </dl>
  4813. </div>
  4814. <div class="paragraph">
  4815. <p>Effects:</p>
  4816. </div>
  4817. <div class="paragraph">
  4818. <p>As if: <code>R r; <a href="#mat_assign">assign</a>(r,a); return r;</code></p>
  4819. </div>
  4820. <hr>
  4821. </div>
  4822. <div class="sect3">
  4823. <h4 id="mat_minus_eq_scalar"><code>operator-=</code></h4>
  4824. <div class="listingblock">
  4825. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4826. <div class="content">
  4827. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4828. //Only enabled if:
  4829. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  4830. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  4831. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  4832. template &lt;class A,class B&gt;
  4833. A &amp; operator-=( A &amp; a, B const &amp; b );
  4834. } }</code></pre>
  4835. </div>
  4836. </div>
  4837. <div class="dlist">
  4838. <dl>
  4839. <dt class="hdlist1">Effects: </dt>
  4840. <dd>
  4841. <p>Subtracts the elements of <code>b</code> from the corresponding elements of <code>a</code>.</p>
  4842. </dd>
  4843. <dt class="hdlist1">Returns: </dt>
  4844. <dd>
  4845. <p><code>a</code>.</p>
  4846. </dd>
  4847. </dl>
  4848. </div>
  4849. <hr>
  4850. </div>
  4851. <div class="sect3">
  4852. <h4 id="mat_minus_unary"><code>operator-</code> (unary)</h4>
  4853. <div class="listingblock">
  4854. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4855. <div class="content">
  4856. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4857. //Only enabled if: is_mat&lt;A&gt;::value
  4858. template &lt;class A&gt;
  4859. typename deduce_mat&lt;A&gt;::type
  4860. operator-( A const &amp; a );
  4861. } }</code></pre>
  4862. </div>
  4863. </div>
  4864. <div class="dlist">
  4865. <dl>
  4866. <dt class="hdlist1">Returns: </dt>
  4867. <dd>
  4868. <p>A matrix of the negated elements of <code>a</code>.</p>
  4869. </dd>
  4870. </dl>
  4871. </div>
  4872. <div class="admonitionblock note">
  4873. <table>
  4874. <tr>
  4875. <td class="icon">
  4876. <i class="fa icon-note" title="Note"></i>
  4877. </td>
  4878. <td class="content">
  4879. The <a href="#deduce_mat"><code>deduce_mat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  4880. </td>
  4881. </tr>
  4882. </table>
  4883. </div>
  4884. <hr>
  4885. </div>
  4886. <div class="sect3">
  4887. <h4 id="mat_minus"><code>operator-</code></h4>
  4888. <div class="listingblock">
  4889. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4890. <div class="content">
  4891. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4892. //Only enabled if:
  4893. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  4894. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  4895. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  4896. template &lt;class A,class B&gt;
  4897. typename deduce_mat2&lt;A,B,mat_traits&lt;A&gt;::rows,mat_traits&lt;A&gt;::cols&gt;::type
  4898. operator-( A const &amp; a, B const &amp; b );
  4899. } }</code></pre>
  4900. </div>
  4901. </div>
  4902. <div class="dlist">
  4903. <dl>
  4904. <dt class="hdlist1">Returns: </dt>
  4905. <dd>
  4906. <p>A matrix of the same size as <code>a</code> and <code>b</code>, with elements the elements of <code>b</code> subtracted from the corresponding elements of <code>a</code>.</p>
  4907. </dd>
  4908. </dl>
  4909. </div>
  4910. <div class="admonitionblock note">
  4911. <table>
  4912. <tr>
  4913. <td class="icon">
  4914. <i class="fa icon-note" title="Note"></i>
  4915. </td>
  4916. <td class="content">
  4917. The <a href="#deduce_mat2"><code>deduce_mat2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  4918. </td>
  4919. </tr>
  4920. </table>
  4921. </div>
  4922. <hr>
  4923. </div>
  4924. <div class="sect3">
  4925. <h4 id="mat_plus_eq_scalar"><code>operator+=</code></h4>
  4926. <div class="listingblock">
  4927. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4928. <div class="content">
  4929. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4930. //Only enabled if:
  4931. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  4932. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  4933. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  4934. template &lt;class A,class B&gt;
  4935. A &amp; operator+=( A &amp; a, B const &amp; b );
  4936. } }</code></pre>
  4937. </div>
  4938. </div>
  4939. <div class="dlist">
  4940. <dl>
  4941. <dt class="hdlist1">Effects: </dt>
  4942. <dd>
  4943. <p>Adds the elements of <code>b</code> to the corresponding elements of <code>a</code>.</p>
  4944. </dd>
  4945. <dt class="hdlist1">Returns: </dt>
  4946. <dd>
  4947. <p><code>a</code>.</p>
  4948. </dd>
  4949. </dl>
  4950. </div>
  4951. <hr>
  4952. </div>
  4953. <div class="sect3">
  4954. <h4 id="mat_plus"><code>operator+</code></h4>
  4955. <div class="listingblock">
  4956. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4957. <div class="content">
  4958. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4959. //Only enabled if:
  4960. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  4961. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  4962. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  4963. template &lt;class A,class B&gt;
  4964. typename deduce_mat2&lt;A,B,mat_traits&lt;A&gt;::rows,mat_traits&lt;A&gt;::cols&gt;::type
  4965. operator+( A const &amp; a, B const &amp; b );
  4966. } }</code></pre>
  4967. </div>
  4968. </div>
  4969. <div class="dlist">
  4970. <dl>
  4971. <dt class="hdlist1">Returns: </dt>
  4972. <dd>
  4973. <p>A matrix of the same size as <code>a</code> and <code>b</code>, with elements the elements of <code>b</code> added to the corresponding elements of <code>a</code>.</p>
  4974. </dd>
  4975. </dl>
  4976. </div>
  4977. <div class="admonitionblock note">
  4978. <table>
  4979. <tr>
  4980. <td class="icon">
  4981. <i class="fa icon-note" title="Note"></i>
  4982. </td>
  4983. <td class="content">
  4984. The <a href="#deduce_mat2"><code>deduce_mat2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  4985. </td>
  4986. </tr>
  4987. </table>
  4988. </div>
  4989. <hr>
  4990. </div>
  4991. <div class="sect3">
  4992. <h4 id="mat_div_eq_scalar"><code>operator/=</code> (scalar)</h4>
  4993. <div class="listingblock">
  4994. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  4995. <div class="content">
  4996. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  4997. //Only enabled if: is_mat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  4998. template &lt;class A,class B&gt;
  4999. A &amp; operator/=( A &amp; a, B b );
  5000. } }</code></pre>
  5001. </div>
  5002. </div>
  5003. <div class="dlist">
  5004. <dl>
  5005. <dt class="hdlist1">Effects: </dt>
  5006. <dd>
  5007. <p>This operation divides a matrix by a scalar.</p>
  5008. </dd>
  5009. <dt class="hdlist1">Returns: </dt>
  5010. <dd>
  5011. <p><code>a</code>.</p>
  5012. </dd>
  5013. </dl>
  5014. </div>
  5015. <hr>
  5016. </div>
  5017. <div class="sect3">
  5018. <h4 id="mat_div_scalar"><code>operator/</code> (scalar)</h4>
  5019. <div class="listingblock">
  5020. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5021. <div class="content">
  5022. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5023. //Only enabled if: is_mat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  5024. template &lt;class A,class B&gt;
  5025. typename deduce_mat&lt;A&gt;::type
  5026. operator/( A const &amp; a, B b );
  5027. } }</code></pre>
  5028. </div>
  5029. </div>
  5030. <div class="dlist">
  5031. <dl>
  5032. <dt class="hdlist1">Returns: </dt>
  5033. <dd>
  5034. <p>A matrix that is the result of dividing the matrix <code>a</code> by the scalar <code>b</code>.</p>
  5035. </dd>
  5036. </dl>
  5037. </div>
  5038. <div class="admonitionblock note">
  5039. <table>
  5040. <tr>
  5041. <td class="icon">
  5042. <i class="fa icon-note" title="Note"></i>
  5043. </td>
  5044. <td class="content">
  5045. The <a href="#deduce_mat"><code>deduce_mat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  5046. </td>
  5047. </tr>
  5048. </table>
  5049. </div>
  5050. <hr>
  5051. </div>
  5052. <div class="sect3">
  5053. <h4 id="mat_mul_eq"><code>operator*=</code></h4>
  5054. <div class="listingblock">
  5055. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5056. <div class="content">
  5057. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5058. //Only enabled if:
  5059. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  5060. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols &amp;&amp;
  5061. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  5062. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  5063. template &lt;class A,class B&gt;
  5064. A &amp; operator*=( A &amp; a, B const &amp; b );
  5065. } }</code></pre>
  5066. </div>
  5067. </div>
  5068. <div class="dlist">
  5069. <dl>
  5070. <dt class="hdlist1">Effects: </dt>
  5071. <dd>
  5072. <p>As if:</p>
  5073. <div class="listingblock">
  5074. <div class="content">
  5075. <pre class="CodeRay highlight nowrap"><code data-lang="c++">A tmp(a);
  5076. a = tmp * b;
  5077. return a;</code></pre>
  5078. </div>
  5079. </div>
  5080. </dd>
  5081. </dl>
  5082. </div>
  5083. <hr>
  5084. </div>
  5085. <div class="sect3">
  5086. <h4 id="mat_mul_eq_scalar"><code>operator*=</code> (scalar)</h4>
  5087. <div class="listingblock">
  5088. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5089. <div class="content">
  5090. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5091. //Only enabled if: is_mat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  5092. template &lt;class A,class B&gt;
  5093. A &amp; operator*=( A &amp; a, B b );
  5094. } }</code></pre>
  5095. </div>
  5096. </div>
  5097. <div class="dlist">
  5098. <dl>
  5099. <dt class="hdlist1">Effects: </dt>
  5100. <dd>
  5101. <p>This operation multiplies the matrix <code>a</code> matrix by the scalar <code>b</code>.</p>
  5102. </dd>
  5103. <dt class="hdlist1">Returns: </dt>
  5104. <dd>
  5105. <p><code>a</code>.</p>
  5106. </dd>
  5107. </dl>
  5108. </div>
  5109. <hr>
  5110. </div>
  5111. <div class="sect3">
  5112. <h4 id="mat_mul"><code>operator*</code></h4>
  5113. <div class="listingblock">
  5114. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5115. <div class="content">
  5116. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5117. //Only enabled if:
  5118. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  5119. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::rows
  5120. template &lt;class A,class B&gt;
  5121. typename deduce_mat2&lt;A,B,mat_traits&lt;A&gt;::rows,mat_traits&lt;B&gt;::cols&gt;::type
  5122. operator*( A const &amp; a, B const &amp; b );
  5123. } }</code></pre>
  5124. </div>
  5125. </div>
  5126. <div class="dlist">
  5127. <dl>
  5128. <dt class="hdlist1">Returns: </dt>
  5129. <dd>
  5130. <p>The result of <a href="https://en.wikipedia.org/wiki/Matrix_multiplication">multiplying</a> the matrices <code>a</code> and <code>b</code>.</p>
  5131. </dd>
  5132. </dl>
  5133. </div>
  5134. <div class="admonitionblock note">
  5135. <table>
  5136. <tr>
  5137. <td class="icon">
  5138. <i class="fa icon-note" title="Note"></i>
  5139. </td>
  5140. <td class="content">
  5141. The <a href="#deduce_mat2"><code>deduce_mat2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  5142. </td>
  5143. </tr>
  5144. </table>
  5145. </div>
  5146. <hr>
  5147. </div>
  5148. <div class="sect3">
  5149. <h4 id="mat_mul_scalar"><code>operator*</code> (scalar)</h4>
  5150. <div class="listingblock">
  5151. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5152. <div class="content">
  5153. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5154. //Only enabled if: is_mat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  5155. template &lt;class A,class B&gt;
  5156. typename deduce_mat&lt;A&gt;::type
  5157. operator*( A const &amp; a, B b );
  5158. //Only enabled if: is_scalar&lt;B&gt;::value &amp;&amp; is_mat&lt;A&gt;::value
  5159. template &lt;class B,class A&gt;
  5160. typename deduce_mat&lt;A&gt;::type
  5161. operator*( B b, A const &amp; a );
  5162. } }</code></pre>
  5163. </div>
  5164. </div>
  5165. <div class="dlist">
  5166. <dl>
  5167. <dt class="hdlist1">Returns: </dt>
  5168. <dd>
  5169. <p>A matrix that is the result of multiplying the matrix <code>a</code> by the scalar <code>b</code>.</p>
  5170. </dd>
  5171. </dl>
  5172. </div>
  5173. <div class="admonitionblock note">
  5174. <table>
  5175. <tr>
  5176. <td class="icon">
  5177. <i class="fa icon-note" title="Note"></i>
  5178. </td>
  5179. <td class="content">
  5180. The <a href="#deduce_mat"><code>deduce_mat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  5181. </td>
  5182. </tr>
  5183. </table>
  5184. </div>
  5185. <hr>
  5186. </div>
  5187. <div class="sect3">
  5188. <h4 id="mat_eq"><code>operator==</code></h4>
  5189. <div class="listingblock">
  5190. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5191. <div class="content">
  5192. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5193. //Only enabled if:
  5194. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  5195. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  5196. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  5197. template &lt;class A,class B&gt;
  5198. bool operator==( A const &amp; a, B const &amp; b );
  5199. } }</code></pre>
  5200. </div>
  5201. </div>
  5202. <div class="dlist">
  5203. <dl>
  5204. <dt class="hdlist1">Returns: </dt>
  5205. <dd>
  5206. <p><code>true</code> if each element of <code>a</code> compares equal to its corresponding element of <code>b</code>, <code>false</code> otherwise.</p>
  5207. </dd>
  5208. </dl>
  5209. </div>
  5210. <hr>
  5211. </div>
  5212. <div class="sect3">
  5213. <h4 id="mat_neq"><code>operator!=</code></h4>
  5214. <div class="listingblock">
  5215. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5216. <div class="content">
  5217. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5218. //Only enabled if:
  5219. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  5220. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  5221. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  5222. template &lt;class A,class B&gt;
  5223. bool operator!=( A const &amp; a, B const &amp; b );
  5224. } }</code></pre>
  5225. </div>
  5226. </div>
  5227. <div class="dlist">
  5228. <dl>
  5229. <dt class="hdlist1">Returns: </dt>
  5230. <dd>
  5231. <p><code>!( a <a href="#mat_eq">==</a> b )</code>.</p>
  5232. </dd>
  5233. </dl>
  5234. </div>
  5235. <hr>
  5236. </div>
  5237. <div class="sect3">
  5238. <h4 id="mat_cmp"><code>cmp</code></h4>
  5239. <div class="listingblock">
  5240. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5241. <div class="content">
  5242. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5243. //Only enabled if:
  5244. // is_mat&lt;A&gt;::value &amp;&amp; is_mat&lt;B&gt;::value &amp;&amp;
  5245. // mat_traits&lt;A&gt;::rows==mat_traits&lt;B&gt;::rows &amp;&amp;
  5246. // mat_traits&lt;A&gt;::cols==mat_traits&lt;B&gt;::cols
  5247. template &lt;class A,class B,class Cmp&gt;
  5248. bool cmp( A const &amp; a, B const &amp; b, Cmp pred );
  5249. } }</code></pre>
  5250. </div>
  5251. </div>
  5252. <div class="dlist">
  5253. <dl>
  5254. <dt class="hdlist1">Returns: </dt>
  5255. <dd>
  5256. <p>Similar to <a href="#mat_eq"><code>operator==</code></a>, except that the individual elements of <code>a</code> and <code>b</code> are passed to the binary predicate <code>pred</code> for comparison.</p>
  5257. </dd>
  5258. </dl>
  5259. </div>
  5260. <hr>
  5261. </div>
  5262. <div class="sect3">
  5263. <h4 id="mat_inverse"><code>inverse</code></h4>
  5264. <div class="listingblock">
  5265. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5266. <div class="content">
  5267. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5268. //Only enabled if:
  5269. // is_mat&lt;A&gt;::value &amp;&amp; is_scalar&lt;B&gt;::value
  5270. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5271. template &lt;class A,class B&gt;
  5272. typename deduce_mat&lt;A&gt;::type
  5273. inverse( A const &amp; a, B det );
  5274. template &lt;class A&gt;
  5275. typename deduce_mat&lt;A&gt;::type
  5276. inverse( A const &amp; a );
  5277. } }</code></pre>
  5278. </div>
  5279. </div>
  5280. <div class="dlist">
  5281. <dl>
  5282. <dt class="hdlist1">Preconditions: </dt>
  5283. <dd>
  5284. <p><code>det!=<a href="#scalar_traits">scalar_traits</a>&lt;typename <a href="#mat_traits">mat_traits&lt;A&gt;::scalar_type</a>&gt;::value(0)</code></p>
  5285. </dd>
  5286. <dt class="hdlist1">Returns: </dt>
  5287. <dd>
  5288. <p>Both overloads compute the inverse of <code>a</code>. The first overload takes the pre-computed determinant of <code>a</code>.</p>
  5289. </dd>
  5290. <dt class="hdlist1">Throws: </dt>
  5291. <dd>
  5292. <p>The second overload computes the determinant automatically and throws <a href="#zero_determinant_error"><code>zero_determinant_error</code></a> if the computed determinant is zero.</p>
  5293. </dd>
  5294. </dl>
  5295. </div>
  5296. <div class="admonitionblock note">
  5297. <table>
  5298. <tr>
  5299. <td class="icon">
  5300. <i class="fa icon-note" title="Note"></i>
  5301. </td>
  5302. <td class="content">
  5303. The <a href="#deduce_mat"><code>deduce_mat</code></a> template can be specialized to deduce the desired return type from the type <code>A</code>.
  5304. </td>
  5305. </tr>
  5306. </table>
  5307. </div>
  5308. <hr>
  5309. </div>
  5310. <div class="sect3">
  5311. <h4 id="zero_mat"><code>zero_mat</code></h4>
  5312. <div class="listingblock">
  5313. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5314. <div class="content">
  5315. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5316. template &lt;class T,int D&gt;
  5317. -unspecified-return-type- zero_mat();
  5318. template &lt;class T,int R,int C&gt;
  5319. -unspecified-return-type- zero_mat();
  5320. } }</code></pre>
  5321. </div>
  5322. </div>
  5323. <div class="dlist">
  5324. <dl>
  5325. <dt class="hdlist1">Returns: </dt>
  5326. <dd>
  5327. <p>A read-only matrix of unspecified type with <a href="#mat_traits"><code>scalar_type</code></a> <code>T</code>, <code>R</code> rows and <code>C</code> columns (or <code>D</code> rows and <code>D</code> columns), with all elements equal to <a href="#scalar_traits"><code>scalar_traits&lt;T&gt;::value(0)</code></a>.</p>
  5328. </dd>
  5329. </dl>
  5330. </div>
  5331. <hr>
  5332. </div>
  5333. <div class="sect3">
  5334. <h4 id="mat_set_zero"><code>set_zero</code></h4>
  5335. <div class="listingblock">
  5336. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5337. <div class="content">
  5338. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5339. //Only enabled if:
  5340. // is_mat&lt;A&gt;::value
  5341. template &lt;class A&gt;
  5342. void set_zero( A &amp; a );
  5343. } }</code></pre>
  5344. </div>
  5345. </div>
  5346. <div class="dlist">
  5347. <dl>
  5348. <dt class="hdlist1">Effects: </dt>
  5349. <dd>
  5350. <p>As if:</p>
  5351. <div class="listingblock">
  5352. <div class="content">
  5353. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(a,
  5354. zero_mat&lt;
  5355. typename mat_traits&lt;A&gt;::scalar_type,
  5356. mat_traits&lt;A&gt;::rows,
  5357. mat_traits&lt;A&gt;::cols&gt;());</code></pre>
  5358. </div>
  5359. </div>
  5360. </dd>
  5361. </dl>
  5362. </div>
  5363. <hr>
  5364. </div>
  5365. <div class="sect3">
  5366. <h4 id="identity_mat"><code>identity_mat</code></h4>
  5367. <div class="listingblock">
  5368. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5369. <div class="content">
  5370. <pre class="nowrap">namespace boost { namespace qvm {
  5371. template &lt;class S,int D&gt;
  5372. -unspecified-return-type- identity_mat();
  5373. } }</pre>
  5374. </div>
  5375. </div>
  5376. <div class="dlist">
  5377. <dl>
  5378. <dt class="hdlist1">Returns: </dt>
  5379. <dd>
  5380. <p>An identity matrix of size <code>D</code> x <code>D</code> and scalar type <code>S</code>.</p>
  5381. </dd>
  5382. </dl>
  5383. </div>
  5384. <hr>
  5385. </div>
  5386. <div class="sect3">
  5387. <h4 id="mat_set_identity"><code>set_identity</code></h4>
  5388. <div class="listingblock">
  5389. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5390. <div class="content">
  5391. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5392. //Only enabled if:
  5393. // is_mat&lt;A&gt;::value &amp;&amp;
  5394. // mat_traits&lt;A&gt;::cols==mat_traits&lt;A&gt;::rows
  5395. template &lt;class A&gt;
  5396. void set_identity( A &amp; a );
  5397. } }</code></pre>
  5398. </div>
  5399. </div>
  5400. <div class="dlist">
  5401. <dl>
  5402. <dt class="hdlist1">Effects: </dt>
  5403. <dd>
  5404. <p>As if:</p>
  5405. <div class="listingblock">
  5406. <div class="content">
  5407. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  5408. a,
  5409. identity_mat&lt;
  5410. typename mat_traits&lt;A&gt;::scalar_type,
  5411. mat_traits&lt;A&gt;::rows,
  5412. mat_traits&lt;A&gt;::cols&gt;());</code></pre>
  5413. </div>
  5414. </div>
  5415. </dd>
  5416. </dl>
  5417. </div>
  5418. <hr>
  5419. </div>
  5420. <div class="sect3">
  5421. <h4 id="rot_mat"><code>rot_mat</code> / Euler angles</h4>
  5422. <div class="listingblock">
  5423. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5424. <div class="content">
  5425. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5426. //Only enabled if:
  5427. // is_vec&lt;A&gt;::value &amp;&amp; vec_traits&lt;A&gt;::dim==3
  5428. template &lt;int Dim,class A,class Angle&gt;
  5429. -unspecified-return-type-
  5430. rot_mat( A const &amp; axis, Angle angle );
  5431. template &lt;int Dim,class Angle&gt;
  5432. -unspecified-return-type-
  5433. rot_mat_xzy( Angle x1, Angle z2, Angle y3 );
  5434. template &lt;int Dim,class Angle&gt;
  5435. -unspecified-return-type-
  5436. rot_mat_xyz( Angle x1, Angle y2, Angle z3 );
  5437. template &lt;int Dim,class Angle&gt;
  5438. -unspecified-return-type-
  5439. rot_mat_yxz( Angle y1, Angle x2, Angle z3 );
  5440. template &lt;int Dim,class Angle&gt;
  5441. -unspecified-return-type-
  5442. rot_mat_yzx( Angle y1, Angle z2, Angle x3 );
  5443. template &lt;int Dim,class Angle&gt;
  5444. -unspecified-return-type-
  5445. rot_mat_zyx( Angle z1, Angle y2, Angle x3 );
  5446. template &lt;int Dim,class Angle&gt;
  5447. -unspecified-return-type-
  5448. rot_mat_zxy( Angle z1, Angle x2, Angle y3 );
  5449. template &lt;int Dim,class Angle&gt;
  5450. -unspecified-return-type-
  5451. rot_mat_xzx( Angle x1, Angle z2, Angle x3 );
  5452. template &lt;int Dim,class Angle&gt;
  5453. -unspecified-return-type-
  5454. rot_mat_xyx( Angle x1, Angle y2, Angle x3 );
  5455. template &lt;int Dim,class Angle&gt;
  5456. -unspecified-return-type-
  5457. rot_mat_yxy( Angle y1, Angle x2, Angle y3 );
  5458. template &lt;int Dim,class Angle&gt;
  5459. -unspecified-return-type-
  5460. rot_mat_yzy( Angle y1, Angle z2, Angle y3 );
  5461. template &lt;int Dim,class Angle&gt;
  5462. -unspecified-return-type-
  5463. rot_mat_zyz( Angle z1, Angle y2, Angle z3 );
  5464. template &lt;int Dim,class Angle&gt;
  5465. -unspecified-return-type-
  5466. rot_mat_zxz( Angle z1, Angle y2, Angle z3 );
  5467. } }</code></pre>
  5468. </div>
  5469. </div>
  5470. <div class="dlist">
  5471. <dl>
  5472. <dt class="hdlist1">Returns: </dt>
  5473. <dd>
  5474. <p>A matrix of unspecified type, of <code>Dim</code> rows and <code>Dim</code> columns parameter, which performs a rotation around the <code>axis</code> at <code>angle</code> radians, or Tait–Bryan angles (x-y-z, y-z-x, z-x-y, x-z-y, z-y-x, y-x-z), or proper Euler angles (z-x-z, x-y-x, y-z-y, z-y-z, x-z-x, y-x-y). See <a href="https://en.wikipedia.org/wiki/Euler_angles">Euler angles</a>.</p>
  5475. </dd>
  5476. <dt class="hdlist1">Throws: </dt>
  5477. <dd>
  5478. <p>In case the axis vector has zero magnitude, throws <a href="#zero_magnitude_error"><code>zero_magnitude_error</code></a>.</p>
  5479. </dd>
  5480. </dl>
  5481. </div>
  5482. <div class="admonitionblock note">
  5483. <table>
  5484. <tr>
  5485. <td class="icon">
  5486. <i class="fa icon-note" title="Note"></i>
  5487. </td>
  5488. <td class="content">
  5489. These functions are not view proxies; they return a temp object.
  5490. </td>
  5491. </tr>
  5492. </table>
  5493. </div>
  5494. <hr>
  5495. </div>
  5496. <div class="sect3">
  5497. <h4 id="mat_set_rot"><code>set_rot</code> / Euler angles</h4>
  5498. <div class="listingblock">
  5499. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5500. <div class="content">
  5501. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5502. //Only enabled if:
  5503. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5504. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols &amp;&amp;
  5505. // is_vec&lt;B&gt;::value &amp;&amp; vec_traits&lt;B&gt;::dim==3
  5506. template &lt;class A&gt;
  5507. void set_rot( A &amp; a, B const &amp; axis, typename vec_traits&lt;B&gt;::scalar_type angle );
  5508. //Only enabled if:
  5509. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5510. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5511. template &lt;class A,class Angle&gt;
  5512. void set_rot_xzy( A &amp; a, Angle x1, Angle z2, Angle y3 );
  5513. //Only enabled if:
  5514. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5515. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5516. template &lt;class A,class Angle&gt;
  5517. void set_rot_xyz( A &amp; a, Angle x1, Angle y2, Angle z3 );
  5518. //Only enabled if:
  5519. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5520. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5521. template &lt;class A,class Angle&gt;
  5522. void set_rot_yxz( A &amp; a, Angle y1, Angle x2, Angle z3 );
  5523. //Only enabled if:
  5524. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5525. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5526. template &lt;class A,class Angle&gt;
  5527. void set_rot_yzx( A &amp; a, Angle y1, Angle z2, Angle x3 );
  5528. //Only enabled if:
  5529. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5530. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5531. template &lt;class A,class Angle&gt;
  5532. void set_rot_zyx( A &amp; a, Angle z1, Angle y2, Angle x3 );
  5533. //Only enabled if:
  5534. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5535. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5536. template &lt;class A,class Angle&gt;
  5537. void set_rot_zxy( A &amp; a, Angle z1, Angle x2, Angle y3 );
  5538. //Only enabled if:
  5539. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5540. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5541. template &lt;class A,class Angle&gt;
  5542. void set_rot_xzx( A &amp; a, Angle x1, Angle z2, Angle x3 );
  5543. //Only enabled if:
  5544. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5545. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5546. template &lt;class A,class Angle&gt;
  5547. void set_rot_xyx( A &amp; a, Angle x1, Angle y2, Angle x3 );
  5548. //Only enabled if:
  5549. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5550. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5551. template &lt;class A,class Angle&gt;
  5552. void set_rot_yxy( A &amp; a, Angle y1, Angle x2, Angle y3 );
  5553. //Only enabled if:
  5554. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5555. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5556. template &lt;class A,class Angle&gt;
  5557. void set_rot_yzy( A &amp; a, Angle y1, Angle z2, Angle y3 );
  5558. //Only enabled if:
  5559. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5560. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5561. template &lt;class A,class Angle&gt;
  5562. void set_rot_zyz( A &amp; a, Angle z1, Angle y2, Angle z3 );
  5563. //Only enabled if:
  5564. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5565. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5566. template &lt;class A,class Angle&gt;
  5567. void set_rot_zxz( A &amp; a, Angle z1, Angle x2, Angle z3 );
  5568. //Only enabled if:
  5569. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5570. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5571. template &lt;class A,class Angle&gt;
  5572. void set_rot_xzy( A &amp; a, Angle x1, Angle z2, Angle y3 );
  5573. } }</code></pre>
  5574. </div>
  5575. </div>
  5576. <div class="dlist">
  5577. <dl>
  5578. <dt class="hdlist1">Effects: </dt>
  5579. <dd>
  5580. <p>Assigns the return value of the corresponding <a href="#rot_mat"><code>rot_mat</code></a> function to <code>a</code>.</p>
  5581. </dd>
  5582. </dl>
  5583. </div>
  5584. <hr>
  5585. </div>
  5586. <div class="sect3">
  5587. <h4 id="mat_rotate"><code>rotate</code> / Euler angles</h4>
  5588. <div class="listingblock">
  5589. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5590. <div class="content">
  5591. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5592. //Only enabled if:
  5593. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5594. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols &amp;&amp;
  5595. // is_vec&lt;B&gt;::value &amp;&amp; vec_traits&lt;B&gt;::dim==3
  5596. template &lt;class A,class B&gt;
  5597. void rotate( A &amp; a, B const &amp; axis, typename mat_traits&lt;A&gt;::scalar_type angle );
  5598. //Only enabled if:
  5599. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5600. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5601. template &lt;class A,class Angle&gt;
  5602. void rotate_xzy( A &amp; a, Angle x1, Angle z2, Angle y3 );
  5603. //Only enabled if:
  5604. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5605. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5606. template &lt;class A,class Angle&gt;
  5607. void rotate_xyz( A &amp; a, Angle x1, Angle y2, Angle z3 );
  5608. //Only enabled if:
  5609. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5610. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5611. template &lt;class A,class Angle&gt;
  5612. void rotate_yxz( A &amp; a, Angle y1, Angle x2, Angle z3 );
  5613. //Only enabled if:
  5614. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5615. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5616. template &lt;class A,class Angle&gt;
  5617. void rotate_yzx( A &amp; a, Angle y1, Angle z2, Angle x3 );
  5618. //Only enabled if:
  5619. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5620. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5621. template &lt;class A,class Angle&gt;
  5622. void rotate_zyx( A &amp; a, Angle z1, Angle y2, Angle x3 );
  5623. //Only enabled if:
  5624. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5625. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5626. template &lt;class A,class Angle&gt;
  5627. void rotate_zxy( A &amp; a, Angle z1, Angle x2, Angle y3 );
  5628. //Only enabled if:
  5629. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5630. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5631. template &lt;class A,class Angle&gt;
  5632. void rotate_xzx( A &amp; a, Angle x1, Angle z2, Angle x3 );
  5633. //Only enabled if:
  5634. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5635. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5636. template &lt;class A,class Angle&gt;
  5637. void rotate_xyx( A &amp; a, Angle x1, Angle y2, Angle x3 );
  5638. //Only enabled if:
  5639. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5640. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5641. template &lt;class A,class Angle&gt;
  5642. void rotate_yxy( A &amp; a, Angle y1, Angle x2, Angle y3 );
  5643. //Only enabled if:
  5644. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5645. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5646. template &lt;class A,class Angle&gt;
  5647. void rotate_yzy( A &amp; a, Angle y1, Angle z2, Angle y3 );
  5648. //Only enabled if:
  5649. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5650. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5651. template &lt;class A,class Angle&gt;
  5652. void rotate_zyz( A &amp; a, Angle z1, Angle y2, Angle z3 );
  5653. //Only enabled if:
  5654. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5655. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5656. template &lt;class A,class Angle&gt;
  5657. void rotate_zxz( A &amp; a, Angle z1, Angle x2, Angle z3 );
  5658. } }</code></pre>
  5659. </div>
  5660. </div>
  5661. <div class="dlist">
  5662. <dl>
  5663. <dt class="hdlist1">Effects: </dt>
  5664. <dd>
  5665. <p>Multiplies the matrix <code>a</code> in-place by the return value of the corresponding <a href="#rot_mat"><code>rot_mat</code></a> function.</p>
  5666. </dd>
  5667. </dl>
  5668. </div>
  5669. <hr>
  5670. </div>
  5671. <div class="sect3">
  5672. <h4 id="rotx_mat"><code>rotx_mat</code></h4>
  5673. <div class="listingblock">
  5674. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5675. <div class="content">
  5676. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5677. template &lt;int Dim,class Angle&gt;
  5678. -unspecified-return-type- rotx_mat( Angle const &amp; angle );
  5679. } }</code></pre>
  5680. </div>
  5681. </div>
  5682. <div class="dlist">
  5683. <dl>
  5684. <dt class="hdlist1">Returns: </dt>
  5685. <dd>
  5686. <p>A <a href="#view_proxy">view proxy</a> matrix of unspecified type, of <code>Dim</code> rows and <code>Dim</code> columns and scalar type <code>Angle</code>, which performs a rotation around the <code>X</code> axis at <code>angle</code> radians.</p>
  5687. </dd>
  5688. </dl>
  5689. </div>
  5690. <hr>
  5691. </div>
  5692. <div class="sect3">
  5693. <h4 id="mat_set_rotx"><code>set_rotx</code></h4>
  5694. <div class="listingblock">
  5695. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5696. <div class="content">
  5697. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5698. //Only enabled if:
  5699. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5700. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5701. template &lt;class A&gt;
  5702. void set_rotx( A &amp; a, typename mat_traits&lt;A&gt;::scalar_type angle );
  5703. } }</code></pre>
  5704. </div>
  5705. </div>
  5706. <div class="dlist">
  5707. <dl>
  5708. <dt class="hdlist1">Effects: </dt>
  5709. <dd>
  5710. <p>As if:</p>
  5711. <div class="listingblock">
  5712. <div class="content">
  5713. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  5714. a,
  5715. rotx_mat&lt;mat_traits&lt;A&gt;::rows&gt;(angle));</code></pre>
  5716. </div>
  5717. </div>
  5718. </dd>
  5719. </dl>
  5720. </div>
  5721. <hr>
  5722. </div>
  5723. <div class="sect3">
  5724. <h4 id="mat_rotate_x"><code>rotate_x</code></h4>
  5725. <div class="listingblock">
  5726. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5727. <div class="content">
  5728. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5729. //Only enabled if:
  5730. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5731. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5732. template &lt;class A&gt;
  5733. void rotate_x( A &amp; a, typename mat_traits&lt;A&gt;::scalar_type angle );
  5734. } }</code></pre>
  5735. </div>
  5736. </div>
  5737. <div class="dlist">
  5738. <dl>
  5739. <dt class="hdlist1">Effects: </dt>
  5740. <dd>
  5741. <p>As if: <code>a <a href="#mat_mul_eq">*=</a> <a href="#rotx_mat">rotx_mat</a>&lt;<a href="#mat_traits">mat_traits&lt;A&gt;::rows</a>&gt;(angle)</code>.</p>
  5742. </dd>
  5743. </dl>
  5744. </div>
  5745. <hr>
  5746. </div>
  5747. <div class="sect3">
  5748. <h4 id="roty_mat"><code>roty_mat</code></h4>
  5749. <div class="listingblock">
  5750. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5751. <div class="content">
  5752. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5753. template &lt;int Dim,class Angle&gt;
  5754. -unspecified-return-type- roty_mat( Angle const &amp; angle );
  5755. } }</code></pre>
  5756. </div>
  5757. </div>
  5758. <div class="dlist">
  5759. <dl>
  5760. <dt class="hdlist1">Returns: </dt>
  5761. <dd>
  5762. <p>A <a href="#view_proxy">view proxy</a> matrix of unspecified type, of <code>Dim</code> rows and <code>Dim</code> columns and scalar type <code>Angle</code>, which performs a rotation around the <code>Y</code> axis at <code>angle</code> radians.</p>
  5763. </dd>
  5764. </dl>
  5765. </div>
  5766. <hr>
  5767. </div>
  5768. <div class="sect3">
  5769. <h4 id="mat_set_roty"><code>set_roty</code></h4>
  5770. <div class="listingblock">
  5771. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5772. <div class="content">
  5773. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5774. //Only enabled if:
  5775. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5776. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5777. template &lt;class A&gt;
  5778. void set_roty( A &amp; a, typename mat_traits&lt;A&gt;::scalar_type angle );
  5779. } }</code></pre>
  5780. </div>
  5781. </div>
  5782. <div class="dlist">
  5783. <dl>
  5784. <dt class="hdlist1">Effects: </dt>
  5785. <dd>
  5786. <p>As if:</p>
  5787. <div class="listingblock">
  5788. <div class="content">
  5789. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  5790. a,
  5791. roty_mat&lt;mat_traits&lt;A&gt;::rows&gt;(angle));</code></pre>
  5792. </div>
  5793. </div>
  5794. </dd>
  5795. </dl>
  5796. </div>
  5797. <hr>
  5798. </div>
  5799. <div class="sect3">
  5800. <h4 id="mat_rotate_y"><code>rotate_y</code></h4>
  5801. <div class="listingblock">
  5802. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5803. <div class="content">
  5804. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5805. //Only enabled if:
  5806. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5807. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5808. template &lt;class A&gt;
  5809. void rotate_y( A &amp; a, typename mat_traits&lt;A&gt;::scalar_type angle );
  5810. } }</code></pre>
  5811. </div>
  5812. </div>
  5813. <div class="dlist">
  5814. <dl>
  5815. <dt class="hdlist1">Effects: </dt>
  5816. <dd>
  5817. <p>As if: <code>a <a href="#mat_mul_eq">*=</a> <a href="#roty_mat">roty_mat</a>&lt;<a href="#mat_traits">mat_traits&lt;A&gt;::rows</a>&gt;(angle)</code>.</p>
  5818. </dd>
  5819. </dl>
  5820. </div>
  5821. <hr>
  5822. </div>
  5823. <div class="sect3">
  5824. <h4 id="rotz_mat"><code>rotz_mat</code></h4>
  5825. <div class="listingblock">
  5826. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5827. <div class="content">
  5828. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5829. template &lt;int Dim,class Angle&gt;
  5830. -unspecified-return-type- rotz_mat( Angle const &amp; angle );
  5831. } }</code></pre>
  5832. </div>
  5833. </div>
  5834. <div class="dlist">
  5835. <dl>
  5836. <dt class="hdlist1">Returns: </dt>
  5837. <dd>
  5838. <p>A <a href="#view_proxy">view proxy</a> matrix of unspecified type, of <code>Dim</code> rows and <code>Dim</code> columns and scalar type <code>Angle</code>, which performs a rotation around the <code>Z</code> axis at <code>angle</code> radians.</p>
  5839. </dd>
  5840. </dl>
  5841. </div>
  5842. <hr>
  5843. </div>
  5844. <div class="sect3">
  5845. <h4 id="mat_set_rotz"><code>set_rotz</code></h4>
  5846. <div class="listingblock">
  5847. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5848. <div class="content">
  5849. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5850. //Only enabled if:
  5851. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5852. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5853. template &lt;class A&gt;
  5854. void set_rotz( A &amp; a, typename mat_traits&lt;A&gt;::scalar_type angle );
  5855. } }</code></pre>
  5856. </div>
  5857. </div>
  5858. <div class="dlist">
  5859. <dl>
  5860. <dt class="hdlist1">Effects: </dt>
  5861. <dd>
  5862. <p>As if:</p>
  5863. <div class="listingblock">
  5864. <div class="content">
  5865. <pre class="CodeRay highlight nowrap"><code data-lang="c++">assign(
  5866. a,
  5867. rotz_mat&lt;mat_traits&lt;A&gt;::rows&gt;(angle));</code></pre>
  5868. </div>
  5869. </div>
  5870. </dd>
  5871. </dl>
  5872. </div>
  5873. <hr>
  5874. </div>
  5875. <div class="sect3">
  5876. <h4 id="mat_rotate_z"><code>rotate_z</code></h4>
  5877. <div class="listingblock">
  5878. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5879. <div class="content">
  5880. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5881. //Only enabled if:
  5882. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3 &amp;&amp;
  5883. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5884. template &lt;class A&gt;
  5885. void rotate_z( A &amp; a, typename mat_traits&lt;A&gt;::scalar_type angle );
  5886. } }</code></pre>
  5887. </div>
  5888. </div>
  5889. <div class="dlist">
  5890. <dl>
  5891. <dt class="hdlist1">Effects: </dt>
  5892. <dd>
  5893. <p>As if: <code>a <a href="#mat_mul_eq">*=</a> <a href="#rotz_mat">rotz_mat</a>&lt;<a href="#mat_traits">mat_traits&lt;A&gt;::rows</a>&gt;(angle)</code>.</p>
  5894. </dd>
  5895. </dl>
  5896. </div>
  5897. <hr>
  5898. </div>
  5899. <div class="sect3">
  5900. <h4 id="determinant"><code>determinant</code></h4>
  5901. <div class="listingblock">
  5902. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5903. <div class="content">
  5904. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5905. //Only enabled if:
  5906. // is_mat&lt;A&gt;::value &amp;&amp; mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols
  5907. template &lt;class A&gt;
  5908. mat_traits&lt;A&gt;::scalar_type
  5909. determinant( A const &amp; a );
  5910. } }</code></pre>
  5911. </div>
  5912. </div>
  5913. <div class="paragraph">
  5914. <p>This function computes the <a href="https://en.wikipedia.org/wiki/Determinant">determinant</a> of the square matrix <code>a</code>.</p>
  5915. </div>
  5916. <hr>
  5917. </div>
  5918. <div class="sect3">
  5919. <h4 id="perspective_lh"><code>perspective_lh</code></h4>
  5920. <div class="listingblock">
  5921. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5922. <div class="content">
  5923. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5924. template &lt;class T&gt;
  5925. -unspecified-return-type-
  5926. perspective_lh( T fov_y, T aspect, T zn, T zf );
  5927. } }</code></pre>
  5928. </div>
  5929. </div>
  5930. <div class="dlist">
  5931. <dl>
  5932. <dt class="hdlist1">Returns: </dt>
  5933. <dd>
  5934. <p>A 4x4 projection matrix of unspecified type of the following form:</p>
  5935. <table class="tableblock frame-all grid-all" style="width: 50%;">
  5936. <colgroup>
  5937. <col style="width: 25%;">
  5938. <col style="width: 25%;">
  5939. <col style="width: 25%;">
  5940. <col style="width: 25%;">
  5941. </colgroup>
  5942. <tbody>
  5943. <tr>
  5944. <td class="tableblock halign-center valign-top"><div class="verse"> <code>xs</code></div></td>
  5945. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5946. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5947. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5948. </tr>
  5949. <tr>
  5950. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5951. <td class="tableblock halign-center valign-top"><div class="verse"> <code>ys</code></div></td>
  5952. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5953. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5954. </tr>
  5955. <tr>
  5956. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5957. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5958. <td class="tableblock halign-center valign-top"><div class="verse"> <code>zf</code>/(<code>zf</code>-<code>zn</code>)</div></td>
  5959. <td class="tableblock halign-center valign-top"><div class="verse"> -<code>zn</code>*<code>zf</code>/(<code>zf</code>-<code>zn</code>)</div></td>
  5960. </tr>
  5961. <tr>
  5962. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5963. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5964. <td class="tableblock halign-center valign-top"><div class="verse"> 1</div></td>
  5965. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  5966. </tr>
  5967. </tbody>
  5968. </table>
  5969. <div class="paragraph">
  5970. <p>where <code>ys</code> = cot(<code>fov_y</code>/2) and <code>xs</code> = <code>ys</code>/<code>aspect</code>.</p>
  5971. </div>
  5972. </dd>
  5973. </dl>
  5974. </div>
  5975. <hr>
  5976. </div>
  5977. <div class="sect3">
  5978. <h4 id="perspective_rh"><code>perspective_rh</code></h4>
  5979. <div class="listingblock">
  5980. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  5981. <div class="content">
  5982. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  5983. template &lt;class T&gt;
  5984. -unspecified-return-type-
  5985. perspective_rh( T fov_y, T aspect, T zn, T zf );
  5986. } }</code></pre>
  5987. </div>
  5988. </div>
  5989. <div class="dlist">
  5990. <dl>
  5991. <dt class="hdlist1">Returns: </dt>
  5992. <dd>
  5993. <p>A 4x4 projection matrix of unspecified type of the following form:</p>
  5994. <table class="tableblock frame-all grid-all" style="width: 50%;">
  5995. <colgroup>
  5996. <col style="width: 25%;">
  5997. <col style="width: 25%;">
  5998. <col style="width: 25%;">
  5999. <col style="width: 25%;">
  6000. </colgroup>
  6001. <tbody>
  6002. <tr>
  6003. <td class="tableblock halign-center valign-top"><div class="verse"> <code>xs</code></div></td>
  6004. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6005. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6006. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6007. </tr>
  6008. <tr>
  6009. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6010. <td class="tableblock halign-center valign-top"><div class="verse"> <code>ys</code></div></td>
  6011. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6012. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6013. </tr>
  6014. <tr>
  6015. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6016. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6017. <td class="tableblock halign-center valign-top"><div class="verse"> <code>zf</code>/(<code>zn</code>-<code>zf</code>)</div></td>
  6018. <td class="tableblock halign-center valign-top"><div class="verse"> <code>zn</code>*<code>zf</code>/(<code>zn</code>-<code>zf</code>)</div></td>
  6019. </tr>
  6020. <tr>
  6021. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6022. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6023. <td class="tableblock halign-center valign-top"><div class="verse"> -1</div></td>
  6024. <td class="tableblock halign-center valign-top"><div class="verse"> 0</div></td>
  6025. </tr>
  6026. </tbody>
  6027. </table>
  6028. <div class="paragraph">
  6029. <p>where <code>ys</code> = cot(<code>fov_y</code>/2), and <code>xs</code> = <code>ys</code>/<code>aspect</code>.</p>
  6030. </div>
  6031. </dd>
  6032. </dl>
  6033. </div>
  6034. <hr>
  6035. </div>
  6036. <div class="sect3">
  6037. <h4 id="mat_scalar_cast"><code>scalar_cast</code></h4>
  6038. <div class="listingblock">
  6039. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  6040. <div class="content">
  6041. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6042. //Only enabled if: is_mat&lt;A&gt;::value
  6043. template &lt;class Scalar,class A&gt;
  6044. -unspecified-return_type- scalar_cast( A const &amp; a );
  6045. } }</code></pre>
  6046. </div>
  6047. </div>
  6048. <div class="dlist">
  6049. <dl>
  6050. <dt class="hdlist1">Returns: </dt>
  6051. <dd>
  6052. <p>A read-only <a href="#view_proxy">view proxy</a> of <code>a</code> that looks like a matrix of the same dimensions as <code>a</code>, but with <a href="#mat_traits"><code>scalar_type</code></a> <code>Scalar</code> and elements constructed from the corresponding elements of <code>a</code>.</p>
  6053. </dd>
  6054. </dl>
  6055. </div>
  6056. <hr>
  6057. </div>
  6058. <div class="sect3">
  6059. <h4 id="mref"><code>mref</code></h4>
  6060. <div class="listingblock">
  6061. <div class="title">#include &lt;boost/qvm/mat_operations.hpp&gt;</div>
  6062. <div class="content">
  6063. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6064. //Only enabled if: is_mat&lt;A&gt;::value
  6065. template &lt;class A&gt;
  6066. -unspecified-return-type- mref( A &amp; a );
  6067. } }</code></pre>
  6068. </div>
  6069. </div>
  6070. <div class="dlist">
  6071. <dl>
  6072. <dt class="hdlist1">Returns: </dt>
  6073. <dd>
  6074. <p>An identity view proxy of <code>a</code>; that is, it simply accesses the elements of <code>a</code>.</p>
  6075. </dd>
  6076. </dl>
  6077. </div>
  6078. <div class="admonitionblock tip">
  6079. <table>
  6080. <tr>
  6081. <td class="icon">
  6082. <i class="fa icon-tip" title="Tip"></i>
  6083. </td>
  6084. <td class="content">
  6085. <code>mref</code> allows calling QVM operations when <code>a</code> is of built-in type, for example a plain old C array.
  6086. </td>
  6087. </tr>
  6088. </table>
  6089. </div>
  6090. <hr>
  6091. </div>
  6092. </div>
  6093. <div class="sect2">
  6094. <h3 id="_quaternion_vector_operations">Quaternion-Vector Operations</h3>
  6095. <div class="sect3">
  6096. <h4 id="quat_vec_mul"><code>operator*</code></h4>
  6097. <div class="listingblock">
  6098. <div class="title">#include &lt;boost/qvm/quat_vec_operations.hpp&gt;</div>
  6099. <div class="content">
  6100. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6101. //Only enabled if:
  6102. // is_mat&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  6103. // mat_traits&lt;A&gt;::cols==vec_traits&lt;B&gt;::dim
  6104. template &lt;class A,class B&gt;
  6105. typename deduce_vec2&lt;A,B,mat_traits&lt;A&gt;::rows&gt;::type
  6106. operator*( A const &amp; a, B const &amp; b );
  6107. } }</code></pre>
  6108. </div>
  6109. </div>
  6110. <div class="dlist">
  6111. <dl>
  6112. <dt class="hdlist1">Returns: </dt>
  6113. <dd>
  6114. <p>The result of transforming the vector <code>b</code> by the quaternion <code>a</code>.</p>
  6115. </dd>
  6116. </dl>
  6117. </div>
  6118. <div class="admonitionblock note">
  6119. <table>
  6120. <tr>
  6121. <td class="icon">
  6122. <i class="fa icon-note" title="Note"></i>
  6123. </td>
  6124. <td class="content">
  6125. The <a href="#deduce_vec2"><code>deduce_vec2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  6126. </td>
  6127. </tr>
  6128. </table>
  6129. </div>
  6130. <hr>
  6131. </div>
  6132. </div>
  6133. <div class="sect2">
  6134. <h3 id="_matrix_vector_operations">Matrix-Vector Operations</h3>
  6135. <div class="sect3">
  6136. <h4 id="mat_vec_mul"><code>operator*</code></h4>
  6137. <div class="listingblock">
  6138. <div class="title">#include &lt;boost/qvm/vec_mat_operations.hpp&gt;</div>
  6139. <div class="content">
  6140. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6141. //Only enabled if:
  6142. // is_mat&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  6143. // mat_traits&lt;A&gt;::cols==vec_traits&lt;B&gt;::dim
  6144. template &lt;class A,class B&gt;
  6145. typename deduce_vec2&lt;A,B,mat_traits&lt;A&gt;::rows&gt;::type
  6146. operator*( A const &amp; a, B const &amp; b );
  6147. } }</code></pre>
  6148. </div>
  6149. </div>
  6150. <div class="dlist">
  6151. <dl>
  6152. <dt class="hdlist1">Returns: </dt>
  6153. <dd>
  6154. <p>The result of multiplying the matrix <code>a</code> and the vector <code>b</code>, where <code>b</code> is interpreted as a matrix-column. The resulting matrix-row is returned as a vector type.</p>
  6155. </dd>
  6156. </dl>
  6157. </div>
  6158. <div class="admonitionblock note">
  6159. <table>
  6160. <tr>
  6161. <td class="icon">
  6162. <i class="fa icon-note" title="Note"></i>
  6163. </td>
  6164. <td class="content">
  6165. The <a href="#deduce_vec2"><code>deduce_vec2</code></a> template can be specialized to deduce the desired return type, given the types <code>A</code> and <code>B</code>.
  6166. </td>
  6167. </tr>
  6168. </table>
  6169. </div>
  6170. <hr>
  6171. </div>
  6172. <div class="sect3">
  6173. <h4 id="transform_vector"><code>transform_vector</code></h4>
  6174. <div class="listingblock">
  6175. <div class="title">#include &lt;boost/qvm/vec_mat_operations.hpp&gt;</div>
  6176. <div class="content">
  6177. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6178. //Only enabled if:
  6179. // is_mat&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  6180. // mat_traits&lt;A&gt;::rows==4 &amp;&amp; mat_traits&lt;A&gt;::cols==4 &amp;&amp;
  6181. // vec_traits&lt;B&gt;::dim==3
  6182. template &lt;class A,class B&gt;
  6183. deduce_vec2&lt;A,B,3&gt; &gt;::type
  6184. transform_vector( A const &amp; a, B const &amp; b );
  6185. } }</code></pre>
  6186. </div>
  6187. </div>
  6188. <div class="dlist">
  6189. <dl>
  6190. <dt class="hdlist1">Effects: </dt>
  6191. <dd>
  6192. <p>As if: <code>return a <a href="#mat_vec_mul">*</a> <a href="#swizzling">XYZ0</a>(b)</code>.</p>
  6193. </dd>
  6194. </dl>
  6195. </div>
  6196. <hr>
  6197. </div>
  6198. <div class="sect3">
  6199. <h4 id="transform_point"><code>transform_point</code></h4>
  6200. <div class="listingblock">
  6201. <div class="title">#include &lt;boost/qvm/vec_mat_operations.hpp&gt;</div>
  6202. <div class="content">
  6203. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6204. //Only enabled if:
  6205. // is_mat&lt;A&gt;::value &amp;&amp; is_vec&lt;B&gt;::value &amp;&amp;
  6206. // mat_traits&lt;A&gt;::rows==4 &amp;&amp; mat_traits&lt;A&gt;::cols==4 &amp;&amp;
  6207. // vec_traits&lt;B&gt;::dim==3
  6208. template &lt;class A,class B&gt;
  6209. deduce_vec2&lt;A,B,3&gt; &gt;::type
  6210. transform_point( A const &amp; a, B const &amp; b );
  6211. } }</code></pre>
  6212. </div>
  6213. </div>
  6214. <div class="dlist">
  6215. <dl>
  6216. <dt class="hdlist1">Effects: </dt>
  6217. <dd>
  6218. <p>As if: <code>return a <a href="#mat_vec_mul">*</a> <a href="#swizzling">XYZ1</a>(b)</code>.</p>
  6219. </dd>
  6220. </dl>
  6221. </div>
  6222. <hr>
  6223. </div>
  6224. </div>
  6225. <div class="sect2">
  6226. <h3 id="_matrix_to_matrix_view_proxies">Matrix-to-Matrix View Proxies</h3>
  6227. <div class="sect3">
  6228. <h4 id="del_row"><code>del_row</code></h4>
  6229. <div class="listingblock">
  6230. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6231. <div class="content">
  6232. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6233. template &lt;int R&gt;
  6234. -unspecified-return-type- del_row();
  6235. } }</code></pre>
  6236. </div>
  6237. </div>
  6238. <div class="paragraph">
  6239. <p>The expression <code>del_row&lt;R&gt;(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that looks like the matrix <code>m</code> with row <code>R</code> deleted.</p>
  6240. </div>
  6241. <hr>
  6242. </div>
  6243. <div class="sect3">
  6244. <h4 id="del_col"><code>del_col</code></h4>
  6245. <div class="listingblock">
  6246. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6247. <div class="content">
  6248. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6249. template &lt;int C&gt;
  6250. -unspecified-return-type- del_col();
  6251. } }</code></pre>
  6252. </div>
  6253. </div>
  6254. <div class="paragraph">
  6255. <p>The expression <code>del_col&lt;C&gt;(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that looks like the matrix <code>m</code> with column <code>C</code> deleted.</p>
  6256. </div>
  6257. <hr>
  6258. </div>
  6259. <div class="sect3">
  6260. <h4 id="del_row_col"><code>del_row_col</code></h4>
  6261. <div class="listingblock">
  6262. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6263. <div class="content">
  6264. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6265. template &lt;int R,int C&gt;
  6266. -unspecified-return-type- del_row_col();
  6267. } }</code></pre>
  6268. </div>
  6269. </div>
  6270. <div class="paragraph">
  6271. <p>The expression <code>del_row_col&lt;R,C&gt;(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that looks like the matrix <code>m</code> with row <code>R</code> and column <code>C</code> deleted.</p>
  6272. </div>
  6273. <hr>
  6274. </div>
  6275. <div class="sect3">
  6276. <h4 id="neg_row"><code>neg_row</code></h4>
  6277. <div class="listingblock">
  6278. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6279. <div class="content">
  6280. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6281. template &lt;int R&gt;
  6282. -unspecified-return-type- neg_row();
  6283. } }</code></pre>
  6284. </div>
  6285. </div>
  6286. <div class="paragraph">
  6287. <p>The expression <code>neg_row&lt;R&gt;(m)</code> returns a read-only <a href="#view_proxy">view proxy</a> that looks like the matrix <code>m</code> with row <code>R</code> negated.</p>
  6288. </div>
  6289. <hr>
  6290. </div>
  6291. <div class="sect3">
  6292. <h4 id="neg_col"><code>neg_col</code></h4>
  6293. <div class="listingblock">
  6294. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6295. <div class="content">
  6296. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6297. template &lt;int C&gt;
  6298. -unspecified-return-type- neg_col();
  6299. } }</code></pre>
  6300. </div>
  6301. </div>
  6302. <div class="literalblock">
  6303. <div class="content">
  6304. <pre class="nowrap">The expression `neg_col&lt;C&gt;(m)` returns a read-only &lt;&lt;view_proxy,`view proxy`&gt;&gt; that looks like the matrix `m` with column `C` negated.</pre>
  6305. </div>
  6306. </div>
  6307. <hr>
  6308. </div>
  6309. <div class="sect3">
  6310. <h4 id="swap_rows"><code>swap_rows</code></h4>
  6311. <div class="listingblock">
  6312. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6313. <div class="content">
  6314. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6315. template &lt;int R1,int R2&gt;
  6316. -unspecified-return-type- swap_rows();
  6317. } }</code></pre>
  6318. </div>
  6319. </div>
  6320. <div class="paragraph">
  6321. <p>The expression <code>swap_rows&lt;R1,R2&gt;(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that looks like the matrix <code>m</code> with rows <code>R1</code> and <code>R2</code> swapped.</p>
  6322. </div>
  6323. <hr>
  6324. </div>
  6325. <div class="sect3">
  6326. <h4 id="swap_cols"><code>swap_cols</code></h4>
  6327. <div class="listingblock">
  6328. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6329. <div class="content">
  6330. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6331. template &lt;int C1,int C2&gt;
  6332. -unspecified-return-type- swap_cols();
  6333. } }</code></pre>
  6334. </div>
  6335. </div>
  6336. <div class="paragraph">
  6337. <p>The expression <code>swap_cols&lt;C1,C2&gt;(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that looks like the matrix <code>m</code> with columns <code>C1</code> and <code>C2</code> swapped.</p>
  6338. </div>
  6339. <hr>
  6340. </div>
  6341. <div class="sect3">
  6342. <h4 id="transposed"><code>transposed</code></h4>
  6343. <div class="listingblock">
  6344. <div class="title">#include &lt;boost/qvm/map_mat_mat.hpp&gt;</div>
  6345. <div class="content">
  6346. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6347. -unspecified-return-type- transposed();
  6348. } }</code></pre>
  6349. </div>
  6350. </div>
  6351. <div class="paragraph">
  6352. <p>The expression <code>transposed(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that transposes the matrix <code>m</code>.</p>
  6353. </div>
  6354. <hr>
  6355. </div>
  6356. </div>
  6357. <div class="sect2">
  6358. <h3 id="_vector_to_matrix_view_proxies">Vector-to-Matrix View Proxies</h3>
  6359. <div class="sect3">
  6360. <h4 id="col_mat"><code>col_mat</code></h4>
  6361. <div class="listingblock">
  6362. <div class="title">#include &lt;boost/qvm/map_vec_mat.hpp&gt;</div>
  6363. <div class="content">
  6364. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6365. //Only enabled if: is_vec&lt;A&gt;::value
  6366. template &lt;iclass A&gt;
  6367. -unspecified-return-type- col_mat( A &amp; a );
  6368. } }</code></pre>
  6369. </div>
  6370. </div>
  6371. <div class="paragraph">
  6372. <p>The expression <code>col_mat(v)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses the vector <code>v</code> as a matrix-column.</p>
  6373. </div>
  6374. <hr>
  6375. </div>
  6376. <div class="sect3">
  6377. <h4 id="row_mat"><code>row_mat</code></h4>
  6378. <div class="listingblock">
  6379. <div class="title">#include &lt;boost/qvm/map_vec_mat.hpp&gt;</div>
  6380. <div class="content">
  6381. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6382. //Only enabled if: is_vec&lt;A&gt;::value
  6383. template &lt;iclass A&gt;
  6384. -unspecified-return-type- row_mat( A &amp; a );
  6385. } }</code></pre>
  6386. </div>
  6387. </div>
  6388. <div class="paragraph">
  6389. <p>The expression <code>row_mat(v)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses the vector <code>v</code> as a matrix-row.</p>
  6390. </div>
  6391. <hr>
  6392. </div>
  6393. <div class="sect3">
  6394. <h4 id="translation_mat"><code>translation_mat</code></h4>
  6395. <div class="listingblock">
  6396. <div class="title">#include &lt;boost/qvm/map_vec_mat.hpp&gt;</div>
  6397. <div class="content">
  6398. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6399. //Only enabled if: is_vec&lt;A&gt;::value
  6400. template &lt;iclass A&gt;
  6401. -unspecified-return-type- translation_mat( A &amp; a );
  6402. } }</code></pre>
  6403. </div>
  6404. </div>
  6405. <div class="paragraph">
  6406. <p>The expression <code>translation_mat(v)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses the vector <code>v</code> as translation matrix of size 1 + <a href="#vec_traits"><code>vec_traits&lt;A&gt;::dim</code></a>.</p>
  6407. </div>
  6408. <hr>
  6409. </div>
  6410. <div class="sect3">
  6411. <h4 id="diag_mat"><code>diag_mat</code></h4>
  6412. <div class="listingblock">
  6413. <div class="title">#include &lt;boost/qvm/map_vec_mat.hpp&gt;</div>
  6414. <div class="content">
  6415. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6416. //Only enabled if: is_vec&lt;A&gt;::value
  6417. template &lt;iclass A&gt;
  6418. -unspecified-return-type- diag_mat( A &amp; a );
  6419. } }</code></pre>
  6420. </div>
  6421. </div>
  6422. <div class="paragraph">
  6423. <p>The expression <code>diag_mat(v)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses the vector <code>v</code> as a square matrix of the same dimensions in which the elements of <code>v</code> appear as the main diagonal and all other elements are zero.</p>
  6424. </div>
  6425. <div class="admonitionblock tip">
  6426. <table>
  6427. <tr>
  6428. <td class="icon">
  6429. <i class="fa icon-tip" title="Tip"></i>
  6430. </td>
  6431. <td class="content">
  6432. If <code>v</code> is a 3D vector, the expression <code>diag_mat(XYZ1(v))</code> can be used as a scaling 4D matrix.
  6433. </td>
  6434. </tr>
  6435. </table>
  6436. </div>
  6437. <hr>
  6438. </div>
  6439. </div>
  6440. <div class="sect2">
  6441. <h3 id="_matrix_to_vector_view_proxies">Matrix-to-Vector View Proxies</h3>
  6442. <div class="sect3">
  6443. <h4 id="col"><code>col</code></h4>
  6444. <div class="listingblock">
  6445. <div class="title">#include &lt;boost/qvm/map_mat_vec.hpp&gt;</div>
  6446. <div class="content">
  6447. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6448. //Only enabled if: is_mat&lt;A&gt;::value
  6449. template &lt;int C,class A&gt;
  6450. -unspecified-return-type- col( A &amp; a );
  6451. } }</code></pre>
  6452. </div>
  6453. </div>
  6454. <div class="paragraph">
  6455. <p>The expression <code>col&lt;C&gt;(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses column <code>C</code> of the matrix <code>m</code> as a vector.</p>
  6456. </div>
  6457. <hr>
  6458. </div>
  6459. <div class="sect3">
  6460. <h4 id="row"><code>row</code></h4>
  6461. <div class="listingblock">
  6462. <div class="title">#include &lt;boost/qvm/map_mat_vec.hpp&gt;</div>
  6463. <div class="content">
  6464. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6465. //Only enabled if: is_mat&lt;A&gt;::value
  6466. template &lt;int C,class A&gt;
  6467. -unspecified-return-type- row( A &amp; a );
  6468. } }</code></pre>
  6469. </div>
  6470. </div>
  6471. <div class="paragraph">
  6472. <p>The expression <code>row&lt;R&gt;(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses row <code>R</code> of the matrix <code>m</code> as a vector.</p>
  6473. </div>
  6474. <hr>
  6475. </div>
  6476. <div class="sect3">
  6477. <h4 id="diag"><code>diag</code></h4>
  6478. <div class="listingblock">
  6479. <div class="title">#include &lt;boost/qvm/map_mat_vec.hpp&gt;</div>
  6480. <div class="content">
  6481. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6482. //Only enabled if: is_mat&lt;A&gt;::value
  6483. template &lt;class A&gt;
  6484. -unspecified-return-type- diag( A &amp; a );
  6485. } }</code></pre>
  6486. </div>
  6487. </div>
  6488. <div class="paragraph">
  6489. <p>The expression <code>diag(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses the main diagonal of the matrix <code>m</code> as a vector.</p>
  6490. </div>
  6491. <hr>
  6492. </div>
  6493. <div class="sect3">
  6494. <h4 id="translation"><code>translation</code></h4>
  6495. <div class="listingblock">
  6496. <div class="title">#include &lt;boost/qvm/map_mat_vec.hpp&gt;</div>
  6497. <div class="content">
  6498. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6499. //Only enabled if:
  6500. // is_mat&lt;A&gt;::value &amp;&amp;
  6501. // mat_traits&lt;A&gt;::rows==mat_traits&lt;A&gt;::cols &amp;&amp; mat_traits&lt;A&gt;::rows&gt;=3
  6502. template &lt;class A&gt;
  6503. -unspecified-return-type- translation( A &amp; a );
  6504. } }</code></pre>
  6505. </div>
  6506. </div>
  6507. <div class="paragraph">
  6508. <p>The expression <code>translation(m)</code> returns an lvalue <a href="#view_proxy">view proxy</a> that accesses the translation component of the square matrix <code>m</code>, which is a vector of size <code>D</code>-1, where <code>D</code> is the size of <code>m</code>.</p>
  6509. </div>
  6510. <hr>
  6511. </div>
  6512. </div>
  6513. <div class="sect2">
  6514. <h3 id="_exceptions">Exceptions</h3>
  6515. <div class="sect3">
  6516. <h4 id="error"><code>error</code></h4>
  6517. <div class="listingblock">
  6518. <div class="title">#include &lt;boost/qvm/error.hpp&gt;</div>
  6519. <div class="content">
  6520. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6521. struct error: virtual boost::exception, virtual std::exception { };
  6522. } }</code></pre>
  6523. </div>
  6524. </div>
  6525. <div class="paragraph">
  6526. <p>This is the base for all exceptions thorwn by QVM.</p>
  6527. </div>
  6528. <hr>
  6529. </div>
  6530. <div class="sect3">
  6531. <h4 id="zero_magnitude_error"><code>zero_magnitude_error</code></h4>
  6532. <div class="listingblock">
  6533. <div class="title">#include &lt;boost/qvm/error.hpp&gt;</div>
  6534. <div class="content">
  6535. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6536. struct zero_magnitude_error: virtual error { };
  6537. } }</code></pre>
  6538. </div>
  6539. </div>
  6540. <div class="paragraph">
  6541. <p>This exception indicates that an operation requires a vector or a quaternion with non-zero magnitude, but the computed magnitude is zero.</p>
  6542. </div>
  6543. <hr>
  6544. </div>
  6545. <div class="sect3">
  6546. <h4 id="zero_determinant_error"><code>zero_determinant_error</code></h4>
  6547. <div class="listingblock">
  6548. <div class="title">#include &lt;boost/qvm/error.hpp&gt;</div>
  6549. <div class="content">
  6550. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6551. struct zero_determinant_error: virtual error { };
  6552. } }</code></pre>
  6553. </div>
  6554. </div>
  6555. <div class="paragraph">
  6556. <p>This exception indicates that an operation requires a matrix with non-zero determinant, but the computed determinant is zero.</p>
  6557. </div>
  6558. <hr>
  6559. </div>
  6560. </div>
  6561. <div class="sect2">
  6562. <h3 id="_macros_and_configuration_boost_qvm">Macros and Configuration: BOOST_QVM_</h3>
  6563. <div class="sect3">
  6564. <h4 id="BOOST_QVM_INLINE"><code>INLINE</code></h4>
  6565. <div class="sect4">
  6566. <h5 id="_boost_qvm_inline"><code>BOOST_QVM_INLINE</code></h5>
  6567. <div class="listingblock">
  6568. <div class="title">#include &lt;boost/qvm/inline.hpp&gt;</div>
  6569. <div class="content">
  6570. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6571. #ifndef BOOST_QVM_INLINE
  6572. #define BOOST_QVM_INLINE inline
  6573. #endif
  6574. } }</code></pre>
  6575. </div>
  6576. </div>
  6577. <div class="paragraph">
  6578. <p>This macro is not used directly by QVM, except as the default value of other macros from <code>&lt;boost/qvm/inline.hpp&gt;</code>. A user-defined <code>BOOST_QVM_INLINE</code> should expand to a value that is valid substitution of the <code>inline</code> keyword in function definitions.</p>
  6579. </div>
  6580. <hr>
  6581. </div>
  6582. </div>
  6583. <div class="sect3">
  6584. <h4 id="BOOST_QVM_FORCE_INLINE"><code>FORCE_INLINE</code></h4>
  6585. <div class="sect4">
  6586. <h5 id="_boost_qvm_force_inline"><code>BOOST_QVM_FORCE_INLINE</code></h5>
  6587. <div class="listingblock">
  6588. <div class="title">#include &lt;boost/qvm/inline.hpp&gt;</div>
  6589. <div class="content">
  6590. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6591. #ifndef BOOST_QVM_FORCE_INLINE
  6592. #define BOOST_QVM_FORCE_INLINE /*platform-specific*/
  6593. #endif
  6594. } }</code></pre>
  6595. </div>
  6596. </div>
  6597. <div class="paragraph">
  6598. <p>This macro is not used directly by QVM, except as the default value of other macros from <code>&lt;boost/qvm/inline.hpp&gt;</code>. A user-defined <code>BOOST_QVM_FORCE_INLINE</code> should expand to a value that is valid substitution of the <code>inline</code> keyword in function definitions, to indicate that the compiler must inline the function. Of course, actual inlining may or may not occur.</p>
  6599. </div>
  6600. <hr>
  6601. </div>
  6602. </div>
  6603. <div class="sect3">
  6604. <h4 id="BOOST_QVM_INLINE_TRIVIAL"><code>INLINE_TRIVIAL</code></h4>
  6605. <div class="sect4">
  6606. <h5 id="_boost_qvm_inline_trivial"><code>BOOST_QVM_INLINE_TRIVIAL</code></h5>
  6607. <div class="listingblock">
  6608. <div class="title">#include &lt;boost/qvm/inline.hpp&gt;</div>
  6609. <div class="content">
  6610. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6611. #ifndef BOOST_QVM_INLINE_TRIVIAL
  6612. #define BOOST_QVM_INLINE_TRIVIAL BOOST_QVM_FORCE_INLINE
  6613. #endif
  6614. } }</code></pre>
  6615. </div>
  6616. </div>
  6617. <div class="paragraph">
  6618. <p>QVM uses <code>BOOST_QVM_INLINE_TRIVIAL</code> in definitions of functions that are not critical for the overall performance of the library but are extremely simple (such as one-liners) and therefore should always be inlined.</p>
  6619. </div>
  6620. <hr>
  6621. </div>
  6622. </div>
  6623. <div class="sect3">
  6624. <h4 id="BOOST_QVM_INLINE_CRITICAL"><code>INLINE_CRITICAL</code></h4>
  6625. <div class="sect4">
  6626. <h5 id="_boost_qvm_inline_critical"><code>BOOST_QVM_INLINE_CRITICAL</code></h5>
  6627. <div class="listingblock">
  6628. <div class="title">#include &lt;boost/qvm/inline.hpp&gt;</div>
  6629. <div class="content">
  6630. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6631. #ifndef BOOST_QVM_INLINE_CRITICAL
  6632. #define BOOST_QVM_INLINE_CRITICAL BOOST_QVM_FORCE_INLINE
  6633. #endif
  6634. } }</code></pre>
  6635. </div>
  6636. </div>
  6637. <div class="paragraph">
  6638. <p>QVM uses <code>BOOST_QVM_INLINE_CRITICAL</code> in definitions of functions that are critical for the overall performance of the library, such as functions that access individual vector and matrix elements.</p>
  6639. </div>
  6640. <hr>
  6641. </div>
  6642. </div>
  6643. <div class="sect3">
  6644. <h4 id="BOOST_QVM_INLINE_OPERATIONS"><code>INLINE_OPERATIONS</code></h4>
  6645. <div class="sect4">
  6646. <h5 id="_boost_qvm_inline_operations"><code>BOOST_QVM_INLINE_OPERATIONS</code></h5>
  6647. <div class="listingblock">
  6648. <div class="title">#include &lt;boost/qvm/inline.hpp&gt;</div>
  6649. <div class="content">
  6650. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6651. #ifndef BOOST_QVM_INLINE_OPERATIONS
  6652. #define BOOST_QVM_INLINE_OPERATIONS BOOST_QVM_INLINE
  6653. #endif
  6654. } }</code></pre>
  6655. </div>
  6656. </div>
  6657. <div class="paragraph">
  6658. <p>QVM uses <code>BOOST_QVM_INLINE_OPERATIONS</code> in definitions of functions that implement various high-level operations, such as matrix multiplication, computing the magnitude of a vector, etc.</p>
  6659. </div>
  6660. <hr>
  6661. </div>
  6662. </div>
  6663. <div class="sect3">
  6664. <h4 id="BOOST_QVM_INLINE_RECURSION"><code>INLINE_RECURSION</code></h4>
  6665. <div class="sect4">
  6666. <h5 id="_boost_qvm_inline_recursion"><code>BOOST_QVM_INLINE_RECURSION</code></h5>
  6667. <div class="listingblock">
  6668. <div class="title">#include &lt;boost/qvm/inline.hpp&gt;</div>
  6669. <div class="content">
  6670. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6671. #ifndef BOOST_QVM_INLINE_RECURSION
  6672. #define BOOST_QVM_INLINE_RECURSION BOOST_QVM_INLINE_OPERATIONS
  6673. #endif
  6674. } }</code></pre>
  6675. </div>
  6676. </div>
  6677. <div class="paragraph">
  6678. <p>QVM uses <code>BOOST_QVM_INLINE_RECURSION</code> in definitions of recursive functions that are not critical for the overall performance of the library (definitions of all critical functions, including critical recursive functions, use <a href="#BOOST_QVM_INLINE_CRITICAL"><code>BOOST_QVM_INLINE_CRITICAL</code></a>).</p>
  6679. </div>
  6680. <hr>
  6681. </div>
  6682. </div>
  6683. <div class="sect3">
  6684. <h4 id="BOOST_QVM_ASSERT"><code>ASSERT</code></h4>
  6685. <div class="sect4">
  6686. <h5 id="_boost_qvm_assert"><code>BOOST_QVM_ASSERT</code></h5>
  6687. <div class="listingblock">
  6688. <div class="title">#include &lt;boost/qvm/assert.hpp&gt;</div>
  6689. <div class="content">
  6690. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6691. #ifndef BOOST_QVM_ASSERT
  6692. #include &lt;boost/assert.hpp&gt;
  6693. #define BOOST_QVM_ASSERT BOOST_ASSERT
  6694. #endif
  6695. } }</code></pre>
  6696. </div>
  6697. </div>
  6698. <div class="paragraph">
  6699. <p>This is the macro QVM uses to assert on precondition violations and logic errors. A user-defined <code>BOOST_QVM_ASSERT</code> should have the semantics of the standard <code>assert</code>.</p>
  6700. </div>
  6701. <hr>
  6702. </div>
  6703. </div>
  6704. <div class="sect3">
  6705. <h4 id="BOOST_QVM_STATIC_ASSERT"><code>STATIC_ASSERT</code></h4>
  6706. <div class="sect4">
  6707. <h5 id="_boost_qvm_static_assert"><code>BOOST_QVM_STATIC_ASSERT</code></h5>
  6708. <div class="listingblock">
  6709. <div class="title">#include &lt;boost/qvm/static_assert.hpp&gt;</div>
  6710. <div class="content">
  6711. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6712. #ifndef BOOST_QVM_STATIC_ASSERT
  6713. #include &lt;boost/static_assert.hpp&gt;
  6714. #define BOOST_QVM_STATIC_ASSERT BOOST_STATIC_ASSERT
  6715. #endif
  6716. } }</code></pre>
  6717. </div>
  6718. </div>
  6719. <div class="paragraph">
  6720. <p>All static assertions in QVM use the <code>BOOST_QVM_STATIC_ASSERT</code> macro.</p>
  6721. </div>
  6722. <hr>
  6723. </div>
  6724. </div>
  6725. <div class="sect3">
  6726. <h4 id="BOOST_QVM_THROW_EXCEPTION"><code>THROW_EXCEPTION</code></h4>
  6727. <div class="sect4">
  6728. <h5 id="_boost_qvm_throw_exception"><code>BOOST_QVM_THROW_EXCEPTION</code></h5>
  6729. <div class="listingblock">
  6730. <div class="title">#include &lt;boost/qvm/throw_exception.hpp&gt;</div>
  6731. <div class="content">
  6732. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace boost { namespace qvm {
  6733. #ifndef BOOST_QVM_THROW_EXCEPTION
  6734. #include &lt;boost/throw_exception.hpp&gt;
  6735. #define BOOST_QVM_THROW_EXCEPTION BOOST_THROW_EXCEPTION
  6736. #endif
  6737. } }</code></pre>
  6738. </div>
  6739. </div>
  6740. <div class="paragraph">
  6741. <p>This macro is used whenever QVM throws an exception. Users who override the standard <code>BOOST_QVM_THROW_EXCEPTION</code> behavior must ensure that when invoked, the substituted implementation does not return control to the caller. Below is a list of all QVM functions that invoke <code>BOOST_QVM_THROW_EXCEPTION</code>:</p>
  6742. </div>
  6743. <div class="ulist">
  6744. <ul>
  6745. <li>
  6746. <p>Quaternion operations:</p>
  6747. <div class="ulist">
  6748. <ul>
  6749. <li>
  6750. <p><a href="#quat_inverse"><code>inverse</code></a></p>
  6751. </li>
  6752. <li>
  6753. <p><a href="#rot_quat"><code>rot_quat</code></a></p>
  6754. </li>
  6755. <li>
  6756. <p><a href="#quat_normalize"><code>normalize</code></a></p>
  6757. </li>
  6758. <li>
  6759. <p><a href="#quat_normalized"><code>normalized</code></a></p>
  6760. </li>
  6761. </ul>
  6762. </div>
  6763. </li>
  6764. <li>
  6765. <p>Vector operations:</p>
  6766. <div class="ulist">
  6767. <ul>
  6768. <li>
  6769. <p><a href="#vec_normalize"><code>normalize</code></a></p>
  6770. </li>
  6771. <li>
  6772. <p><a href="#vec_normalized"><code>normalized</code></a></p>
  6773. </li>
  6774. </ul>
  6775. </div>
  6776. </li>
  6777. <li>
  6778. <p>Matrix operations:</p>
  6779. <div class="ulist">
  6780. <ul>
  6781. <li>
  6782. <p><a href="#mat_inverse"><code>inverse</code></a></p>
  6783. </li>
  6784. <li>
  6785. <p><a href="#rot_mat"><code>rot_mat</code></a></p>
  6786. </li>
  6787. </ul>
  6788. </div>
  6789. </li>
  6790. </ul>
  6791. </div>
  6792. </div>
  6793. </div>
  6794. </div>
  6795. </div>
  6796. </div>
  6797. <div class="sect1">
  6798. <h2 id="rationale">Design Rationale</h2>
  6799. <div class="sectionbody">
  6800. <div class="paragraph">
  6801. <p>C&#43;&#43; is ideal for 3D graphics and other domains that require 3D transformations: define vector and matrix types and then overload the appropriate operators to implement the standard algebraic operations. Because this is relatively straight-forward, there are many libraries that do this, each providing custom vector and matrix types, and then defining the same operations (e.g. matrix multiply) for these types.</p>
  6802. </div>
  6803. <div class="paragraph">
  6804. <p>Often these libraries are part of a higher level system. For example, video game programmers typically use one set of vector/matrix types with the rendering engine, and another with the physics simulation engine.</p>
  6805. </div>
  6806. <div class="paragraph">
  6807. <p>QVM proides interoperability between all these different types and APIs by decoupling the standard algebraic functions from the types they operate on&#8201;&#8212;&#8201;without compromising type safety. The operations work on any type for which proper traits have been specialized. Using QVM, there is no need to translate between the different quaternion, vector or matrix types; they can be mixed in the same expression safely and efficiently.</p>
  6808. </div>
  6809. <div class="paragraph">
  6810. <p>This design enables QVM to generate types and adaptors at compile time, compatible with any other QVM or user-defined type. For example, transposing a matrix needs not store the result: rather than modifying its argument or returning a new object, it simply binds the original matrix object through a generated type which remaps element access on the fly.</p>
  6811. </div>
  6812. <div class="paragraph">
  6813. <p>In addition, QVM can be helpful in selectively optimizing individual types or operations for maximum performance where that matters. For example, users can overload a specific operation for specific types, or define highly optimized, possibly platform-specific or for some reason cumbersome to use types, then mix and match them with more user-friendly types in parts of the program where performance isn&#8217;t critical.</p>
  6814. </div>
  6815. </div>
  6816. </div>
  6817. <div class="sect1">
  6818. <h2 id="_code_generator">Code Generator</h2>
  6819. <div class="sectionbody">
  6820. <div class="paragraph">
  6821. <p>While QVM defines generic functions that operate on matrix and vector types of arbitrary static dimensions, it also provides a code generator that can be used to create compatible header files that define much simpler specializations of these functions for specific dimensions. This is useful during debugging since the generated code is much easier to read than the template metaprogramming-heavy generic implementations. It is also potentially friendlier to the optimizer.</p>
  6822. </div>
  6823. <div class="paragraph">
  6824. <p>The code generator is a command-line utility program. Its source code can be found in the <code>boost/libs/qvm/gen</code> directory. It was used to generate the following headers that ship with QVM:</p>
  6825. </div>
  6826. <div class="ulist">
  6827. <ul>
  6828. <li>
  6829. <p>2D, 3D and 4D matrix operations:</p>
  6830. <div class="ulist">
  6831. <ul>
  6832. <li>
  6833. <p><code>boost/qvm/gen/mat_operations2.hpp</code> (matrices of size 2x2, 2x1 and 1x2, included by <code>boost/qvm/mat_operations2.hpp</code>)</p>
  6834. </li>
  6835. <li>
  6836. <p><code>boost/qvm/gen/mat_operations3.hpp</code> (matrices of size 3x3, 3x1 and 1x3, included by <code>boost/qvm/mat_operations3.hpp</code>)</p>
  6837. </li>
  6838. <li>
  6839. <p><code>boost/qvm/gen/mat_operations4.hpp</code> (matrices of size 4x4, 4x1 and 1x4, included by <code>boost/qvm/mat_operations4.hpp</code>)</p>
  6840. </li>
  6841. </ul>
  6842. </div>
  6843. </li>
  6844. <li>
  6845. <p>2D, 3D and 4D vector operations:</p>
  6846. <div class="ulist">
  6847. <ul>
  6848. <li>
  6849. <p><code>boost/qvm/gen/v2.hpp</code> (included by <code>boost/qvm/vec_operations2.hpp</code>)</p>
  6850. </li>
  6851. <li>
  6852. <p><code>boost/qvm/gen/v3.hpp</code> (included by <code>boost/qvm/vec_operations3.hpp</code>)</p>
  6853. </li>
  6854. <li>
  6855. <p><code>boost/qvm/gen/v4.hpp</code> (included by <code>boost/qvm/vec_operations4.hpp</code>)</p>
  6856. </li>
  6857. </ul>
  6858. </div>
  6859. </li>
  6860. <li>
  6861. <p>2D, 3D and 4D vector-matrix operations:</p>
  6862. <div class="ulist">
  6863. <ul>
  6864. <li>
  6865. <p><code>boost/qvm/gen/vm2.hpp</code> (included by <code>boost/qvm/vec_mat_operations2.hpp</code>)</p>
  6866. </li>
  6867. <li>
  6868. <p><code>boost/qvm/gen/vm3.hpp</code> (included by <code>boost/qvm/vec_mat_operations3.hpp</code>)</p>
  6869. </li>
  6870. <li>
  6871. <p><code>boost/qvm/gen/vm4.hpp</code> (included by <code>boost/qvm/vec_mat_operations4.hpp</code>)</p>
  6872. </li>
  6873. </ul>
  6874. </div>
  6875. </li>
  6876. <li>
  6877. <p>2D, 3D and 4D vector swizzling operations:</p>
  6878. <div class="ulist">
  6879. <ul>
  6880. <li>
  6881. <p><code>boost/qvm/gen/sw2.hpp</code> (included by <code>boost/qvm/swizzle2.hpp</code>)</p>
  6882. </li>
  6883. <li>
  6884. <p><code>boost/qvm/gen/sw3.hpp</code> (included by <code>boost/qvm/swizzle3.hpp</code>)</p>
  6885. </li>
  6886. <li>
  6887. <p><code>boost/qvm/gen/sw4.hpp</code> (included by <code>boost/qvm/swizzle4.hpp</code>)</p>
  6888. </li>
  6889. </ul>
  6890. </div>
  6891. </li>
  6892. </ul>
  6893. </div>
  6894. <div class="paragraph">
  6895. <p>Any such generated headers must be included before the corresponding generic header file is included. For example, if one creates a header <code>boost/qvm/gen/m5.hpp</code>, it must be included before <code>boost/qvm/mat_operations.hpp</code> in included. However, the generic headers (<code>boost/qvm/mat_operations.hpp</code>, <code>boost/qvm/vec_operations.hpp</code>, <code>boost/qvm/vec_mat_operations.hpp</code> and <code>boost/qvm/swizzle.hpp</code>) already include the generated headers from the list above, so the generated headers don&#8217;t need to be included manually.</p>
  6896. </div>
  6897. <div class="admonitionblock note">
  6898. <table>
  6899. <tr>
  6900. <td class="icon">
  6901. <i class="fa icon-note" title="Note"></i>
  6902. </td>
  6903. <td class="content">
  6904. headers under <code>boost/qvm/gen</code> are not part of the public interface of QVM. For example, <code>boost/qvm/gen/mat_operations2.hpp</code> should not be included directly; <code>#include &lt;boost/qvm/mat_operations2.hpp&gt;</code> instead.
  6905. </td>
  6906. </tr>
  6907. </table>
  6908. </div>
  6909. </div>
  6910. </div>
  6911. <div class="sect1">
  6912. <h2 id="_known_quirks_and_issues">Known Quirks and Issues</h2>
  6913. <div class="sectionbody">
  6914. <div class="sect2">
  6915. <h3 id="_capturing_view_proxies_with_auto">Capturing View Proxies with <code>auto</code></h3>
  6916. <div class="paragraph">
  6917. <p>By design, <a href="#view_proxy">view proxies</a> must not return temporary objects. They return reference to an argument they take by (<code>const</code>) reference, cast to reference of unspecified type that is not copyable. Because of this, the return value of a view proxy can not be captured by value with <code>auto</code>:</p>
  6918. </div>
  6919. <div class="listingblock">
  6920. <div class="content">
  6921. <pre class="CodeRay highlight nowrap"><code data-lang="c++">auto tr = transposed(m); //Error: the return type of transposed can not be copied.</code></pre>
  6922. </div>
  6923. </div>
  6924. <div class="paragraph">
  6925. <p>The correct use of auto with view proxies is:</p>
  6926. </div>
  6927. <div class="listingblock">
  6928. <div class="content">
  6929. <pre class="CodeRay highlight nowrap"><code data-lang="c++">auto &amp; tr = transposed(m);</code></pre>
  6930. </div>
  6931. </div>
  6932. <div class="admonitionblock note">
  6933. <table>
  6934. <tr>
  6935. <td class="icon">
  6936. <i class="fa icon-note" title="Note"></i>
  6937. </td>
  6938. <td class="content">
  6939. Many view proxies are not read-only, that is, they&#8217;re lvalues; changes made on the view proxy operate on the original object. This is another reason why they can not be captured by value with <code>auto</code>.
  6940. </td>
  6941. </tr>
  6942. </table>
  6943. </div>
  6944. <hr>
  6945. </div>
  6946. <div class="sect2">
  6947. <h3 id="_binding_qvm_overloads_from_an_unrelated_namespace">Binding QVM Overloads From an Unrelated Namespace</h3>
  6948. <div class="paragraph">
  6949. <p>The operator overloads in namespace <code>boost::qvm</code> are designed to work with user-defined types. Typically it is sufficient to make these operators available in the namespace where the operator is used, by <code>using namespace boost::qvm</code>. A problem arises if the scope that uses the operator is not controlled by the user. For example:</p>
  6950. </div>
  6951. <div class="listingblock">
  6952. <div class="content">
  6953. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace ns1 {
  6954. struct float2 { float x, y; };
  6955. }
  6956. namespace ns2 {
  6957. using namespace boost::qvm;
  6958. void f() {
  6959. ns1::float2 a, b;
  6960. a==b; //OK
  6961. ns1::float2 arr1[2], arr2[2];
  6962. std::equal(arr1,arr1+2,arr2); //Error: operator== is inaccessible from namespace std
  6963. }
  6964. }</code></pre>
  6965. </div>
  6966. </div>
  6967. <div class="paragraph">
  6968. <p>In the <code>std::equal</code> expression above, even though <code>boost::qvm::operator==</code> is made visible in namespace <code>ns2</code> by <code>using namespace boost::qvm</code>, the call originates from namespace <code>std</code>. In this case the compiler can&#8217;t bind <code>boost::qvm::operator==</code> because only namespace <code>ns1</code> is visible through ADL, and it does not contain a suitable declaration. The solution is to declare <code>operator==</code> in namespace ns1, which can be done like this:</p>
  6969. </div>
  6970. <div class="listingblock">
  6971. <div class="content">
  6972. <pre class="CodeRay highlight nowrap"><code data-lang="c++">namespace ns1 {
  6973. using boost::qvm::operator==;
  6974. }</code></pre>
  6975. </div>
  6976. </div>
  6977. <hr>
  6978. </div>
  6979. <div class="sect2">
  6980. <h3 id="_link_errors_when_calling_math_functions_with_int_arguments">Link Errors When Calling Math Functions with <code>int</code> Arguments</h3>
  6981. <div class="paragraph">
  6982. <p>QVM does not call standard math functions (e.g. sin, cos, etc.) directly. Instead, it calls function templates declared in <code>boost/qvm/math.hpp</code> in namespace <code>boost::qvm</code>. This allows the user to specialize these templates for user-defined scalar types.</p>
  6983. </div>
  6984. <div class="paragraph">
  6985. <p>QVM itself defines specializations of the math function templates only for <code>float</code> and <code>double</code>, but it does not provide generic definitions. This is done to protect the user from unintentionally writing code that binds standard math functions that take <code>double</code> when passing arguments of lesser types, which would be suboptimal.</p>
  6986. </div>
  6987. <div class="paragraph">
  6988. <p>Because of this, a call to e.g. <code><a href="#rot_mat">rot_mat</a>(axis,1)</code> will compile successfully but fail to link, since it calls e.g. <code>boost::qvm::sin&lt;int&gt;</code>, which is undefined. Because rotations by integer number of radians are rarely needed, in QVM there is no protection against such errors. In such cases the solution is to use <code>rot_mat(axis,1.0f)</code> instead.</p>
  6989. </div>
  6990. </div>
  6991. </div>
  6992. </div>
  6993. <div class="sect1">
  6994. <h2 id="_distribution">Distribution</h2>
  6995. <div class="sectionbody">
  6996. <div class="paragraph">
  6997. <p>QVM is part of <a href="https://www.boost.org/">Boost</a> and is distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</p>
  6998. </div>
  6999. <div class="paragraph">
  7000. <p>The source code is available in <a href="https://github.com/boostorg/qvm">QVM GitHub repository</a>.</p>
  7001. </div>
  7002. <div class="paragraph">
  7003. <p>&#169; 2008-2018 Emil Dotchevski and Reverge Studios, Inc.</p>
  7004. </div>
  7005. </div>
  7006. </div>
  7007. <div class="sect1">
  7008. <h2 id="_portability">Portability</h2>
  7009. <div class="sectionbody">
  7010. <div class="paragraph">
  7011. <p>See the <a href="https://travis-ci.org/boostorg/qvm">QVM Travis CI Builds</a>.</p>
  7012. </div>
  7013. </div>
  7014. </div>
  7015. <div class="sect1">
  7016. <h2 id="_feedback_support">Feedback / Support</h2>
  7017. <div class="sectionbody">
  7018. <div class="paragraph">
  7019. <p>Please use the <a href="https://lists.boost.org/mailman/listinfo.cgi/boost">Boost Developers mailing list</a>.</p>
  7020. </div>
  7021. </div>
  7022. </div>
  7023. <div class="sect1">
  7024. <h2 id="_qa">Q&amp;A</h2>
  7025. <div class="sectionbody">
  7026. <div class="qlist qanda">
  7027. <ol>
  7028. <li>
  7029. <p><em>What is the motivation behind QVM? Why not just use uBLAS/Eigen/CML/GLM/etc?</em></p>
  7030. <p>The primary domain of QVM is realtime graphics and simulation applications, so it is not a complete linear algebra library. While (naturally) there is some overlap with such libraries, QVM puts the emphasis on 2, 3 and 4 dimensional zero-overhead operations (hence domain-specific features like Swizzling).</p>
  7031. </li>
  7032. <li>
  7033. <p><em>How does the <code>qvm::<a href="#vec">vec</a></code> (or <code>qvm::<a href="#mat">mat</a></code>, or <code>qvm::<a href="#quat">quat</a></code>) template compare to vector types from other libraries?</em></p>
  7034. <p>The <code>qvm::vec</code> template is not in any way central to the vector operations defined by QVM. The operations are designed to work with any user-defined vector type or with 3rd-party vector types (e.g. <code>D3DVECTOR</code>), while the <code>qvm::vec</code> template is simply a default return type for expressions that use arguments of different types that would be incompatible outside of QVM. For example, if the <a href="#deduce_mat2"><code>deduce_mat2</code></a> hasn&#8217;t been specialized, calling <a href="#cross"><code>cross</code></a> with a user-defined type <code>vec3</code> and a user-defined type <code>float3</code> returns a <code>qvm::vec</code>.</p>
  7035. </li>
  7036. <li>
  7037. <p><em>Why doesn&#8217;t QVM use [] or () to access vector and matrix elements?</em></p>
  7038. <p>Because it&#8217;s designed to work with user-defined types, and the C&#43;&#43; standard requires these operators to be members. Of course if a user-defined type defines <code>operator[]</code> or <code>operator()</code> they are available for use with other QVM functions, but QVM defines its own mechanisms for <a href="#quat_access">accessing quaternion elements</a>, <a href="#vec_access">accessing vector elements</a> (as well as <a href="#swizzling">swizzling</a>), and <a href="#mat_access">accessing matrix elements</a>.</p>
  7039. </li>
  7040. </ol>
  7041. </div>
  7042. <hr>
  7043. <div class="paragraph text-right">
  7044. <p>&#169; 2008-2018 Emil Dotchevski and Reverge Studios, Inc.</p>
  7045. </div>
  7046. </div>
  7047. </div>
  7048. </div>
  7049. <div id="footer">
  7050. <div id="footer-text">
  7051. </div>
  7052. </div>
  7053. </body>
  7054. </html>