12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651 |
- define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './Cartesian4-5af5bb24', './RuntimeError-ba10bc3e'], function (exports, when, Check, _Math, Cartographic, Cartesian2, Cartesian4, RuntimeError) { 'use strict';
-
- function GeographicProjection(ellipsoid) {
- this._ellipsoid = when.defaultValue(ellipsoid, Cartesian2.Ellipsoid.WGS84);
- this._semimajorAxis = this._ellipsoid.maximumRadius;
- this._oneOverSemimajorAxis = 1.0 / this._semimajorAxis;
- }
- Object.defineProperties(GeographicProjection.prototype, {
-
- ellipsoid : {
- get : function() {
- return this._ellipsoid;
- }
- }
- });
-
- GeographicProjection.prototype.project = function(cartographic, result) {
-
- var semimajorAxis = this._semimajorAxis;
- var x = cartographic.longitude * semimajorAxis;
- var y = cartographic.latitude * semimajorAxis;
- var z = cartographic.height;
- if (!when.defined(result)) {
- return new Cartographic.Cartesian3(x, y, z);
- }
- result.x = x;
- result.y = y;
- result.z = z;
- return result;
- };
-
- GeographicProjection.prototype.unproject = function(cartesian, result) {
-
- if (!when.defined(cartesian)) {
- throw new Check.DeveloperError('cartesian is required');
- }
-
- var oneOverEarthSemimajorAxis = this._oneOverSemimajorAxis;
- var longitude = cartesian.x * oneOverEarthSemimajorAxis;
- var latitude = cartesian.y * oneOverEarthSemimajorAxis;
- var height = cartesian.z;
- if (!when.defined(result)) {
- return new Cartographic.Cartographic(longitude, latitude, height);
- }
- result.longitude = longitude;
- result.latitude = latitude;
- result.height = height;
- return result;
- };
-
- var Intersect = {
-
- OUTSIDE : -1,
-
- INTERSECTING : 0,
-
- INSIDE : 1
- };
- var Intersect$1 = Object.freeze(Intersect);
-
- function Interval(start, stop) {
-
- this.start = when.defaultValue(start, 0.0);
-
- this.stop = when.defaultValue(stop, 0.0);
- }
-
- function Matrix3(column0Row0, column1Row0, column2Row0,
- column0Row1, column1Row1, column2Row1,
- column0Row2, column1Row2, column2Row2) {
- this[0] = when.defaultValue(column0Row0, 0.0);
- this[1] = when.defaultValue(column0Row1, 0.0);
- this[2] = when.defaultValue(column0Row2, 0.0);
- this[3] = when.defaultValue(column1Row0, 0.0);
- this[4] = when.defaultValue(column1Row1, 0.0);
- this[5] = when.defaultValue(column1Row2, 0.0);
- this[6] = when.defaultValue(column2Row0, 0.0);
- this[7] = when.defaultValue(column2Row1, 0.0);
- this[8] = when.defaultValue(column2Row2, 0.0);
- }
-
- Matrix3.packedLength = 9;
-
- Matrix3.pack = function(value, array, startingIndex) {
-
- Check.Check.typeOf.object('value', value);
- Check.Check.defined('array', array);
-
- startingIndex = when.defaultValue(startingIndex, 0);
- array[startingIndex++] = value[0];
- array[startingIndex++] = value[1];
- array[startingIndex++] = value[2];
- array[startingIndex++] = value[3];
- array[startingIndex++] = value[4];
- array[startingIndex++] = value[5];
- array[startingIndex++] = value[6];
- array[startingIndex++] = value[7];
- array[startingIndex++] = value[8];
- return array;
- };
-
- Matrix3.unpack = function(array, startingIndex, result) {
-
- Check.Check.defined('array', array);
-
- startingIndex = when.defaultValue(startingIndex, 0);
- if (!when.defined(result)) {
- result = new Matrix3();
- }
- result[0] = array[startingIndex++];
- result[1] = array[startingIndex++];
- result[2] = array[startingIndex++];
- result[3] = array[startingIndex++];
- result[4] = array[startingIndex++];
- result[5] = array[startingIndex++];
- result[6] = array[startingIndex++];
- result[7] = array[startingIndex++];
- result[8] = array[startingIndex++];
- return result;
- };
-
- Matrix3.clone = function(matrix, result) {
- if (!when.defined(matrix)) {
- return undefined;
- }
- if (!when.defined(result)) {
- return new Matrix3(matrix[0], matrix[3], matrix[6],
- matrix[1], matrix[4], matrix[7],
- matrix[2], matrix[5], matrix[8]);
- }
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[3];
- result[4] = matrix[4];
- result[5] = matrix[5];
- result[6] = matrix[6];
- result[7] = matrix[7];
- result[8] = matrix[8];
- return result;
- };
-
- Matrix3.fromArray = function(array, startingIndex, result) {
-
- Check.Check.defined('array', array);
-
- startingIndex = when.defaultValue(startingIndex, 0);
- if (!when.defined(result)) {
- result = new Matrix3();
- }
- result[0] = array[startingIndex];
- result[1] = array[startingIndex + 1];
- result[2] = array[startingIndex + 2];
- result[3] = array[startingIndex + 3];
- result[4] = array[startingIndex + 4];
- result[5] = array[startingIndex + 5];
- result[6] = array[startingIndex + 6];
- result[7] = array[startingIndex + 7];
- result[8] = array[startingIndex + 8];
- return result;
- };
-
- Matrix3.fromColumnMajorArray = function(values, result) {
-
- Check.Check.defined('values', values);
-
- return Matrix3.clone(values, result);
- };
-
- Matrix3.fromRowMajorArray = function(values, result) {
-
- Check.Check.defined('values', values);
-
- if (!when.defined(result)) {
- return new Matrix3(values[0], values[1], values[2],
- values[3], values[4], values[5],
- values[6], values[7], values[8]);
- }
- result[0] = values[0];
- result[1] = values[3];
- result[2] = values[6];
- result[3] = values[1];
- result[4] = values[4];
- result[5] = values[7];
- result[6] = values[2];
- result[7] = values[5];
- result[8] = values[8];
- return result;
- };
-
- Matrix3.fromQuaternion = function(quaternion, result) {
-
- Check.Check.typeOf.object('quaternion', quaternion);
-
- var x2 = quaternion.x * quaternion.x;
- var xy = quaternion.x * quaternion.y;
- var xz = quaternion.x * quaternion.z;
- var xw = quaternion.x * quaternion.w;
- var y2 = quaternion.y * quaternion.y;
- var yz = quaternion.y * quaternion.z;
- var yw = quaternion.y * quaternion.w;
- var z2 = quaternion.z * quaternion.z;
- var zw = quaternion.z * quaternion.w;
- var w2 = quaternion.w * quaternion.w;
- var m00 = x2 - y2 - z2 + w2;
- var m01 = 2.0 * (xy - zw);
- var m02 = 2.0 * (xz + yw);
- var m10 = 2.0 * (xy + zw);
- var m11 = -x2 + y2 - z2 + w2;
- var m12 = 2.0 * (yz - xw);
- var m20 = 2.0 * (xz - yw);
- var m21 = 2.0 * (yz + xw);
- var m22 = -x2 - y2 + z2 + w2;
- if (!when.defined(result)) {
- return new Matrix3(m00, m01, m02,
- m10, m11, m12,
- m20, m21, m22);
- }
- result[0] = m00;
- result[1] = m10;
- result[2] = m20;
- result[3] = m01;
- result[4] = m11;
- result[5] = m21;
- result[6] = m02;
- result[7] = m12;
- result[8] = m22;
- return result;
- };
-
- Matrix3.fromHeadingPitchRoll = function(headingPitchRoll, result) {
-
- Check.Check.typeOf.object('headingPitchRoll', headingPitchRoll);
-
- var cosTheta = Math.cos(-headingPitchRoll.pitch);
- var cosPsi = Math.cos(-headingPitchRoll.heading);
- var cosPhi = Math.cos(headingPitchRoll.roll);
- var sinTheta = Math.sin(-headingPitchRoll.pitch);
- var sinPsi = Math.sin(-headingPitchRoll.heading);
- var sinPhi = Math.sin(headingPitchRoll.roll);
- var m00 = cosTheta * cosPsi;
- var m01 = -cosPhi * sinPsi + sinPhi * sinTheta * cosPsi;
- var m02 = sinPhi * sinPsi + cosPhi * sinTheta * cosPsi;
- var m10 = cosTheta * sinPsi;
- var m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi;
- var m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi;
- var m20 = -sinTheta;
- var m21 = sinPhi * cosTheta;
- var m22 = cosPhi * cosTheta;
- if (!when.defined(result)) {
- return new Matrix3(m00, m01, m02,
- m10, m11, m12,
- m20, m21, m22);
- }
- result[0] = m00;
- result[1] = m10;
- result[2] = m20;
- result[3] = m01;
- result[4] = m11;
- result[5] = m21;
- result[6] = m02;
- result[7] = m12;
- result[8] = m22;
- return result;
- };
-
- Matrix3.fromScale = function(scale, result) {
-
- Check.Check.typeOf.object('scale', scale);
-
- if (!when.defined(result)) {
- return new Matrix3(
- scale.x, 0.0, 0.0,
- 0.0, scale.y, 0.0,
- 0.0, 0.0, scale.z);
- }
- result[0] = scale.x;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = scale.y;
- result[5] = 0.0;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = scale.z;
- return result;
- };
-
- Matrix3.fromUniformScale = function(scale, result) {
-
- Check.Check.typeOf.number('scale', scale);
-
- if (!when.defined(result)) {
- return new Matrix3(
- scale, 0.0, 0.0,
- 0.0, scale, 0.0,
- 0.0, 0.0, scale);
- }
- result[0] = scale;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = scale;
- result[5] = 0.0;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = scale;
- return result;
- };
-
- Matrix3.fromCrossProduct = function(vector, result) {
-
- Check.Check.typeOf.object('vector', vector);
-
- if (!when.defined(result)) {
- return new Matrix3(
- 0.0, -vector.z, vector.y,
- vector.z, 0.0, -vector.x,
- -vector.y, vector.x, 0.0);
- }
- result[0] = 0.0;
- result[1] = vector.z;
- result[2] = -vector.y;
- result[3] = -vector.z;
- result[4] = 0.0;
- result[5] = vector.x;
- result[6] = vector.y;
- result[7] = -vector.x;
- result[8] = 0.0;
- return result;
- };
-
- Matrix3.fromRotationX = function(angle, result) {
-
- Check.Check.typeOf.number('angle', angle);
-
- var cosAngle = Math.cos(angle);
- var sinAngle = Math.sin(angle);
- if (!when.defined(result)) {
- return new Matrix3(
- 1.0, 0.0, 0.0,
- 0.0, cosAngle, -sinAngle,
- 0.0, sinAngle, cosAngle);
- }
- result[0] = 1.0;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = cosAngle;
- result[5] = sinAngle;
- result[6] = 0.0;
- result[7] = -sinAngle;
- result[8] = cosAngle;
- return result;
- };
-
- Matrix3.fromRotationY = function(angle, result) {
-
- Check.Check.typeOf.number('angle', angle);
-
- var cosAngle = Math.cos(angle);
- var sinAngle = Math.sin(angle);
- if (!when.defined(result)) {
- return new Matrix3(
- cosAngle, 0.0, sinAngle,
- 0.0, 1.0, 0.0,
- -sinAngle, 0.0, cosAngle);
- }
- result[0] = cosAngle;
- result[1] = 0.0;
- result[2] = -sinAngle;
- result[3] = 0.0;
- result[4] = 1.0;
- result[5] = 0.0;
- result[6] = sinAngle;
- result[7] = 0.0;
- result[8] = cosAngle;
- return result;
- };
-
- Matrix3.fromRotationZ = function(angle, result) {
-
- Check.Check.typeOf.number('angle', angle);
-
- var cosAngle = Math.cos(angle);
- var sinAngle = Math.sin(angle);
- if (!when.defined(result)) {
- return new Matrix3(
- cosAngle, -sinAngle, 0.0,
- sinAngle, cosAngle, 0.0,
- 0.0, 0.0, 1.0);
- }
- result[0] = cosAngle;
- result[1] = sinAngle;
- result[2] = 0.0;
- result[3] = -sinAngle;
- result[4] = cosAngle;
- result[5] = 0.0;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = 1.0;
- return result;
- };
-
- Matrix3.toArray = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
-
- if (!when.defined(result)) {
- return [matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8]];
- }
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[3];
- result[4] = matrix[4];
- result[5] = matrix[5];
- result[6] = matrix[6];
- result[7] = matrix[7];
- result[8] = matrix[8];
- return result;
- };
-
- Matrix3.getElementIndex = function(column, row) {
-
- Check.Check.typeOf.number.greaterThanOrEquals('row', row, 0);
- Check.Check.typeOf.number.lessThanOrEquals('row', row, 2);
- Check.Check.typeOf.number.greaterThanOrEquals('column', column, 0);
- Check.Check.typeOf.number.lessThanOrEquals('column', column, 2);
-
- return column * 3 + row;
- };
-
- Matrix3.getColumn = function(matrix, index, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 2);
- Check.Check.typeOf.object('result', result);
-
- var startIndex = index * 3;
- var x = matrix[startIndex];
- var y = matrix[startIndex + 1];
- var z = matrix[startIndex + 2];
- result.x = x;
- result.y = y;
- result.z = z;
- return result;
- };
-
- Matrix3.setColumn = function(matrix, index, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 2);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- result = Matrix3.clone(matrix, result);
- var startIndex = index * 3;
- result[startIndex] = cartesian.x;
- result[startIndex + 1] = cartesian.y;
- result[startIndex + 2] = cartesian.z;
- return result;
- };
-
- Matrix3.getRow = function(matrix, index, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 2);
- Check.Check.typeOf.object('result', result);
-
- var x = matrix[index];
- var y = matrix[index + 3];
- var z = matrix[index + 6];
- result.x = x;
- result.y = y;
- result.z = z;
- return result;
- };
-
- Matrix3.setRow = function(matrix, index, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 2);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- result = Matrix3.clone(matrix, result);
- result[index] = cartesian.x;
- result[index + 3] = cartesian.y;
- result[index + 6] = cartesian.z;
- return result;
- };
- var scratchColumn = new Cartographic.Cartesian3();
-
- Matrix3.getScale = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result.x = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn));
- result.y = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn));
- result.z = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn));
- return result;
- };
- var scratchScale = new Cartographic.Cartesian3();
-
- Matrix3.getMaximumScale = function(matrix) {
- Matrix3.getScale(matrix, scratchScale);
- return Cartographic.Cartesian3.maximumComponent(scratchScale);
- };
-
- Matrix3.multiply = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- var column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
- var column0Row1 = left[1] * right[0] + left[4] * right[1] + left[7] * right[2];
- var column0Row2 = left[2] * right[0] + left[5] * right[1] + left[8] * right[2];
- var column1Row0 = left[0] * right[3] + left[3] * right[4] + left[6] * right[5];
- var column1Row1 = left[1] * right[3] + left[4] * right[4] + left[7] * right[5];
- var column1Row2 = left[2] * right[3] + left[5] * right[4] + left[8] * right[5];
- var column2Row0 = left[0] * right[6] + left[3] * right[7] + left[6] * right[8];
- var column2Row1 = left[1] * right[6] + left[4] * right[7] + left[7] * right[8];
- var column2Row2 = left[2] * right[6] + left[5] * right[7] + left[8] * right[8];
- result[0] = column0Row0;
- result[1] = column0Row1;
- result[2] = column0Row2;
- result[3] = column1Row0;
- result[4] = column1Row1;
- result[5] = column1Row2;
- result[6] = column2Row0;
- result[7] = column2Row1;
- result[8] = column2Row2;
- return result;
- };
-
- Matrix3.add = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- result[0] = left[0] + right[0];
- result[1] = left[1] + right[1];
- result[2] = left[2] + right[2];
- result[3] = left[3] + right[3];
- result[4] = left[4] + right[4];
- result[5] = left[5] + right[5];
- result[6] = left[6] + right[6];
- result[7] = left[7] + right[7];
- result[8] = left[8] + right[8];
- return result;
- };
-
- Matrix3.subtract = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- result[0] = left[0] - right[0];
- result[1] = left[1] - right[1];
- result[2] = left[2] - right[2];
- result[3] = left[3] - right[3];
- result[4] = left[4] - right[4];
- result[5] = left[5] - right[5];
- result[6] = left[6] - right[6];
- result[7] = left[7] - right[7];
- result[8] = left[8] - right[8];
- return result;
- };
-
- Matrix3.multiplyByVector = function(matrix, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- var vX = cartesian.x;
- var vY = cartesian.y;
- var vZ = cartesian.z;
- var x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;
- var y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;
- var z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;
- result.x = x;
- result.y = y;
- result.z = z;
- return result;
- };
-
- Matrix3.multiplyByScalar = function(matrix, scalar, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number('scalar', scalar);
- Check.Check.typeOf.object('result', result);
-
- result[0] = matrix[0] * scalar;
- result[1] = matrix[1] * scalar;
- result[2] = matrix[2] * scalar;
- result[3] = matrix[3] * scalar;
- result[4] = matrix[4] * scalar;
- result[5] = matrix[5] * scalar;
- result[6] = matrix[6] * scalar;
- result[7] = matrix[7] * scalar;
- result[8] = matrix[8] * scalar;
- return result;
- };
-
- Matrix3.multiplyByScale = function(matrix, scale, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('scale', scale);
- Check.Check.typeOf.object('result', result);
-
- result[0] = matrix[0] * scale.x;
- result[1] = matrix[1] * scale.x;
- result[2] = matrix[2] * scale.x;
- result[3] = matrix[3] * scale.y;
- result[4] = matrix[4] * scale.y;
- result[5] = matrix[5] * scale.y;
- result[6] = matrix[6] * scale.z;
- result[7] = matrix[7] * scale.z;
- result[8] = matrix[8] * scale.z;
- return result;
- };
-
- Matrix3.negate = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result[0] = -matrix[0];
- result[1] = -matrix[1];
- result[2] = -matrix[2];
- result[3] = -matrix[3];
- result[4] = -matrix[4];
- result[5] = -matrix[5];
- result[6] = -matrix[6];
- result[7] = -matrix[7];
- result[8] = -matrix[8];
- return result;
- };
-
- Matrix3.transpose = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- var column0Row0 = matrix[0];
- var column0Row1 = matrix[3];
- var column0Row2 = matrix[6];
- var column1Row0 = matrix[1];
- var column1Row1 = matrix[4];
- var column1Row2 = matrix[7];
- var column2Row0 = matrix[2];
- var column2Row1 = matrix[5];
- var column2Row2 = matrix[8];
- result[0] = column0Row0;
- result[1] = column0Row1;
- result[2] = column0Row2;
- result[3] = column1Row0;
- result[4] = column1Row1;
- result[5] = column1Row2;
- result[6] = column2Row0;
- result[7] = column2Row1;
- result[8] = column2Row2;
- return result;
- };
- var UNIT = new Cartographic.Cartesian3(1, 1, 1);
-
- Matrix3.getRotation = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- var inverseScale = Cartographic.Cartesian3.divideComponents(UNIT, Matrix3.getScale(matrix, scratchScale), scratchScale);
- result = Matrix3.multiplyByScale(matrix, inverseScale, result);
- return result;
- };
- function computeFrobeniusNorm(matrix) {
- var norm = 0.0;
- for (var i = 0; i < 9; ++i) {
- var temp = matrix[i];
- norm += temp * temp;
- }
- return Math.sqrt(norm);
- }
- var rowVal = [1, 0, 0];
- var colVal = [2, 2, 1];
- function offDiagonalFrobeniusNorm(matrix) {
-
-
- var norm = 0.0;
- for (var i = 0; i < 3; ++i) {
- var temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
- norm += 2.0 * temp * temp;
- }
- return Math.sqrt(norm);
- }
- function shurDecomposition(matrix, result) {
-
-
-
-
-
-
- var tolerance = _Math.CesiumMath.EPSILON15;
- var maxDiagonal = 0.0;
- var rotAxis = 1;
-
- for (var i = 0; i < 3; ++i) {
- var temp = Math.abs(matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])]);
- if (temp > maxDiagonal) {
- rotAxis = i;
- maxDiagonal = temp;
- }
- }
- var c = 1.0;
- var s = 0.0;
- var p = rowVal[rotAxis];
- var q = colVal[rotAxis];
- if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {
- var qq = matrix[Matrix3.getElementIndex(q, q)];
- var pp = matrix[Matrix3.getElementIndex(p, p)];
- var qp = matrix[Matrix3.getElementIndex(q, p)];
- var tau = (qq - pp) / 2.0 / qp;
- var t;
- if (tau < 0.0) {
- t = -1.0 / (-tau + Math.sqrt(1.0 + tau * tau));
- } else {
- t = 1.0 / (tau + Math.sqrt(1.0 + tau * tau));
- }
- c = 1.0 / Math.sqrt(1.0 + t * t);
- s = t * c;
- }
- result = Matrix3.clone(Matrix3.IDENTITY, result);
- result[Matrix3.getElementIndex(p, p)] = result[Matrix3.getElementIndex(q, q)] = c;
- result[Matrix3.getElementIndex(q, p)] = s;
- result[Matrix3.getElementIndex(p, q)] = -s;
- return result;
- }
- var jMatrix = new Matrix3();
- var jMatrixTranspose = new Matrix3();
-
- Matrix3.computeEigenDecomposition = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
-
-
-
- var tolerance = _Math.CesiumMath.EPSILON20;
- var maxSweeps = 10;
- var count = 0;
- var sweep = 0;
- if (!when.defined(result)) {
- result = {};
- }
- var unitaryMatrix = result.unitary = Matrix3.clone(Matrix3.IDENTITY, result.unitary);
- var diagMatrix = result.diagonal = Matrix3.clone(matrix, result.diagonal);
- var epsilon = tolerance * computeFrobeniusNorm(diagMatrix);
- while (sweep < maxSweeps && offDiagonalFrobeniusNorm(diagMatrix) > epsilon) {
- shurDecomposition(diagMatrix, jMatrix);
- Matrix3.transpose(jMatrix, jMatrixTranspose);
- Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);
- Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);
- Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);
- if (++count > 2) {
- ++sweep;
- count = 0;
- }
- }
- return result;
- };
-
- Matrix3.abs = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result[0] = Math.abs(matrix[0]);
- result[1] = Math.abs(matrix[1]);
- result[2] = Math.abs(matrix[2]);
- result[3] = Math.abs(matrix[3]);
- result[4] = Math.abs(matrix[4]);
- result[5] = Math.abs(matrix[5]);
- result[6] = Math.abs(matrix[6]);
- result[7] = Math.abs(matrix[7]);
- result[8] = Math.abs(matrix[8]);
- return result;
- };
-
- Matrix3.determinant = function(matrix) {
-
- Check.Check.typeOf.object('matrix', matrix);
-
- var m11 = matrix[0];
- var m21 = matrix[3];
- var m31 = matrix[6];
- var m12 = matrix[1];
- var m22 = matrix[4];
- var m32 = matrix[7];
- var m13 = matrix[2];
- var m23 = matrix[5];
- var m33 = matrix[8];
- return m11 * (m22 * m33 - m23 * m32) + m12 * (m23 * m31 - m21 * m33) + m13 * (m21 * m32 - m22 * m31);
- };
-
- Matrix3.inverse = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- var m11 = matrix[0];
- var m21 = matrix[1];
- var m31 = matrix[2];
- var m12 = matrix[3];
- var m22 = matrix[4];
- var m32 = matrix[5];
- var m13 = matrix[6];
- var m23 = matrix[7];
- var m33 = matrix[8];
- var determinant = Matrix3.determinant(matrix);
-
- if (Math.abs(determinant) <= _Math.CesiumMath.EPSILON15) {
- throw new Check.DeveloperError('matrix is not invertible');
- }
-
- result[0] = m22 * m33 - m23 * m32;
- result[1] = m23 * m31 - m21 * m33;
- result[2] = m21 * m32 - m22 * m31;
- result[3] = m13 * m32 - m12 * m33;
- result[4] = m11 * m33 - m13 * m31;
- result[5] = m12 * m31 - m11 * m32;
- result[6] = m12 * m23 - m13 * m22;
- result[7] = m13 * m21 - m11 * m23;
- result[8] = m11 * m22 - m12 * m21;
- var scale = 1.0 / determinant;
- return Matrix3.multiplyByScalar(result, scale, result);
- };
-
- Matrix3.equals = function(left, right) {
- return (left === right) ||
- (when.defined(left) &&
- when.defined(right) &&
- left[0] === right[0] &&
- left[1] === right[1] &&
- left[2] === right[2] &&
- left[3] === right[3] &&
- left[4] === right[4] &&
- left[5] === right[5] &&
- left[6] === right[6] &&
- left[7] === right[7] &&
- left[8] === right[8]);
- };
-
- Matrix3.equalsEpsilon = function(left, right, epsilon) {
-
- Check.Check.typeOf.number('epsilon', epsilon);
-
- return (left === right) ||
- (when.defined(left) &&
- when.defined(right) &&
- Math.abs(left[0] - right[0]) <= epsilon &&
- Math.abs(left[1] - right[1]) <= epsilon &&
- Math.abs(left[2] - right[2]) <= epsilon &&
- Math.abs(left[3] - right[3]) <= epsilon &&
- Math.abs(left[4] - right[4]) <= epsilon &&
- Math.abs(left[5] - right[5]) <= epsilon &&
- Math.abs(left[6] - right[6]) <= epsilon &&
- Math.abs(left[7] - right[7]) <= epsilon &&
- Math.abs(left[8] - right[8]) <= epsilon);
- };
-
- Matrix3.IDENTITY = Object.freeze(new Matrix3(1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0));
-
- Matrix3.ZERO = Object.freeze(new Matrix3(0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0));
-
- Matrix3.COLUMN0ROW0 = 0;
-
- Matrix3.COLUMN0ROW1 = 1;
-
- Matrix3.COLUMN0ROW2 = 2;
-
- Matrix3.COLUMN1ROW0 = 3;
-
- Matrix3.COLUMN1ROW1 = 4;
-
- Matrix3.COLUMN1ROW2 = 5;
-
- Matrix3.COLUMN2ROW0 = 6;
-
- Matrix3.COLUMN2ROW1 = 7;
-
- Matrix3.COLUMN2ROW2 = 8;
- Object.defineProperties(Matrix3.prototype, {
-
- length : {
- get : function() {
- return Matrix3.packedLength;
- }
- }
- });
-
- Matrix3.prototype.clone = function(result) {
- return Matrix3.clone(this, result);
- };
-
- Matrix3.prototype.equals = function(right) {
- return Matrix3.equals(this, right);
- };
-
- Matrix3.equalsArray = function(matrix, array, offset) {
- return matrix[0] === array[offset] &&
- matrix[1] === array[offset + 1] &&
- matrix[2] === array[offset + 2] &&
- matrix[3] === array[offset + 3] &&
- matrix[4] === array[offset + 4] &&
- matrix[5] === array[offset + 5] &&
- matrix[6] === array[offset + 6] &&
- matrix[7] === array[offset + 7] &&
- matrix[8] === array[offset + 8];
- };
-
- Matrix3.prototype.equalsEpsilon = function(right, epsilon) {
- return Matrix3.equalsEpsilon(this, right, epsilon);
- };
-
- Matrix3.prototype.toString = function() {
- return '(' + this[0] + ', ' + this[3] + ', ' + this[6] + ')\n' +
- '(' + this[1] + ', ' + this[4] + ', ' + this[7] + ')\n' +
- '(' + this[2] + ', ' + this[5] + ', ' + this[8] + ')';
- };
-
- function Matrix4(column0Row0, column1Row0, column2Row0, column3Row0,
- column0Row1, column1Row1, column2Row1, column3Row1,
- column0Row2, column1Row2, column2Row2, column3Row2,
- column0Row3, column1Row3, column2Row3, column3Row3) {
- this[0] = when.defaultValue(column0Row0, 0.0);
- this[1] = when.defaultValue(column0Row1, 0.0);
- this[2] = when.defaultValue(column0Row2, 0.0);
- this[3] = when.defaultValue(column0Row3, 0.0);
- this[4] = when.defaultValue(column1Row0, 0.0);
- this[5] = when.defaultValue(column1Row1, 0.0);
- this[6] = when.defaultValue(column1Row2, 0.0);
- this[7] = when.defaultValue(column1Row3, 0.0);
- this[8] = when.defaultValue(column2Row0, 0.0);
- this[9] = when.defaultValue(column2Row1, 0.0);
- this[10] = when.defaultValue(column2Row2, 0.0);
- this[11] = when.defaultValue(column2Row3, 0.0);
- this[12] = when.defaultValue(column3Row0, 0.0);
- this[13] = when.defaultValue(column3Row1, 0.0);
- this[14] = when.defaultValue(column3Row2, 0.0);
- this[15] = when.defaultValue(column3Row3, 0.0);
- }
-
- Matrix4.packedLength = 16;
-
- Matrix4.pack = function(value, array, startingIndex) {
-
- Check.Check.typeOf.object('value', value);
- Check.Check.defined('array', array);
-
- startingIndex = when.defaultValue(startingIndex, 0);
- array[startingIndex++] = value[0];
- array[startingIndex++] = value[1];
- array[startingIndex++] = value[2];
- array[startingIndex++] = value[3];
- array[startingIndex++] = value[4];
- array[startingIndex++] = value[5];
- array[startingIndex++] = value[6];
- array[startingIndex++] = value[7];
- array[startingIndex++] = value[8];
- array[startingIndex++] = value[9];
- array[startingIndex++] = value[10];
- array[startingIndex++] = value[11];
- array[startingIndex++] = value[12];
- array[startingIndex++] = value[13];
- array[startingIndex++] = value[14];
- array[startingIndex] = value[15];
- return array;
- };
-
- Matrix4.unpack = function(array, startingIndex, result) {
-
- Check.Check.defined('array', array);
-
- startingIndex = when.defaultValue(startingIndex, 0);
- if (!when.defined(result)) {
- result = new Matrix4();
- }
- result[0] = array[startingIndex++];
- result[1] = array[startingIndex++];
- result[2] = array[startingIndex++];
- result[3] = array[startingIndex++];
- result[4] = array[startingIndex++];
- result[5] = array[startingIndex++];
- result[6] = array[startingIndex++];
- result[7] = array[startingIndex++];
- result[8] = array[startingIndex++];
- result[9] = array[startingIndex++];
- result[10] = array[startingIndex++];
- result[11] = array[startingIndex++];
- result[12] = array[startingIndex++];
- result[13] = array[startingIndex++];
- result[14] = array[startingIndex++];
- result[15] = array[startingIndex];
- return result;
- };
-
- Matrix4.clone = function(matrix, result) {
- if (!when.defined(matrix)) {
- return undefined;
- }
- if (!when.defined(result)) {
- return new Matrix4(matrix[0], matrix[4], matrix[8], matrix[12],
- matrix[1], matrix[5], matrix[9], matrix[13],
- matrix[2], matrix[6], matrix[10], matrix[14],
- matrix[3], matrix[7], matrix[11], matrix[15]);
- }
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[3];
- result[4] = matrix[4];
- result[5] = matrix[5];
- result[6] = matrix[6];
- result[7] = matrix[7];
- result[8] = matrix[8];
- result[9] = matrix[9];
- result[10] = matrix[10];
- result[11] = matrix[11];
- result[12] = matrix[12];
- result[13] = matrix[13];
- result[14] = matrix[14];
- result[15] = matrix[15];
- return result;
- };
-
- Matrix4.fromArray = Matrix4.unpack;
-
- Matrix4.fromColumnMajorArray = function(values, result) {
-
- Check.Check.defined('values', values);
-
- return Matrix4.clone(values, result);
- };
-
- Matrix4.fromRowMajorArray = function(values, result) {
-
- Check.Check.defined('values', values);
-
- if (!when.defined(result)) {
- return new Matrix4(values[0], values[1], values[2], values[3],
- values[4], values[5], values[6], values[7],
- values[8], values[9], values[10], values[11],
- values[12], values[13], values[14], values[15]);
- }
- result[0] = values[0];
- result[1] = values[4];
- result[2] = values[8];
- result[3] = values[12];
- result[4] = values[1];
- result[5] = values[5];
- result[6] = values[9];
- result[7] = values[13];
- result[8] = values[2];
- result[9] = values[6];
- result[10] = values[10];
- result[11] = values[14];
- result[12] = values[3];
- result[13] = values[7];
- result[14] = values[11];
- result[15] = values[15];
- return result;
- };
-
- Matrix4.fromRotationTranslation = function(rotation, translation, result) {
-
- Check.Check.typeOf.object('rotation', rotation);
-
- translation = when.defaultValue(translation, Cartographic.Cartesian3.ZERO);
- if (!when.defined(result)) {
- return new Matrix4(rotation[0], rotation[3], rotation[6], translation.x,
- rotation[1], rotation[4], rotation[7], translation.y,
- rotation[2], rotation[5], rotation[8], translation.z,
- 0.0, 0.0, 0.0, 1.0);
- }
- result[0] = rotation[0];
- result[1] = rotation[1];
- result[2] = rotation[2];
- result[3] = 0.0;
- result[4] = rotation[3];
- result[5] = rotation[4];
- result[6] = rotation[5];
- result[7] = 0.0;
- result[8] = rotation[6];
- result[9] = rotation[7];
- result[10] = rotation[8];
- result[11] = 0.0;
- result[12] = translation.x;
- result[13] = translation.y;
- result[14] = translation.z;
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.fromTranslationQuaternionRotationScale = function(translation, rotation, scale, result) {
-
- Check.Check.typeOf.object('translation', translation);
- Check.Check.typeOf.object('rotation', rotation);
- Check.Check.typeOf.object('scale', scale);
-
- if (!when.defined(result)) {
- result = new Matrix4();
- }
- var scaleX = scale.x;
- var scaleY = scale.y;
- var scaleZ = scale.z;
- var x2 = rotation.x * rotation.x;
- var xy = rotation.x * rotation.y;
- var xz = rotation.x * rotation.z;
- var xw = rotation.x * rotation.w;
- var y2 = rotation.y * rotation.y;
- var yz = rotation.y * rotation.z;
- var yw = rotation.y * rotation.w;
- var z2 = rotation.z * rotation.z;
- var zw = rotation.z * rotation.w;
- var w2 = rotation.w * rotation.w;
- var m00 = x2 - y2 - z2 + w2;
- var m01 = 2.0 * (xy - zw);
- var m02 = 2.0 * (xz + yw);
- var m10 = 2.0 * (xy + zw);
- var m11 = -x2 + y2 - z2 + w2;
- var m12 = 2.0 * (yz - xw);
- var m20 = 2.0 * (xz - yw);
- var m21 = 2.0 * (yz + xw);
- var m22 = -x2 - y2 + z2 + w2;
- result[0] = m00 * scaleX;
- result[1] = m10 * scaleX;
- result[2] = m20 * scaleX;
- result[3] = 0.0;
- result[4] = m01 * scaleY;
- result[5] = m11 * scaleY;
- result[6] = m21 * scaleY;
- result[7] = 0.0;
- result[8] = m02 * scaleZ;
- result[9] = m12 * scaleZ;
- result[10] = m22 * scaleZ;
- result[11] = 0.0;
- result[12] = translation.x;
- result[13] = translation.y;
- result[14] = translation.z;
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.fromTranslationRotationScale = function(translationRotationScale, result) {
-
- Check.Check.typeOf.object('translationRotationScale', translationRotationScale);
-
- return Matrix4.fromTranslationQuaternionRotationScale(translationRotationScale.translation, translationRotationScale.rotation, translationRotationScale.scale, result);
- };
-
- Matrix4.fromTranslation = function(translation, result) {
-
- Check.Check.typeOf.object('translation', translation);
-
- return Matrix4.fromRotationTranslation(Matrix3.IDENTITY, translation, result);
- };
-
- Matrix4.fromScale = function(scale, result) {
-
- Check.Check.typeOf.object('scale', scale);
-
- if (!when.defined(result)) {
- return new Matrix4(
- scale.x, 0.0, 0.0, 0.0,
- 0.0, scale.y, 0.0, 0.0,
- 0.0, 0.0, scale.z, 0.0,
- 0.0, 0.0, 0.0, 1.0);
- }
- result[0] = scale.x;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = scale.y;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = 0.0;
- result[9] = 0.0;
- result[10] = scale.z;
- result[11] = 0.0;
- result[12] = 0.0;
- result[13] = 0.0;
- result[14] = 0.0;
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.fromUniformScale = function(scale, result) {
-
- Check.Check.typeOf.number('scale', scale);
-
- if (!when.defined(result)) {
- return new Matrix4(scale, 0.0, 0.0, 0.0,
- 0.0, scale, 0.0, 0.0,
- 0.0, 0.0, scale, 0.0,
- 0.0, 0.0, 0.0, 1.0);
- }
- result[0] = scale;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = scale;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = 0.0;
- result[9] = 0.0;
- result[10] = scale;
- result[11] = 0.0;
- result[12] = 0.0;
- result[13] = 0.0;
- result[14] = 0.0;
- result[15] = 1.0;
- return result;
- };
- var fromCameraF = new Cartographic.Cartesian3();
- var fromCameraR = new Cartographic.Cartesian3();
- var fromCameraU = new Cartographic.Cartesian3();
-
- Matrix4.fromCamera = function(camera, result) {
-
- Check.Check.typeOf.object('camera', camera);
-
- var position = camera.position;
- var direction = camera.direction;
- var up = camera.up;
-
- Check.Check.typeOf.object('camera.position', position);
- Check.Check.typeOf.object('camera.direction', direction);
- Check.Check.typeOf.object('camera.up', up);
-
- Cartographic.Cartesian3.normalize(direction, fromCameraF);
- Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(fromCameraF, up, fromCameraR), fromCameraR);
- Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(fromCameraR, fromCameraF, fromCameraU), fromCameraU);
- var sX = fromCameraR.x;
- var sY = fromCameraR.y;
- var sZ = fromCameraR.z;
- var fX = fromCameraF.x;
- var fY = fromCameraF.y;
- var fZ = fromCameraF.z;
- var uX = fromCameraU.x;
- var uY = fromCameraU.y;
- var uZ = fromCameraU.z;
- var positionX = position.x;
- var positionY = position.y;
- var positionZ = position.z;
- var t0 = sX * -positionX + sY * -positionY+ sZ * -positionZ;
- var t1 = uX * -positionX + uY * -positionY+ uZ * -positionZ;
- var t2 = fX * positionX + fY * positionY + fZ * positionZ;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (!when.defined(result)) {
- return new Matrix4(
- sX, sY, sZ, t0,
- uX, uY, uZ, t1,
- -fX, -fY, -fZ, t2,
- 0.0, 0.0, 0.0, 1.0);
- }
- result[0] = sX;
- result[1] = uX;
- result[2] = -fX;
- result[3] = 0.0;
- result[4] = sY;
- result[5] = uY;
- result[6] = -fY;
- result[7] = 0.0;
- result[8] = sZ;
- result[9] = uZ;
- result[10] = -fZ;
- result[11] = 0.0;
- result[12] = t0;
- result[13] = t1;
- result[14] = t2;
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.computePerspectiveFieldOfView = function(fovY, aspectRatio, near, far, result) {
-
- Check.Check.typeOf.number.greaterThan('fovY', fovY, 0.0);
- Check.Check.typeOf.number.lessThan('fovY', fovY, Math.PI);
- Check.Check.typeOf.number.greaterThan('near', near, 0.0);
- Check.Check.typeOf.number.greaterThan('far', far, 0.0);
- Check.Check.typeOf.object('result', result);
-
- var bottom = Math.tan(fovY * 0.5);
- var column1Row1 = 1.0 / bottom;
- var column0Row0 = column1Row1 / aspectRatio;
- var column2Row2 = (far + near) / (near - far);
- var column3Row2 = (2.0 * far * near) / (near - far);
- result[0] = column0Row0;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = column1Row1;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = 0.0;
- result[9] = 0.0;
- result[10] = column2Row2;
- result[11] = -1.0;
- result[12] = 0.0;
- result[13] = 0.0;
- result[14] = column3Row2;
- result[15] = 0.0;
- return result;
- };
-
- Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) {
-
- Check.Check.typeOf.number('left', left);
- Check.Check.typeOf.number('right', right);
- Check.Check.typeOf.number('bottom', bottom);
- Check.Check.typeOf.number('top', top);
- Check.Check.typeOf.number('near', near);
- Check.Check.typeOf.number('far', far);
- Check.Check.typeOf.object('result', result);
-
- var a = 1.0 / (right - left);
- var b = 1.0 / (top - bottom);
- var c = 1.0 / (far - near);
- var tx = -(right + left) * a;
- var ty = -(top + bottom) * b;
- var tz = -(far + near) * c;
- a *= 2.0;
- b *= 2.0;
- c *= -2.0;
- result[0] = a;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = b;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = 0.0;
- result[9] = 0.0;
- result[10] = c;
- result[11] = 0.0;
- result[12] = tx;
- result[13] = ty;
- result[14] = tz;
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) {
-
- Check.Check.typeOf.number('left', left);
- Check.Check.typeOf.number('right', right);
- Check.Check.typeOf.number('bottom', bottom);
- Check.Check.typeOf.number('top', top);
- Check.Check.typeOf.number('near', near);
- Check.Check.typeOf.number('far', far);
- Check.Check.typeOf.object('result', result);
-
- var column0Row0 = 2.0 * near / (right - left);
- var column1Row1 = 2.0 * near / (top - bottom);
- var column2Row0 = (right + left) / (right - left);
- var column2Row1 = (top + bottom) / (top - bottom);
- var column2Row2 = -(far + near) / (far - near);
- var column2Row3 = -1.0;
- var column3Row2 = -2.0 * far * near / (far - near);
- result[0] = column0Row0;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = column1Row1;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = column2Row0;
- result[9] = column2Row1;
- result[10] = column2Row2;
- result[11] = column2Row3;
- result[12] = 0.0;
- result[13] = 0.0;
- result[14] = column3Row2;
- result[15] = 0.0;
- return result;
- };
-
- Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) {
-
- Check.Check.typeOf.number('left', left);
- Check.Check.typeOf.number('right', right);
- Check.Check.typeOf.number('bottom', bottom);
- Check.Check.typeOf.number('top', top);
- Check.Check.typeOf.number('near', near);
- Check.Check.typeOf.object('result', result);
-
- var column0Row0 = 2.0 * near / (right - left);
- var column1Row1 = 2.0 * near / (top - bottom);
- var column2Row0 = (right + left) / (right - left);
- var column2Row1 = (top + bottom) / (top - bottom);
- var column2Row2 = -1.0;
- var column2Row3 = -1.0;
- var column3Row2 = -2.0 * near;
- result[0] = column0Row0;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = column1Row1;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = column2Row0;
- result[9] = column2Row1;
- result[10] = column2Row2;
- result[11] = column2Row3;
- result[12] = 0.0;
- result[13] = 0.0;
- result[14] = column3Row2;
- result[15] = 0.0;
- return result;
- };
-
- Matrix4.computeViewportTransformation = function(viewport, nearDepthRange, farDepthRange, result) {
-
- Check.Check.typeOf.object('result', result);
-
- viewport = when.defaultValue(viewport, when.defaultValue.EMPTY_OBJECT);
- var x = when.defaultValue(viewport.x, 0.0);
- var y = when.defaultValue(viewport.y, 0.0);
- var width = when.defaultValue(viewport.width, 0.0);
- var height = when.defaultValue(viewport.height, 0.0);
- nearDepthRange = when.defaultValue(nearDepthRange, 0.0);
- farDepthRange = when.defaultValue(farDepthRange, 1.0);
- var halfWidth = width * 0.5;
- var halfHeight = height * 0.5;
- var halfDepth = (farDepthRange - nearDepthRange) * 0.5;
- var column0Row0 = halfWidth;
- var column1Row1 = halfHeight;
- var column2Row2 = halfDepth;
- var column3Row0 = x + halfWidth;
- var column3Row1 = y + halfHeight;
- var column3Row2 = nearDepthRange + halfDepth;
- var column3Row3 = 1.0;
- result[0] = column0Row0;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = column1Row1;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = 0.0;
- result[9] = 0.0;
- result[10] = column2Row2;
- result[11] = 0.0;
- result[12] = column3Row0;
- result[13] = column3Row1;
- result[14] = column3Row2;
- result[15] = column3Row3;
- return result;
- };
-
- Matrix4.computeView = function(position, direction, up, right, result) {
-
- Check.Check.typeOf.object('position', position);
- Check.Check.typeOf.object('direction', direction);
- Check.Check.typeOf.object('up', up);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- result[0] = right.x;
- result[1] = up.x;
- result[2] = -direction.x;
- result[3] = 0.0;
- result[4] = right.y;
- result[5] = up.y;
- result[6] = -direction.y;
- result[7] = 0.0;
- result[8] = right.z;
- result[9] = up.z;
- result[10] = -direction.z;
- result[11] = 0.0;
- result[12] = -Cartographic.Cartesian3.dot(right, position);
- result[13] = -Cartographic.Cartesian3.dot(up, position);
- result[14] = Cartographic.Cartesian3.dot(direction, position);
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.toArray = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
-
- if (!when.defined(result)) {
- return [matrix[0], matrix[1], matrix[2], matrix[3],
- matrix[4], matrix[5], matrix[6], matrix[7],
- matrix[8], matrix[9], matrix[10], matrix[11],
- matrix[12], matrix[13], matrix[14], matrix[15]];
- }
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[3];
- result[4] = matrix[4];
- result[5] = matrix[5];
- result[6] = matrix[6];
- result[7] = matrix[7];
- result[8] = matrix[8];
- result[9] = matrix[9];
- result[10] = matrix[10];
- result[11] = matrix[11];
- result[12] = matrix[12];
- result[13] = matrix[13];
- result[14] = matrix[14];
- result[15] = matrix[15];
- return result;
- };
-
- Matrix4.getElementIndex = function(column, row) {
-
- Check.Check.typeOf.number.greaterThanOrEquals('row', row, 0);
- Check.Check.typeOf.number.lessThanOrEquals('row', row, 3);
- Check.Check.typeOf.number.greaterThanOrEquals('column', column, 0);
- Check.Check.typeOf.number.lessThanOrEquals('column', column, 3);
-
- return column * 4 + row;
- };
-
- Matrix4.getColumn = function(matrix, index, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 3);
- Check.Check.typeOf.object('result', result);
-
- var startIndex = index * 4;
- var x = matrix[startIndex];
- var y = matrix[startIndex + 1];
- var z = matrix[startIndex + 2];
- var w = matrix[startIndex + 3];
- result.x = x;
- result.y = y;
- result.z = z;
- result.w = w;
- return result;
- };
-
- Matrix4.setColumn = function(matrix, index, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 3);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- result = Matrix4.clone(matrix, result);
- var startIndex = index * 4;
- result[startIndex] = cartesian.x;
- result[startIndex + 1] = cartesian.y;
- result[startIndex + 2] = cartesian.z;
- result[startIndex + 3] = cartesian.w;
- return result;
- };
-
- Matrix4.setTranslation = function(matrix, translation, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('translation', translation);
- Check.Check.typeOf.object('result', result);
-
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[3];
- result[4] = matrix[4];
- result[5] = matrix[5];
- result[6] = matrix[6];
- result[7] = matrix[7];
- result[8] = matrix[8];
- result[9] = matrix[9];
- result[10] = matrix[10];
- result[11] = matrix[11];
- result[12] = translation.x;
- result[13] = translation.y;
- result[14] = translation.z;
- result[15] = matrix[15];
- return result;
- };
- var scaleScratch = new Cartographic.Cartesian3();
-
- Matrix4.setScale = function(matrix, scale, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('scale', scale);
- Check.Check.typeOf.object('result', result);
-
- var existingScale = Matrix4.getScale(matrix, scaleScratch);
- var newScale = Cartographic.Cartesian3.divideComponents(scale, existingScale, scaleScratch);
- return Matrix4.multiplyByScale(matrix, newScale, result);
- };
-
- Matrix4.getRow = function(matrix, index, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 3);
- Check.Check.typeOf.object('result', result);
-
- var x = matrix[index];
- var y = matrix[index + 4];
- var z = matrix[index + 8];
- var w = matrix[index + 12];
- result.x = x;
- result.y = y;
- result.z = z;
- result.w = w;
- return result;
- };
-
- Matrix4.setRow = function(matrix, index, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number.greaterThanOrEquals('index', index, 0);
- Check.Check.typeOf.number.lessThanOrEquals('index', index, 3);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- result = Matrix4.clone(matrix, result);
- result[index] = cartesian.x;
- result[index + 4] = cartesian.y;
- result[index + 8] = cartesian.z;
- result[index + 12] = cartesian.w;
- return result;
- };
- var scratchColumn$1 = new Cartographic.Cartesian3();
-
- Matrix4.getScale = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result.x = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn$1));
- result.y = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.fromElements(matrix[4], matrix[5], matrix[6], scratchColumn$1));
- result.z = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.fromElements(matrix[8], matrix[9], matrix[10], scratchColumn$1));
- return result;
- };
- var scratchScale$1 = new Cartographic.Cartesian3();
-
- Matrix4.getMaximumScale = function(matrix) {
- Matrix4.getScale(matrix, scratchScale$1);
- return Cartographic.Cartesian3.maximumComponent(scratchScale$1);
- };
-
- Matrix4.multiply = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- var left0 = left[0];
- var left1 = left[1];
- var left2 = left[2];
- var left3 = left[3];
- var left4 = left[4];
- var left5 = left[5];
- var left6 = left[6];
- var left7 = left[7];
- var left8 = left[8];
- var left9 = left[9];
- var left10 = left[10];
- var left11 = left[11];
- var left12 = left[12];
- var left13 = left[13];
- var left14 = left[14];
- var left15 = left[15];
- var right0 = right[0];
- var right1 = right[1];
- var right2 = right[2];
- var right3 = right[3];
- var right4 = right[4];
- var right5 = right[5];
- var right6 = right[6];
- var right7 = right[7];
- var right8 = right[8];
- var right9 = right[9];
- var right10 = right[10];
- var right11 = right[11];
- var right12 = right[12];
- var right13 = right[13];
- var right14 = right[14];
- var right15 = right[15];
- var column0Row0 = left0 * right0 + left4 * right1 + left8 * right2 + left12 * right3;
- var column0Row1 = left1 * right0 + left5 * right1 + left9 * right2 + left13 * right3;
- var column0Row2 = left2 * right0 + left6 * right1 + left10 * right2 + left14 * right3;
- var column0Row3 = left3 * right0 + left7 * right1 + left11 * right2 + left15 * right3;
- var column1Row0 = left0 * right4 + left4 * right5 + left8 * right6 + left12 * right7;
- var column1Row1 = left1 * right4 + left5 * right5 + left9 * right6 + left13 * right7;
- var column1Row2 = left2 * right4 + left6 * right5 + left10 * right6 + left14 * right7;
- var column1Row3 = left3 * right4 + left7 * right5 + left11 * right6 + left15 * right7;
- var column2Row0 = left0 * right8 + left4 * right9 + left8 * right10 + left12 * right11;
- var column2Row1 = left1 * right8 + left5 * right9 + left9 * right10 + left13 * right11;
- var column2Row2 = left2 * right8 + left6 * right9 + left10 * right10 + left14 * right11;
- var column2Row3 = left3 * right8 + left7 * right9 + left11 * right10 + left15 * right11;
- var column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12 * right15;
- var column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13 * right15;
- var column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14 * right15;
- var column3Row3 = left3 * right12 + left7 * right13 + left11 * right14 + left15 * right15;
- result[0] = column0Row0;
- result[1] = column0Row1;
- result[2] = column0Row2;
- result[3] = column0Row3;
- result[4] = column1Row0;
- result[5] = column1Row1;
- result[6] = column1Row2;
- result[7] = column1Row3;
- result[8] = column2Row0;
- result[9] = column2Row1;
- result[10] = column2Row2;
- result[11] = column2Row3;
- result[12] = column3Row0;
- result[13] = column3Row1;
- result[14] = column3Row2;
- result[15] = column3Row3;
- return result;
- };
-
- Matrix4.add = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- result[0] = left[0] + right[0];
- result[1] = left[1] + right[1];
- result[2] = left[2] + right[2];
- result[3] = left[3] + right[3];
- result[4] = left[4] + right[4];
- result[5] = left[5] + right[5];
- result[6] = left[6] + right[6];
- result[7] = left[7] + right[7];
- result[8] = left[8] + right[8];
- result[9] = left[9] + right[9];
- result[10] = left[10] + right[10];
- result[11] = left[11] + right[11];
- result[12] = left[12] + right[12];
- result[13] = left[13] + right[13];
- result[14] = left[14] + right[14];
- result[15] = left[15] + right[15];
- return result;
- };
-
- Matrix4.subtract = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- result[0] = left[0] - right[0];
- result[1] = left[1] - right[1];
- result[2] = left[2] - right[2];
- result[3] = left[3] - right[3];
- result[4] = left[4] - right[4];
- result[5] = left[5] - right[5];
- result[6] = left[6] - right[6];
- result[7] = left[7] - right[7];
- result[8] = left[8] - right[8];
- result[9] = left[9] - right[9];
- result[10] = left[10] - right[10];
- result[11] = left[11] - right[11];
- result[12] = left[12] - right[12];
- result[13] = left[13] - right[13];
- result[14] = left[14] - right[14];
- result[15] = left[15] - right[15];
- return result;
- };
-
- Matrix4.multiplyTransformation = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
- Check.Check.typeOf.object('result', result);
-
- var left0 = left[0];
- var left1 = left[1];
- var left2 = left[2];
- var left4 = left[4];
- var left5 = left[5];
- var left6 = left[6];
- var left8 = left[8];
- var left9 = left[9];
- var left10 = left[10];
- var left12 = left[12];
- var left13 = left[13];
- var left14 = left[14];
- var right0 = right[0];
- var right1 = right[1];
- var right2 = right[2];
- var right4 = right[4];
- var right5 = right[5];
- var right6 = right[6];
- var right8 = right[8];
- var right9 = right[9];
- var right10 = right[10];
- var right12 = right[12];
- var right13 = right[13];
- var right14 = right[14];
- var column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
- var column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
- var column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
- var column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
- var column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
- var column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
- var column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
- var column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
- var column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
- var column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12;
- var column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13;
- var column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14;
- result[0] = column0Row0;
- result[1] = column0Row1;
- result[2] = column0Row2;
- result[3] = 0.0;
- result[4] = column1Row0;
- result[5] = column1Row1;
- result[6] = column1Row2;
- result[7] = 0.0;
- result[8] = column2Row0;
- result[9] = column2Row1;
- result[10] = column2Row2;
- result[11] = 0.0;
- result[12] = column3Row0;
- result[13] = column3Row1;
- result[14] = column3Row2;
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.multiplyByMatrix3 = function(matrix, rotation, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('rotation', rotation);
- Check.Check.typeOf.object('result', result);
-
- var left0 = matrix[0];
- var left1 = matrix[1];
- var left2 = matrix[2];
- var left4 = matrix[4];
- var left5 = matrix[5];
- var left6 = matrix[6];
- var left8 = matrix[8];
- var left9 = matrix[9];
- var left10 = matrix[10];
- var right0 = rotation[0];
- var right1 = rotation[1];
- var right2 = rotation[2];
- var right4 = rotation[3];
- var right5 = rotation[4];
- var right6 = rotation[5];
- var right8 = rotation[6];
- var right9 = rotation[7];
- var right10 = rotation[8];
- var column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
- var column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
- var column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
- var column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
- var column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
- var column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
- var column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
- var column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
- var column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
- result[0] = column0Row0;
- result[1] = column0Row1;
- result[2] = column0Row2;
- result[3] = 0.0;
- result[4] = column1Row0;
- result[5] = column1Row1;
- result[6] = column1Row2;
- result[7] = 0.0;
- result[8] = column2Row0;
- result[9] = column2Row1;
- result[10] = column2Row2;
- result[11] = 0.0;
- result[12] = matrix[12];
- result[13] = matrix[13];
- result[14] = matrix[14];
- result[15] = matrix[15];
- return result;
- };
-
- Matrix4.multiplyByTranslation = function(matrix, translation, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('translation', translation);
- Check.Check.typeOf.object('result', result);
-
- var x = translation.x;
- var y = translation.y;
- var z = translation.z;
- var tx = (x * matrix[0]) + (y * matrix[4]) + (z * matrix[8]) + matrix[12];
- var ty = (x * matrix[1]) + (y * matrix[5]) + (z * matrix[9]) + matrix[13];
- var tz = (x * matrix[2]) + (y * matrix[6]) + (z * matrix[10]) + matrix[14];
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[3];
- result[4] = matrix[4];
- result[5] = matrix[5];
- result[6] = matrix[6];
- result[7] = matrix[7];
- result[8] = matrix[8];
- result[9] = matrix[9];
- result[10] = matrix[10];
- result[11] = matrix[11];
- result[12] = tx;
- result[13] = ty;
- result[14] = tz;
- result[15] = matrix[15];
- return result;
- };
- var uniformScaleScratch = new Cartographic.Cartesian3();
-
- Matrix4.multiplyByUniformScale = function(matrix, scale, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number('scale', scale);
- Check.Check.typeOf.object('result', result);
-
- uniformScaleScratch.x = scale;
- uniformScaleScratch.y = scale;
- uniformScaleScratch.z = scale;
- return Matrix4.multiplyByScale(matrix, uniformScaleScratch, result);
- };
-
- Matrix4.multiplyByScale = function(matrix, scale, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('scale', scale);
- Check.Check.typeOf.object('result', result);
-
- var scaleX = scale.x;
- var scaleY = scale.y;
- var scaleZ = scale.z;
-
- if ((scaleX === 1.0) && (scaleY === 1.0) && (scaleZ === 1.0)) {
- return Matrix4.clone(matrix, result);
- }
- result[0] = scaleX * matrix[0];
- result[1] = scaleX * matrix[1];
- result[2] = scaleX * matrix[2];
- result[3] = 0.0;
- result[4] = scaleY * matrix[4];
- result[5] = scaleY * matrix[5];
- result[6] = scaleY * matrix[6];
- result[7] = 0.0;
- result[8] = scaleZ * matrix[8];
- result[9] = scaleZ * matrix[9];
- result[10] = scaleZ * matrix[10];
- result[11] = 0.0;
- result[12] = matrix[12];
- result[13] = matrix[13];
- result[14] = matrix[14];
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.multiplyByVector = function(matrix, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- var vX = cartesian.x;
- var vY = cartesian.y;
- var vZ = cartesian.z;
- var vW = cartesian.w;
- var x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12] * vW;
- var y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13] * vW;
- var z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14] * vW;
- var w = matrix[3] * vX + matrix[7] * vY + matrix[11] * vZ + matrix[15] * vW;
- result.x = x;
- result.y = y;
- result.z = z;
- result.w = w;
- return result;
- };
-
- Matrix4.multiplyByPointAsVector = function(matrix, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- var vX = cartesian.x;
- var vY = cartesian.y;
- var vZ = cartesian.z;
- var x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ;
- var y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ;
- var z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ;
- result.x = x;
- result.y = y;
- result.z = z;
- return result;
- };
-
- Matrix4.multiplyByPoint = function(matrix, cartesian, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('cartesian', cartesian);
- Check.Check.typeOf.object('result', result);
-
- var vX = cartesian.x;
- var vY = cartesian.y;
- var vZ = cartesian.z;
- var x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12];
- var y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13];
- var z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14];
- result.x = x;
- result.y = y;
- result.z = z;
- return result;
- };
-
- Matrix4.multiplyByScalar = function(matrix, scalar, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.number('scalar', scalar);
- Check.Check.typeOf.object('result', result);
-
- result[0] = matrix[0] * scalar;
- result[1] = matrix[1] * scalar;
- result[2] = matrix[2] * scalar;
- result[3] = matrix[3] * scalar;
- result[4] = matrix[4] * scalar;
- result[5] = matrix[5] * scalar;
- result[6] = matrix[6] * scalar;
- result[7] = matrix[7] * scalar;
- result[8] = matrix[8] * scalar;
- result[9] = matrix[9] * scalar;
- result[10] = matrix[10] * scalar;
- result[11] = matrix[11] * scalar;
- result[12] = matrix[12] * scalar;
- result[13] = matrix[13] * scalar;
- result[14] = matrix[14] * scalar;
- result[15] = matrix[15] * scalar;
- return result;
- };
-
- Matrix4.multiplyByPlane = function(matrix, plane, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('plane', plane);
- Check.Check.typeOf.object('result', result);
-
- var inverseMat = new Matrix4();
- var invTrans = new Matrix4();
- Matrix4.inverse(matrix, inverseMat);
- Matrix4.transpose(inverseMat, invTrans);
- var v4 = new Cartesian4.Cartesian4(plane.normal.x, plane.normal.y, plane.normal.z, plane.distance);
- Matrix4.multiplyByVector(invTrans, v4, v4);
- result.normal.x = v4.x;
- result.normal.y = v4.y;
- result.normal.z = v4.z;
- var length = Cartographic.Cartesian3.magnitude(result.normal);
- Cartographic.Cartesian3.normalize(result.normal, result.normal);
- result.distance = v4.w / length;
- return result;
- };
-
- Matrix4.negate = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result[0] = -matrix[0];
- result[1] = -matrix[1];
- result[2] = -matrix[2];
- result[3] = -matrix[3];
- result[4] = -matrix[4];
- result[5] = -matrix[5];
- result[6] = -matrix[6];
- result[7] = -matrix[7];
- result[8] = -matrix[8];
- result[9] = -matrix[9];
- result[10] = -matrix[10];
- result[11] = -matrix[11];
- result[12] = -matrix[12];
- result[13] = -matrix[13];
- result[14] = -matrix[14];
- result[15] = -matrix[15];
- return result;
- };
-
- Matrix4.transpose = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- var matrix1 = matrix[1];
- var matrix2 = matrix[2];
- var matrix3 = matrix[3];
- var matrix6 = matrix[6];
- var matrix7 = matrix[7];
- var matrix11 = matrix[11];
- result[0] = matrix[0];
- result[1] = matrix[4];
- result[2] = matrix[8];
- result[3] = matrix[12];
- result[4] = matrix1;
- result[5] = matrix[5];
- result[6] = matrix[9];
- result[7] = matrix[13];
- result[8] = matrix2;
- result[9] = matrix6;
- result[10] = matrix[10];
- result[11] = matrix[14];
- result[12] = matrix3;
- result[13] = matrix7;
- result[14] = matrix11;
- result[15] = matrix[15];
- return result;
- };
-
- Matrix4.abs = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result[0] = Math.abs(matrix[0]);
- result[1] = Math.abs(matrix[1]);
- result[2] = Math.abs(matrix[2]);
- result[3] = Math.abs(matrix[3]);
- result[4] = Math.abs(matrix[4]);
- result[5] = Math.abs(matrix[5]);
- result[6] = Math.abs(matrix[6]);
- result[7] = Math.abs(matrix[7]);
- result[8] = Math.abs(matrix[8]);
- result[9] = Math.abs(matrix[9]);
- result[10] = Math.abs(matrix[10]);
- result[11] = Math.abs(matrix[11]);
- result[12] = Math.abs(matrix[12]);
- result[13] = Math.abs(matrix[13]);
- result[14] = Math.abs(matrix[14]);
- result[15] = Math.abs(matrix[15]);
- return result;
- };
-
- Matrix4.equals = function(left, right) {
-
-
-
-
- return (left === right) ||
- (when.defined(left) &&
- when.defined(right) &&
-
- left[12] === right[12] &&
- left[13] === right[13] &&
- left[14] === right[14] &&
-
- left[0] === right[0] &&
- left[1] === right[1] &&
- left[2] === right[2] &&
- left[4] === right[4] &&
- left[5] === right[5] &&
- left[6] === right[6] &&
- left[8] === right[8] &&
- left[9] === right[9] &&
- left[10] === right[10] &&
-
- left[3] === right[3] &&
- left[7] === right[7] &&
- left[11] === right[11] &&
- left[15] === right[15]);
- };
-
- Matrix4.equalsEpsilon = function(left, right, epsilon) {
-
- Check.Check.typeOf.number('epsilon', epsilon);
-
- return (left === right) ||
- (when.defined(left) &&
- when.defined(right) &&
- Math.abs(left[0] - right[0]) <= epsilon &&
- Math.abs(left[1] - right[1]) <= epsilon &&
- Math.abs(left[2] - right[2]) <= epsilon &&
- Math.abs(left[3] - right[3]) <= epsilon &&
- Math.abs(left[4] - right[4]) <= epsilon &&
- Math.abs(left[5] - right[5]) <= epsilon &&
- Math.abs(left[6] - right[6]) <= epsilon &&
- Math.abs(left[7] - right[7]) <= epsilon &&
- Math.abs(left[8] - right[8]) <= epsilon &&
- Math.abs(left[9] - right[9]) <= epsilon &&
- Math.abs(left[10] - right[10]) <= epsilon &&
- Math.abs(left[11] - right[11]) <= epsilon &&
- Math.abs(left[12] - right[12]) <= epsilon &&
- Math.abs(left[13] - right[13]) <= epsilon &&
- Math.abs(left[14] - right[14]) <= epsilon &&
- Math.abs(left[15] - right[15]) <= epsilon);
- };
-
- Matrix4.getTranslation = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result.x = matrix[12];
- result.y = matrix[13];
- result.z = matrix[14];
- return result;
- };
-
- Matrix4.getMatrix3 = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[4];
- result[4] = matrix[5];
- result[5] = matrix[6];
- result[6] = matrix[8];
- result[7] = matrix[9];
- result[8] = matrix[10];
- return result;
- };
-
- Matrix4.getRotation = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
- result[0] = matrix[0];
- result[1] = matrix[1];
- result[2] = matrix[2];
- result[3] = matrix[4];
- result[4] = matrix[5];
- result[5] = matrix[6];
- result[6] = matrix[8];
- result[7] = matrix[9];
- result[8] = matrix[10];
- return result;
- };
- var scratchInverseRotation = new Matrix3();
- var scratchMatrix3Zero = new Matrix3();
- var scratchBottomRow = new Cartesian4.Cartesian4();
- var scratchExpectedBottomRow = new Cartesian4.Cartesian4(0.0, 0.0, 0.0, 1.0);
-
- Matrix4.inverse = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
-
-
-
-
- var src0 = matrix[0];
- var src1 = matrix[4];
- var src2 = matrix[8];
- var src3 = matrix[12];
- var src4 = matrix[1];
- var src5 = matrix[5];
- var src6 = matrix[9];
- var src7 = matrix[13];
- var src8 = matrix[2];
- var src9 = matrix[6];
- var src10 = matrix[10];
- var src11 = matrix[14];
- var src12 = matrix[3];
- var src13 = matrix[7];
- var src14 = matrix[11];
- var src15 = matrix[15];
-
- var tmp0 = src10 * src15;
- var tmp1 = src11 * src14;
- var tmp2 = src9 * src15;
- var tmp3 = src11 * src13;
- var tmp4 = src9 * src14;
- var tmp5 = src10 * src13;
- var tmp6 = src8 * src15;
- var tmp7 = src11 * src12;
- var tmp8 = src8 * src14;
- var tmp9 = src10 * src12;
- var tmp10 = src8 * src13;
- var tmp11 = src9 * src12;
-
- var dst0 = (tmp0 * src5 + tmp3 * src6 + tmp4 * src7) - (tmp1 * src5 + tmp2 * src6 + tmp5 * src7);
- var dst1 = (tmp1 * src4 + tmp6 * src6 + tmp9 * src7) - (tmp0 * src4 + tmp7 * src6 + tmp8 * src7);
- var dst2 = (tmp2 * src4 + tmp7 * src5 + tmp10 * src7) - (tmp3 * src4 + tmp6 * src5 + tmp11 * src7);
- var dst3 = (tmp5 * src4 + tmp8 * src5 + tmp11 * src6) - (tmp4 * src4 + tmp9 * src5 + tmp10 * src6);
- var dst4 = (tmp1 * src1 + tmp2 * src2 + tmp5 * src3) - (tmp0 * src1 + tmp3 * src2 + tmp4 * src3);
- var dst5 = (tmp0 * src0 + tmp7 * src2 + tmp8 * src3) - (tmp1 * src0 + tmp6 * src2 + tmp9 * src3);
- var dst6 = (tmp3 * src0 + tmp6 * src1 + tmp11 * src3) - (tmp2 * src0 + tmp7 * src1 + tmp10 * src3);
- var dst7 = (tmp4 * src0 + tmp9 * src1 + tmp10 * src2) - (tmp5 * src0 + tmp8 * src1 + tmp11 * src2);
-
- tmp0 = src2 * src7;
- tmp1 = src3 * src6;
- tmp2 = src1 * src7;
- tmp3 = src3 * src5;
- tmp4 = src1 * src6;
- tmp5 = src2 * src5;
- tmp6 = src0 * src7;
- tmp7 = src3 * src4;
- tmp8 = src0 * src6;
- tmp9 = src2 * src4;
- tmp10 = src0 * src5;
- tmp11 = src1 * src4;
-
- var dst8 = (tmp0 * src13 + tmp3 * src14 + tmp4 * src15) - (tmp1 * src13 + tmp2 * src14 + tmp5 * src15);
- var dst9 = (tmp1 * src12 + tmp6 * src14 + tmp9 * src15) - (tmp0 * src12 + tmp7 * src14 + tmp8 * src15);
- var dst10 = (tmp2 * src12 + tmp7 * src13 + tmp10 * src15) - (tmp3 * src12 + tmp6 * src13 + tmp11 * src15);
- var dst11 = (tmp5 * src12 + tmp8 * src13 + tmp11 * src14) - (tmp4 * src12 + tmp9 * src13 + tmp10 * src14);
- var dst12 = (tmp2 * src10 + tmp5 * src11 + tmp1 * src9) - (tmp4 * src11 + tmp0 * src9 + tmp3 * src10);
- var dst13 = (tmp8 * src11 + tmp0 * src8 + tmp7 * src10) - (tmp6 * src10 + tmp9 * src11 + tmp1 * src8);
- var dst14 = (tmp6 * src9 + tmp11 * src11 + tmp3 * src8) - (tmp10 * src11 + tmp2 * src8 + tmp7 * src9);
- var dst15 = (tmp10 * src10 + tmp4 * src8 + tmp9 * src9) - (tmp8 * src9 + tmp11 * src10 + tmp5 * src8);
-
- var det = src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
- if (Math.abs(det) < _Math.CesiumMath.EPSILON21) {
-
-
- if (Matrix3.equalsEpsilon(Matrix4.getRotation(matrix, scratchInverseRotation), scratchMatrix3Zero, _Math.CesiumMath.EPSILON7) &&
- Cartesian4.Cartesian4.equals(Matrix4.getRow(matrix, 3, scratchBottomRow), scratchExpectedBottomRow)) {
- result[0] = 0.0;
- result[1] = 0.0;
- result[2] = 0.0;
- result[3] = 0.0;
- result[4] = 0.0;
- result[5] = 0.0;
- result[6] = 0.0;
- result[7] = 0.0;
- result[8] = 0.0;
- result[9] = 0.0;
- result[10] = 0.0;
- result[11] = 0.0;
- result[12] = -matrix[12];
- result[13] = -matrix[13];
- result[14] = -matrix[14];
- result[15] = 1.0;
- return result;
- }
- throw new RuntimeError.RuntimeError('matrix is not invertible because its determinate is zero.');
- }
-
- det = 1.0 / det;
- result[0] = dst0 * det;
- result[1] = dst1 * det;
- result[2] = dst2 * det;
- result[3] = dst3 * det;
- result[4] = dst4 * det;
- result[5] = dst5 * det;
- result[6] = dst6 * det;
- result[7] = dst7 * det;
- result[8] = dst8 * det;
- result[9] = dst9 * det;
- result[10] = dst10 * det;
- result[11] = dst11 * det;
- result[12] = dst12 * det;
- result[13] = dst13 * det;
- result[14] = dst14 * det;
- result[15] = dst15 * det;
- return result;
- };
-
- Matrix4.inverseTransformation = function(matrix, result) {
-
- Check.Check.typeOf.object('matrix', matrix);
- Check.Check.typeOf.object('result', result);
-
-
-
-
-
-
- var matrix0 = matrix[0];
- var matrix1 = matrix[1];
- var matrix2 = matrix[2];
- var matrix4 = matrix[4];
- var matrix5 = matrix[5];
- var matrix6 = matrix[6];
- var matrix8 = matrix[8];
- var matrix9 = matrix[9];
- var matrix10 = matrix[10];
- var vX = matrix[12];
- var vY = matrix[13];
- var vZ = matrix[14];
- var x = -matrix0 * vX - matrix1 * vY - matrix2 * vZ;
- var y = -matrix4 * vX - matrix5 * vY - matrix6 * vZ;
- var z = -matrix8 * vX - matrix9 * vY - matrix10 * vZ;
- result[0] = matrix0;
- result[1] = matrix4;
- result[2] = matrix8;
- result[3] = 0.0;
- result[4] = matrix1;
- result[5] = matrix5;
- result[6] = matrix9;
- result[7] = 0.0;
- result[8] = matrix2;
- result[9] = matrix6;
- result[10] = matrix10;
- result[11] = 0.0;
- result[12] = x;
- result[13] = y;
- result[14] = z;
- result[15] = 1.0;
- return result;
- };
-
- Matrix4.IDENTITY = Object.freeze(new Matrix4(1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
-
- Matrix4.ZERO = Object.freeze(new Matrix4(0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0));
-
- Matrix4.COLUMN0ROW0 = 0;
-
- Matrix4.COLUMN0ROW1 = 1;
-
- Matrix4.COLUMN0ROW2 = 2;
-
- Matrix4.COLUMN0ROW3 = 3;
-
- Matrix4.COLUMN1ROW0 = 4;
-
- Matrix4.COLUMN1ROW1 = 5;
-
- Matrix4.COLUMN1ROW2 = 6;
-
- Matrix4.COLUMN1ROW3 = 7;
-
- Matrix4.COLUMN2ROW0 = 8;
-
- Matrix4.COLUMN2ROW1 = 9;
-
- Matrix4.COLUMN2ROW2 = 10;
-
- Matrix4.COLUMN2ROW3 = 11;
-
- Matrix4.COLUMN3ROW0 = 12;
-
- Matrix4.COLUMN3ROW1 = 13;
-
- Matrix4.COLUMN3ROW2 = 14;
-
- Matrix4.COLUMN3ROW3 = 15;
- Object.defineProperties(Matrix4.prototype, {
-
- length : {
- get : function() {
- return Matrix4.packedLength;
- }
- }
- });
-
- Matrix4.prototype.clone = function(result) {
- return Matrix4.clone(this, result);
- };
-
- Matrix4.prototype.equals = function(right) {
- return Matrix4.equals(this, right);
- };
-
- Matrix4.equalsArray = function(matrix, array, offset) {
- return matrix[0] === array[offset] &&
- matrix[1] === array[offset + 1] &&
- matrix[2] === array[offset + 2] &&
- matrix[3] === array[offset + 3] &&
- matrix[4] === array[offset + 4] &&
- matrix[5] === array[offset + 5] &&
- matrix[6] === array[offset + 6] &&
- matrix[7] === array[offset + 7] &&
- matrix[8] === array[offset + 8] &&
- matrix[9] === array[offset + 9] &&
- matrix[10] === array[offset + 10] &&
- matrix[11] === array[offset + 11] &&
- matrix[12] === array[offset + 12] &&
- matrix[13] === array[offset + 13] &&
- matrix[14] === array[offset + 14] &&
- matrix[15] === array[offset + 15];
- };
-
- Matrix4.prototype.equalsEpsilon = function(right, epsilon) {
- return Matrix4.equalsEpsilon(this, right, epsilon);
- };
-
- Matrix4.prototype.toString = function() {
- return '(' + this[0] + ', ' + this[4] + ', ' + this[8] + ', ' + this[12] +')\n' +
- '(' + this[1] + ', ' + this[5] + ', ' + this[9] + ', ' + this[13] +')\n' +
- '(' + this[2] + ', ' + this[6] + ', ' + this[10] + ', ' + this[14] +')\n' +
- '(' + this[3] + ', ' + this[7] + ', ' + this[11] + ', ' + this[15] +')';
- };
-
- function BoundingSphere(center, radius) {
-
- this.center = Cartographic.Cartesian3.clone(when.defaultValue(center, Cartographic.Cartesian3.ZERO));
-
- this.radius = when.defaultValue(radius, 0.0);
- }
- var fromPointsXMin = new Cartographic.Cartesian3();
- var fromPointsYMin = new Cartographic.Cartesian3();
- var fromPointsZMin = new Cartographic.Cartesian3();
- var fromPointsXMax = new Cartographic.Cartesian3();
- var fromPointsYMax = new Cartographic.Cartesian3();
- var fromPointsZMax = new Cartographic.Cartesian3();
- var fromPointsCurrentPos = new Cartographic.Cartesian3();
- var fromPointsScratch = new Cartographic.Cartesian3();
- var fromPointsRitterCenter = new Cartographic.Cartesian3();
- var fromPointsMinBoxPt = new Cartographic.Cartesian3();
- var fromPointsMaxBoxPt = new Cartographic.Cartesian3();
- var fromPointsNaiveCenterScratch = new Cartographic.Cartesian3();
- var volumeConstant = (4.0 / 3.0) * _Math.CesiumMath.PI;
-
- BoundingSphere.fromPoints = function(positions, result) {
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- if (!when.defined(positions) || positions.length === 0) {
- result.center = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
- result.radius = 0.0;
- return result;
- }
- var currentPos = Cartographic.Cartesian3.clone(positions[0], fromPointsCurrentPos);
- var xMin = Cartographic.Cartesian3.clone(currentPos, fromPointsXMin);
- var yMin = Cartographic.Cartesian3.clone(currentPos, fromPointsYMin);
- var zMin = Cartographic.Cartesian3.clone(currentPos, fromPointsZMin);
- var xMax = Cartographic.Cartesian3.clone(currentPos, fromPointsXMax);
- var yMax = Cartographic.Cartesian3.clone(currentPos, fromPointsYMax);
- var zMax = Cartographic.Cartesian3.clone(currentPos, fromPointsZMax);
- var numPositions = positions.length;
- var i;
- for (i = 1; i < numPositions; i++) {
- Cartographic.Cartesian3.clone(positions[i], currentPos);
- var x = currentPos.x;
- var y = currentPos.y;
- var z = currentPos.z;
-
- if (x < xMin.x) {
- Cartographic.Cartesian3.clone(currentPos, xMin);
- }
- if (x > xMax.x) {
- Cartographic.Cartesian3.clone(currentPos, xMax);
- }
- if (y < yMin.y) {
- Cartographic.Cartesian3.clone(currentPos, yMin);
- }
- if (y > yMax.y) {
- Cartographic.Cartesian3.clone(currentPos, yMax);
- }
- if (z < zMin.z) {
- Cartographic.Cartesian3.clone(currentPos, zMin);
- }
- if (z > zMax.z) {
- Cartographic.Cartesian3.clone(currentPos, zMax);
- }
- }
-
- var xSpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(xMax, xMin, fromPointsScratch));
- var ySpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(yMax, yMin, fromPointsScratch));
- var zSpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(zMax, zMin, fromPointsScratch));
-
- var diameter1 = xMin;
- var diameter2 = xMax;
- var maxSpan = xSpan;
- if (ySpan > maxSpan) {
- maxSpan = ySpan;
- diameter1 = yMin;
- diameter2 = yMax;
- }
- if (zSpan > maxSpan) {
- maxSpan = zSpan;
- diameter1 = zMin;
- diameter2 = zMax;
- }
-
- var ritterCenter = fromPointsRitterCenter;
- ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
- ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
- ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
-
- var radiusSquared = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch));
- var ritterRadius = Math.sqrt(radiusSquared);
-
- var minBoxPt = fromPointsMinBoxPt;
- minBoxPt.x = xMin.x;
- minBoxPt.y = yMin.y;
- minBoxPt.z = zMin.z;
- var maxBoxPt = fromPointsMaxBoxPt;
- maxBoxPt.x = xMax.x;
- maxBoxPt.y = yMax.y;
- maxBoxPt.z = zMax.z;
- var naiveCenter = Cartographic.Cartesian3.midpoint(minBoxPt, maxBoxPt, fromPointsNaiveCenterScratch);
-
- var naiveRadius = 0;
- for (i = 0; i < numPositions; i++) {
- Cartographic.Cartesian3.clone(positions[i], currentPos);
-
- var r = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch));
- if (r > naiveRadius) {
- naiveRadius = r;
- }
-
- var oldCenterToPointSquared = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(currentPos, ritterCenter, fromPointsScratch));
- if (oldCenterToPointSquared > radiusSquared) {
- var oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
-
- ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
- radiusSquared = ritterRadius * ritterRadius;
-
- var oldToNew = oldCenterToPoint - ritterRadius;
- ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
- ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
- ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
- }
- }
- if (ritterRadius < naiveRadius) {
- Cartographic.Cartesian3.clone(ritterCenter, result.center);
- result.radius = ritterRadius;
- } else {
- Cartographic.Cartesian3.clone(naiveCenter, result.center);
- result.radius = naiveRadius;
- }
- return result;
- };
- var defaultProjection = new GeographicProjection();
- var fromRectangle2DLowerLeft = new Cartographic.Cartesian3();
- var fromRectangle2DUpperRight = new Cartographic.Cartesian3();
- var fromRectangle2DSouthwest = new Cartographic.Cartographic();
- var fromRectangle2DNortheast = new Cartographic.Cartographic();
-
- BoundingSphere.fromRectangle2D = function(rectangle, projection, result) {
- return BoundingSphere.fromRectangleWithHeights2D(rectangle, projection, 0.0, 0.0, result);
- };
-
- BoundingSphere.fromRectangleWithHeights2D = function(rectangle, projection, minimumHeight, maximumHeight, result) {
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- if (!when.defined(rectangle)) {
- result.center = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
- result.radius = 0.0;
- return result;
- }
- projection = when.defaultValue(projection, defaultProjection);
- Cartesian2.Rectangle.southwest(rectangle, fromRectangle2DSouthwest);
- fromRectangle2DSouthwest.height = minimumHeight;
- Cartesian2.Rectangle.northeast(rectangle, fromRectangle2DNortheast);
- fromRectangle2DNortheast.height = maximumHeight;
- var lowerLeft = projection.project(fromRectangle2DSouthwest, fromRectangle2DLowerLeft);
- var upperRight = projection.project(fromRectangle2DNortheast, fromRectangle2DUpperRight);
- var width = upperRight.x - lowerLeft.x;
- var height = upperRight.y - lowerLeft.y;
- var elevation = upperRight.z - lowerLeft.z;
- result.radius = Math.sqrt(width * width + height * height + elevation * elevation) * 0.5;
- var center = result.center;
- center.x = lowerLeft.x + width * 0.5;
- center.y = lowerLeft.y + height * 0.5;
- center.z = lowerLeft.z + elevation * 0.5;
- return result;
- };
- var fromRectangle3DScratch = [];
-
- BoundingSphere.fromRectangle3D = function(rectangle, ellipsoid, surfaceHeight, result) {
- ellipsoid = when.defaultValue(ellipsoid, Cartesian2.Ellipsoid.WGS84);
- surfaceHeight = when.defaultValue(surfaceHeight, 0.0);
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- if (!when.defined(rectangle)) {
- result.center = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
- result.radius = 0.0;
- return result;
- }
- var positions = Cartesian2.Rectangle.subsample(rectangle, ellipsoid, surfaceHeight, fromRectangle3DScratch);
- return BoundingSphere.fromPoints(positions, result);
- };
-
- BoundingSphere.fromVertices = function(positions, center, stride, result) {
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- if (!when.defined(positions) || positions.length === 0) {
- result.center = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
- result.radius = 0.0;
- return result;
- }
- center = when.defaultValue(center, Cartographic.Cartesian3.ZERO);
- stride = when.defaultValue(stride, 3);
-
- Check.Check.typeOf.number.greaterThanOrEquals('stride', stride, 3);
-
- var currentPos = fromPointsCurrentPos;
- currentPos.x = positions[0] + center.x;
- currentPos.y = positions[1] + center.y;
- currentPos.z = positions[2] + center.z;
- var xMin = Cartographic.Cartesian3.clone(currentPos, fromPointsXMin);
- var yMin = Cartographic.Cartesian3.clone(currentPos, fromPointsYMin);
- var zMin = Cartographic.Cartesian3.clone(currentPos, fromPointsZMin);
- var xMax = Cartographic.Cartesian3.clone(currentPos, fromPointsXMax);
- var yMax = Cartographic.Cartesian3.clone(currentPos, fromPointsYMax);
- var zMax = Cartographic.Cartesian3.clone(currentPos, fromPointsZMax);
- var numElements = positions.length;
- var i;
- for (i = 0; i < numElements; i += stride) {
- var x = positions[i] + center.x;
- var y = positions[i + 1] + center.y;
- var z = positions[i + 2] + center.z;
- currentPos.x = x;
- currentPos.y = y;
- currentPos.z = z;
-
- if (x < xMin.x) {
- Cartographic.Cartesian3.clone(currentPos, xMin);
- }
- if (x > xMax.x) {
- Cartographic.Cartesian3.clone(currentPos, xMax);
- }
- if (y < yMin.y) {
- Cartographic.Cartesian3.clone(currentPos, yMin);
- }
- if (y > yMax.y) {
- Cartographic.Cartesian3.clone(currentPos, yMax);
- }
- if (z < zMin.z) {
- Cartographic.Cartesian3.clone(currentPos, zMin);
- }
- if (z > zMax.z) {
- Cartographic.Cartesian3.clone(currentPos, zMax);
- }
- }
-
- var xSpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(xMax, xMin, fromPointsScratch));
- var ySpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(yMax, yMin, fromPointsScratch));
- var zSpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(zMax, zMin, fromPointsScratch));
-
- var diameter1 = xMin;
- var diameter2 = xMax;
- var maxSpan = xSpan;
- if (ySpan > maxSpan) {
- maxSpan = ySpan;
- diameter1 = yMin;
- diameter2 = yMax;
- }
- if (zSpan > maxSpan) {
- maxSpan = zSpan;
- diameter1 = zMin;
- diameter2 = zMax;
- }
-
- var ritterCenter = fromPointsRitterCenter;
- ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
- ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
- ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
-
- var radiusSquared = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch));
- var ritterRadius = Math.sqrt(radiusSquared);
-
- var minBoxPt = fromPointsMinBoxPt;
- minBoxPt.x = xMin.x;
- minBoxPt.y = yMin.y;
- minBoxPt.z = zMin.z;
- var maxBoxPt = fromPointsMaxBoxPt;
- maxBoxPt.x = xMax.x;
- maxBoxPt.y = yMax.y;
- maxBoxPt.z = zMax.z;
- var naiveCenter = Cartographic.Cartesian3.midpoint(minBoxPt, maxBoxPt, fromPointsNaiveCenterScratch);
-
- var naiveRadius = 0;
- for (i = 0; i < numElements; i += stride) {
- currentPos.x = positions[i] + center.x;
- currentPos.y = positions[i + 1] + center.y;
- currentPos.z = positions[i + 2] + center.z;
-
- var r = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch));
- if (r > naiveRadius) {
- naiveRadius = r;
- }
-
- var oldCenterToPointSquared = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(currentPos, ritterCenter, fromPointsScratch));
- if (oldCenterToPointSquared > radiusSquared) {
- var oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
-
- ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
- radiusSquared = ritterRadius * ritterRadius;
-
- var oldToNew = oldCenterToPoint - ritterRadius;
- ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
- ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
- ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
- }
- }
- if (ritterRadius < naiveRadius) {
- Cartographic.Cartesian3.clone(ritterCenter, result.center);
- result.radius = ritterRadius;
- } else {
- Cartographic.Cartesian3.clone(naiveCenter, result.center);
- result.radius = naiveRadius;
- }
- return result;
- };
-
- BoundingSphere.fromEncodedCartesianVertices = function(positionsHigh, positionsLow, result) {
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- if (!when.defined(positionsHigh) || !when.defined(positionsLow) || positionsHigh.length !== positionsLow.length || positionsHigh.length === 0) {
- result.center = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
- result.radius = 0.0;
- return result;
- }
- var currentPos = fromPointsCurrentPos;
- currentPos.x = positionsHigh[0] + positionsLow[0];
- currentPos.y = positionsHigh[1] + positionsLow[1];
- currentPos.z = positionsHigh[2] + positionsLow[2];
- var xMin = Cartographic.Cartesian3.clone(currentPos, fromPointsXMin);
- var yMin = Cartographic.Cartesian3.clone(currentPos, fromPointsYMin);
- var zMin = Cartographic.Cartesian3.clone(currentPos, fromPointsZMin);
- var xMax = Cartographic.Cartesian3.clone(currentPos, fromPointsXMax);
- var yMax = Cartographic.Cartesian3.clone(currentPos, fromPointsYMax);
- var zMax = Cartographic.Cartesian3.clone(currentPos, fromPointsZMax);
- var numElements = positionsHigh.length;
- var i;
- for (i = 0; i < numElements; i += 3) {
- var x = positionsHigh[i] + positionsLow[i];
- var y = positionsHigh[i + 1] + positionsLow[i + 1];
- var z = positionsHigh[i + 2] + positionsLow[i + 2];
- currentPos.x = x;
- currentPos.y = y;
- currentPos.z = z;
-
- if (x < xMin.x) {
- Cartographic.Cartesian3.clone(currentPos, xMin);
- }
- if (x > xMax.x) {
- Cartographic.Cartesian3.clone(currentPos, xMax);
- }
- if (y < yMin.y) {
- Cartographic.Cartesian3.clone(currentPos, yMin);
- }
- if (y > yMax.y) {
- Cartographic.Cartesian3.clone(currentPos, yMax);
- }
- if (z < zMin.z) {
- Cartographic.Cartesian3.clone(currentPos, zMin);
- }
- if (z > zMax.z) {
- Cartographic.Cartesian3.clone(currentPos, zMax);
- }
- }
-
- var xSpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(xMax, xMin, fromPointsScratch));
- var ySpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(yMax, yMin, fromPointsScratch));
- var zSpan = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(zMax, zMin, fromPointsScratch));
-
- var diameter1 = xMin;
- var diameter2 = xMax;
- var maxSpan = xSpan;
- if (ySpan > maxSpan) {
- maxSpan = ySpan;
- diameter1 = yMin;
- diameter2 = yMax;
- }
- if (zSpan > maxSpan) {
- maxSpan = zSpan;
- diameter1 = zMin;
- diameter2 = zMax;
- }
-
- var ritterCenter = fromPointsRitterCenter;
- ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
- ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
- ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
-
- var radiusSquared = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch));
- var ritterRadius = Math.sqrt(radiusSquared);
-
- var minBoxPt = fromPointsMinBoxPt;
- minBoxPt.x = xMin.x;
- minBoxPt.y = yMin.y;
- minBoxPt.z = zMin.z;
- var maxBoxPt = fromPointsMaxBoxPt;
- maxBoxPt.x = xMax.x;
- maxBoxPt.y = yMax.y;
- maxBoxPt.z = zMax.z;
- var naiveCenter = Cartographic.Cartesian3.midpoint(minBoxPt, maxBoxPt, fromPointsNaiveCenterScratch);
-
- var naiveRadius = 0;
- for (i = 0; i < numElements; i += 3) {
- currentPos.x = positionsHigh[i] + positionsLow[i];
- currentPos.y = positionsHigh[i + 1] + positionsLow[i + 1];
- currentPos.z = positionsHigh[i + 2] + positionsLow[i + 2];
-
- var r = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch));
- if (r > naiveRadius) {
- naiveRadius = r;
- }
-
- var oldCenterToPointSquared = Cartographic.Cartesian3.magnitudeSquared(Cartographic.Cartesian3.subtract(currentPos, ritterCenter, fromPointsScratch));
- if (oldCenterToPointSquared > radiusSquared) {
- var oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
-
- ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
- radiusSquared = ritterRadius * ritterRadius;
-
- var oldToNew = oldCenterToPoint - ritterRadius;
- ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
- ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
- ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
- }
- }
- if (ritterRadius < naiveRadius) {
- Cartographic.Cartesian3.clone(ritterCenter, result.center);
- result.radius = ritterRadius;
- } else {
- Cartographic.Cartesian3.clone(naiveCenter, result.center);
- result.radius = naiveRadius;
- }
- return result;
- };
-
- BoundingSphere.fromCornerPoints = function(corner, oppositeCorner, result) {
-
- Check.Check.typeOf.object('corner', corner);
- Check.Check.typeOf.object('oppositeCorner', oppositeCorner);
-
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- var center = Cartographic.Cartesian3.midpoint(corner, oppositeCorner, result.center);
- result.radius = Cartographic.Cartesian3.distance(center, oppositeCorner);
- return result;
- };
-
- BoundingSphere.fromEllipsoid = function(ellipsoid, result) {
-
- Check.Check.typeOf.object('ellipsoid', ellipsoid);
-
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
- result.radius = ellipsoid.maximumRadius;
- return result;
- };
- var fromBoundingSpheresScratch = new Cartographic.Cartesian3();
-
- BoundingSphere.fromBoundingSpheres = function(boundingSpheres, result) {
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- if (!when.defined(boundingSpheres) || boundingSpheres.length === 0) {
- result.center = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
- result.radius = 0.0;
- return result;
- }
- var length = boundingSpheres.length;
- if (length === 1) {
- return BoundingSphere.clone(boundingSpheres[0], result);
- }
- if (length === 2) {
- return BoundingSphere.union(boundingSpheres[0], boundingSpheres[1], result);
- }
- var positions = [];
- var i;
- for (i = 0; i < length; i++) {
- positions.push(boundingSpheres[i].center);
- }
- result = BoundingSphere.fromPoints(positions, result);
- var center = result.center;
- var radius = result.radius;
- for (i = 0; i < length; i++) {
- var tmp = boundingSpheres[i];
- radius = Math.max(radius, Cartographic.Cartesian3.distance(center, tmp.center, fromBoundingSpheresScratch) + tmp.radius);
- }
- result.radius = radius;
- return result;
- };
- var fromOrientedBoundingBoxScratchU = new Cartographic.Cartesian3();
- var fromOrientedBoundingBoxScratchV = new Cartographic.Cartesian3();
- var fromOrientedBoundingBoxScratchW = new Cartographic.Cartesian3();
-
- BoundingSphere.fromOrientedBoundingBox = function(orientedBoundingBox, result) {
-
- Check.Check.defined('orientedBoundingBox', orientedBoundingBox);
-
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- var halfAxes = orientedBoundingBox.halfAxes;
- var u = Matrix3.getColumn(halfAxes, 0, fromOrientedBoundingBoxScratchU);
- var v = Matrix3.getColumn(halfAxes, 1, fromOrientedBoundingBoxScratchV);
- var w = Matrix3.getColumn(halfAxes, 2, fromOrientedBoundingBoxScratchW);
- Cartographic.Cartesian3.add(u, v, u);
- Cartographic.Cartesian3.add(u, w, u);
- result.center = Cartographic.Cartesian3.clone(orientedBoundingBox.center, result.center);
- result.radius = Cartographic.Cartesian3.magnitude(u);
- return result;
- };
-
- BoundingSphere.clone = function(sphere, result) {
- if (!when.defined(sphere)) {
- return undefined;
- }
- if (!when.defined(result)) {
- return new BoundingSphere(sphere.center, sphere.radius);
- }
- result.center = Cartographic.Cartesian3.clone(sphere.center, result.center);
- result.radius = sphere.radius;
- return result;
- };
-
- BoundingSphere.packedLength = 4;
-
- BoundingSphere.pack = function(value, array, startingIndex) {
-
- Check.Check.typeOf.object('value', value);
- Check.Check.defined('array', array);
-
- startingIndex = when.defaultValue(startingIndex, 0);
- var center = value.center;
- array[startingIndex++] = center.x;
- array[startingIndex++] = center.y;
- array[startingIndex++] = center.z;
- array[startingIndex] = value.radius;
- return array;
- };
-
- BoundingSphere.unpack = function(array, startingIndex, result) {
-
- Check.Check.defined('array', array);
-
- startingIndex = when.defaultValue(startingIndex, 0);
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- var center = result.center;
- center.x = array[startingIndex++];
- center.y = array[startingIndex++];
- center.z = array[startingIndex++];
- result.radius = array[startingIndex];
- return result;
- };
- var unionScratch = new Cartographic.Cartesian3();
- var unionScratchCenter = new Cartographic.Cartesian3();
-
- BoundingSphere.union = function(left, right, result) {
-
- Check.Check.typeOf.object('left', left);
- Check.Check.typeOf.object('right', right);
-
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- var leftCenter = left.center;
- var leftRadius = left.radius;
- var rightCenter = right.center;
- var rightRadius = right.radius;
- var toRightCenter = Cartographic.Cartesian3.subtract(rightCenter, leftCenter, unionScratch);
- var centerSeparation = Cartographic.Cartesian3.magnitude(toRightCenter);
- if (leftRadius >= (centerSeparation + rightRadius)) {
-
- left.clone(result);
- return result;
- }
- if (rightRadius >= (centerSeparation + leftRadius)) {
-
- right.clone(result);
- return result;
- }
-
- var halfDistanceBetweenTangentPoints = (leftRadius + centerSeparation + rightRadius) * 0.5;
-
- var center = Cartographic.Cartesian3.multiplyByScalar(toRightCenter,
- (-leftRadius + halfDistanceBetweenTangentPoints) / centerSeparation, unionScratchCenter);
- Cartographic.Cartesian3.add(center, leftCenter, center);
- Cartographic.Cartesian3.clone(center, result.center);
- result.radius = halfDistanceBetweenTangentPoints;
- return result;
- };
- var expandScratch = new Cartographic.Cartesian3();
-
- BoundingSphere.expand = function(sphere, point, result) {
-
- Check.Check.typeOf.object('sphere', sphere);
- Check.Check.typeOf.object('point', point);
-
- result = BoundingSphere.clone(sphere, result);
- var radius = Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.subtract(point, result.center, expandScratch));
- if (radius > result.radius) {
- result.radius = radius;
- }
- return result;
- };
-
- BoundingSphere.intersectPlane = function(sphere, plane) {
-
- Check.Check.typeOf.object('sphere', sphere);
- Check.Check.typeOf.object('plane', plane);
-
- var center = sphere.center;
- var radius = sphere.radius;
- var normal = plane.normal;
- var distanceToPlane = Cartographic.Cartesian3.dot(normal, center) + plane.distance;
- if (distanceToPlane < -radius) {
-
- return Intersect$1.OUTSIDE;
- } else if (distanceToPlane < radius) {
-
- return Intersect$1.INTERSECTING;
- }
- return Intersect$1.INSIDE;
- };
-
- BoundingSphere.transform = function(sphere, transform, result) {
-
- Check.Check.typeOf.object('sphere', sphere);
- Check.Check.typeOf.object('transform', transform);
-
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- result.center = Matrix4.multiplyByPoint(transform, sphere.center, result.center);
- result.radius = Matrix4.getMaximumScale(transform) * sphere.radius;
- return result;
- };
- var distanceSquaredToScratch = new Cartographic.Cartesian3();
-
- BoundingSphere.distanceSquaredTo = function(sphere, cartesian) {
-
- Check.Check.typeOf.object('sphere', sphere);
- Check.Check.typeOf.object('cartesian', cartesian);
-
- var diff = Cartographic.Cartesian3.subtract(sphere.center, cartesian, distanceSquaredToScratch);
- return Cartographic.Cartesian3.magnitudeSquared(diff) - sphere.radius * sphere.radius;
- };
-
- BoundingSphere.transformWithoutScale = function(sphere, transform, result) {
-
- Check.Check.typeOf.object('sphere', sphere);
- Check.Check.typeOf.object('transform', transform);
-
- if (!when.defined(result)) {
- result = new BoundingSphere();
- }
- result.center = Matrix4.multiplyByPoint(transform, sphere.center, result.center);
- result.radius = sphere.radius;
- return result;
- };
- var scratchCartesian3 = new Cartographic.Cartesian3();
-
- BoundingSphere.computePlaneDistances = function(sphere, position, direction, result) {
-
- Check.Check.typeOf.object('sphere', sphere);
- Check.Check.typeOf.object('position', position);
- Check.Check.typeOf.object('direction', direction);
-
- if (!when.defined(result)) {
- result = new Interval();
- }
- var toCenter = Cartographic.Cartesian3.subtract(sphere.center, position, scratchCartesian3);
- var mag = Cartographic.Cartesian3.dot(direction, toCenter);
- result.start = mag - sphere.radius;
- result.stop = mag + sphere.radius;
- return result;
- };
- var projectTo2DNormalScratch = new Cartographic.Cartesian3();
- var projectTo2DEastScratch = new Cartographic.Cartesian3();
- var projectTo2DNorthScratch = new Cartographic.Cartesian3();
- var projectTo2DWestScratch = new Cartographic.Cartesian3();
- var projectTo2DSouthScratch = new Cartographic.Cartesian3();
- var projectTo2DCartographicScratch = new Cartographic.Cartographic();
- var projectTo2DPositionsScratch = new Array(8);
- for (var n = 0; n < 8; ++n) {
- projectTo2DPositionsScratch[n] = new Cartographic.Cartesian3();
- }
- var projectTo2DProjection = new GeographicProjection();
-
- BoundingSphere.projectTo2D = function(sphere, projection, result) {
-
- Check.Check.typeOf.object('sphere', sphere);
-
- projection = when.defaultValue(projection, projectTo2DProjection);
- var ellipsoid = projection.ellipsoid;
- var center = sphere.center;
- var radius = sphere.radius;
- var normal;
- if (Cartographic.Cartesian3.equals(center, Cartographic.Cartesian3.ZERO)) {
-
-
- normal = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.UNIT_X, projectTo2DNormalScratch);
- } else {
- normal = ellipsoid.geodeticSurfaceNormal(center, projectTo2DNormalScratch);
- }
- var east = Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, normal, projectTo2DEastScratch);
- Cartographic.Cartesian3.normalize(east, east);
- var north = Cartographic.Cartesian3.cross(normal, east, projectTo2DNorthScratch);
- Cartographic.Cartesian3.normalize(north, north);
- Cartographic.Cartesian3.multiplyByScalar(normal, radius, normal);
- Cartographic.Cartesian3.multiplyByScalar(north, radius, north);
- Cartographic.Cartesian3.multiplyByScalar(east, radius, east);
- var south = Cartographic.Cartesian3.negate(north, projectTo2DSouthScratch);
- var west = Cartographic.Cartesian3.negate(east, projectTo2DWestScratch);
- var positions = projectTo2DPositionsScratch;
-
- var corner = positions[0];
- Cartographic.Cartesian3.add(normal, north, corner);
- Cartographic.Cartesian3.add(corner, east, corner);
-
- corner = positions[1];
- Cartographic.Cartesian3.add(normal, north, corner);
- Cartographic.Cartesian3.add(corner, west, corner);
-
- corner = positions[2];
- Cartographic.Cartesian3.add(normal, south, corner);
- Cartographic.Cartesian3.add(corner, west, corner);
-
- corner = positions[3];
- Cartographic.Cartesian3.add(normal, south, corner);
- Cartographic.Cartesian3.add(corner, east, corner);
- Cartographic.Cartesian3.negate(normal, normal);
-
- corner = positions[4];
- Cartographic.Cartesian3.add(normal, north, corner);
- Cartographic.Cartesian3.add(corner, east, corner);
-
- corner = positions[5];
- Cartographic.Cartesian3.add(normal, north, corner);
- Cartographic.Cartesian3.add(corner, west, corner);
-
- corner = positions[6];
- Cartographic.Cartesian3.add(normal, south, corner);
- Cartographic.Cartesian3.add(corner, west, corner);
-
- corner = positions[7];
- Cartographic.Cartesian3.add(normal, south, corner);
- Cartographic.Cartesian3.add(corner, east, corner);
- var length = positions.length;
- for (var i = 0; i < length; ++i) {
- var position = positions[i];
- Cartographic.Cartesian3.add(center, position, position);
- var cartographic = ellipsoid.cartesianToCartographic(position, projectTo2DCartographicScratch);
- projection.project(cartographic, position);
- }
- result = BoundingSphere.fromPoints(positions, result);
-
- center = result.center;
- var x = center.x;
- var y = center.y;
- var z = center.z;
- center.x = z;
- center.y = x;
- center.z = y;
- return result;
- };
-
- BoundingSphere.isOccluded = function(sphere, occluder) {
-
- Check.Check.typeOf.object('sphere', sphere);
- Check.Check.typeOf.object('occluder', occluder);
-
- return !occluder.isBoundingSphereVisible(sphere);
- };
-
- BoundingSphere.equals = function(left, right) {
- return (left === right) ||
- ((when.defined(left)) &&
- (when.defined(right)) &&
- Cartographic.Cartesian3.equals(left.center, right.center) &&
- left.radius === right.radius);
- };
-
- BoundingSphere.prototype.intersectPlane = function(plane) {
- return BoundingSphere.intersectPlane(this, plane);
- };
-
- BoundingSphere.prototype.distanceSquaredTo = function(cartesian) {
- return BoundingSphere.distanceSquaredTo(this, cartesian);
- };
-
- BoundingSphere.prototype.computePlaneDistances = function(position, direction, result) {
- return BoundingSphere.computePlaneDistances(this, position, direction, result);
- };
-
- BoundingSphere.prototype.isOccluded = function(occluder) {
- return BoundingSphere.isOccluded(this, occluder);
- };
-
- BoundingSphere.prototype.equals = function(right) {
- return BoundingSphere.equals(this, right);
- };
-
- BoundingSphere.prototype.clone = function(result) {
- return BoundingSphere.clone(this, result);
- };
-
- BoundingSphere.prototype.volume = function() {
- var radius = this.radius;
- return volumeConstant * radius * radius * radius;
- };
- exports.BoundingSphere = BoundingSphere;
- exports.GeographicProjection = GeographicProjection;
- exports.Intersect = Intersect$1;
- exports.Interval = Interval;
- exports.Matrix3 = Matrix3;
- exports.Matrix4 = Matrix4;
- });
|