
% Apex nodes and derivatives - order is x,dxds1,dxds2,d2xds1ds2,dxds3,d2xds1ds3,
%   d2xds2ds3, d3xds1ds2ds3
% Node 28
% x
% along 28-81
xa(1,:)=[
 50.514907999999998
 0.00000000000000000E+00
 0.00000000000000000E+00
 0.00000000000000000E+00
 0.99031192264529788
 0.00000000000000000E+00
 0.76566961578164172E-01
 -0.10465986836631792E-01]';
% along 28-24
xa(2,:)=[
 50.514907999999998
 0.00000000000000000E+00
 0.00000000000000000E+00
 0.00000000000000000E+00
 0.99031192264529788
 0.00000000000000000E+00
 0.57302478125002040E-01
 0.21256898733201770E-01]';
% y
% along 28-81
ya(1,:)=[
 1.0088299999999999
 0.00000000000000000E+00
 0.96814764037810752
 0.85214131312181723E-01
 0.82026435772618617E-01
 0.00000000000000000E+00
 0.41599078883090446E-01
 0.36614553633834844E-02
]';
% along 28-24
ya(2,:)=[
 1.0088299999999999
 0.00000000000000000E+00
 0.82903757255504162
 0.19031526772735147
 0.82026435772618617E-01
 0.00000000000000000E+00
 0.15675020028442135E-01
 0.35983841168387080E-02
]';
% z
% along 28-81
za(1,:)=[
 1.0228230000000000
 0.00000000000000000E+00
 0.25038000405444166
 -0.32949859741523446
 0.11204445412876984
 0.00000000000000000E+00
 0.10735257639794927E-01
 -0.14127535258105086E-01
]';
% along 28-24
za(2,:)=[
 1.0228230000000000
 0.00000000000000000E+00
 0.55919290347074690
 -0.28215398764462363
 0.11204445412876984
 0.00000000000000000E+00
 0.10550433638036923E-01
 -0.53234704944853132E-02
]';

% Node 81
%x
x(2,:)=[
 32.100000000000001
 0.00000000000000000E+00
 -0.79889633743640676
 -0.14332514584212868E-01
 0.67040014603387849E-01
 0.27122176825936151E-01
 0.18402924014793577E-01
 0.23249052870880326E-03
]';
%y
y(2,:)=[
 26.424808078990495
 0.40190042946579480
 0.55230569471711011
 -0.24007070646300133E-01
 0.94254034538722575
 -0.68219821738161754E-01
 0.32016148228528565E-01
 0.11222911889248255E-02
]';
%z
z(2,:)=[
 8.1168789083400554
 -0.91568337584298753
 -0.23816603790999544
 -0.14179855298542442E-01
 0.32729701153433527
 -0.12631563871119886E-01
 -0.31034477184320023E-02
 -0.53216001346358443E-02
]';

%Node 24
%x
x(3,:)=[
 32.100000000000001
 0.00000000000000000E+00
 -0.72723892549842384
 -0.35324739407142911E-02
 0.14990155901623947
 -0.23262770375346267E-02
 0.85614684468753709E-02
 0.93369112139798525E-04
]';
%y
y(3,:)=[
 23.335225726024333
 0.54590587342463903
 0.68326522357272557
 0.97966594091838059E-02
 0.88243981150932671
 -0.21872351486377454E-02
 0.21673455101089544E-01
 0.20484909139072581E-02
]';
%z
z(3,:)=[
 13.126360170967098
 -0.83784651181495173
 0.65361911661237310E-01
 -0.39280431633117646E-01
 0.44590301823141443
 -0.23895850690803439E-02
 0.44250682261757386E-02
 -0.80128601651870070E-03
]';

% Node 78
%x
x(4,:)=[
 32.100000000000001
 0.00000000000000000E+00
 -0.84019861520773309
 0.27960944721785986E-02
 0.22445641176736325
 0.21552533266020650E-02
 0.53659919040226810E-02
 -0.31286579798173929E-03
]';
%y
y(4,:)=[
 18.311591082646242
 0.76573125616050108
 0.44208884920974911
 0.24276851969426128E-01
 0.47625171797656229
 0.26186712316380893E-02
 0.22688749894385327E-01
 0.19982723300375279E-03
]';
%z
z(4,:)=[
 17.757443863459304
 -0.64316066681573525
 0.31404416314812750
 -0.43689350775664238E-02
 0.85017858144091873
 -0.80873348536502805E-02
 0.14471035891209483E-01
 0.77652590588278591E-03
]';

% Node 25
%x
x(5,:)=[
 30.100000000000001
 0.18151201034817380
 -0.91425759728143619
 0.68062483429461706E-02
 0.43740249340347714
 -0.54797143595985386E-02
 0.40804070176875809E-02
 0.12478297232731807E-02
]';
%y
y(5,:)=[
 12.106105438478053
 0.88771918844898756
 0.16400809904544900
 0.14868647950118750E-01
 -0.63169889520072034E-01
 0.94671051121674038E-02
 0.16722648348991870E-01
 0.44509751295047032E-02
]';
%z
z(5,:)=[
 21.612709424501720
 -0.42309340878680168
 0.37045160177906289
 0.17625879581803346E-01
 0.89704438230359762
 0.57040342659209362E-01
 0.12195869066821600E-01
 0.45919471849149842E-02
]';

% Node 88
%x
x(6,:)=[
 26.535893999999999
 0.91288142982833761E-01
 -0.96853466254563680
 -0.89567417192018758E-02
 0.46456852158066242
 -0.14541816646330566E-01
 0.22618460711216247E-02
 -0.77605640664808100E-03
]';
%y
y(6,:)=[
 -7.4787650000000001
 0.82624220651884539
 -0.68009247319430519E-01
 0.12727317916033307E-01
 -0.33578447245431253
 0.26821767341015924E-01
 -0.36739096211077273E-02
 0.47839629199936118E-02
]';
%z
z(6,:)=[
 18.304152999999999
 0.55586895138837866
 0.23940624412628489
 -0.60375743105186720E-02
 0.81940519696602909
 -0.23769295733147768E-01
 0.86598758540254676E-02
 -0.16754340174495036E-02
]';

% Node 91
%x
x(7,:)=[
 26.468623999999998
 -0.27102970782962383E-01
 -0.88875390456333214
 -0.45907021152730718E-02
 0.37162376342158360
 0.10889001494463551E-02
 0.41721309027859367E-02
 0.10206879646639301E-02
]';
%y
y(7,:)=[
 -14.589726000000001
 0.65821159927658313
 -0.33023898312101801
 0.30916872820241321E-01
 -0.78165565933874626
 -0.92166255790010077E-02
 -0.85354326051951899E-02
 -0.40637558457430525E-02
]';
%z
z(7,:)=[
 9.0429420000000000
 0.75234494718347167
 0.31789732800171122
 0.48290411583661761E-02
 0.50090938170899613
 0.11406710389923080E-01
 0.13991213644792661E-01
 0.93836233269114903E-03
]';

% Node 26
%x
x(8,:)=[
 27.856714000000000
 -0.55064015324902404E-01
 -0.83369704835405933
 0.58690057473338164E-02
 0.50690136459451662
 -0.41743402312398046E-02
 -0.21664929345134561E-02
 0.13812213729810072E-03
]';
%y
y(8,:)=[
 -19.248116000000000
 -0.43932358762842472
 -0.53113751649977092
 -0.10691099574661325E-01
 -0.77198835427577794
 -0.34380009110012437E-02
 0.14899204617614494E-02
 -0.30042670115741464E-03
]';
%z
z(8,:)=[
 -11.107616999999999
 0.89663969328241810
 -0.15113626345846021
 0.16726733144533719E-01
 -0.38351660646547353
 -0.15627698238806281E-02
 0.10062551267684631E-01
 -0.52506073713442245E-03
]';

% Node 94
%x
x(9,:)=[
 28.740024999999999
 0.21565000006525364E-01
 -0.80060617701796333
 -0.48609475967726062E-02
 0.52797940171922642
 0.22795345322378707E-02
 -0.15223414560698409E-02
 -0.76769218866647323E-03
]';
%y
y(9,:)=[
 1.5672169999999999
 -0.95391529906921835
 -0.11433531275297028
 -0.25839222212684487E-01
 0.21793759835537097E-01
 -0.33179792568939534E-01
 -0.21367716114192328E-01
 -0.12467663556568690E-02
]';
%z
z(9,:)=[
 -24.306919000000001
 -0.29930010520613282
 -0.58818125231799256
 0.14871793942993461E-01
 -0.84897749286564650
 -0.40674372452547951E-01
 0.53418073738418790E-02
 -0.47539155080303210E-02
]';

% Node 97
%x
x(10,:)=[
 29.900874999999999
 0.17006362481697398E-01
 -0.83115049624996096
 0.17708501377290417E-02
 0.28538019225091305
 0.10277329536561672E-01
 0.16770480755025158E-01
 0.39071644481695312E-04
]';
%y
y(10,:)=[
 18.419180000000001
 -0.61554336387201358
 0.16747572272300212
 -0.16361787085813009E-01
 0.95459122580513567
 0.91391107824077573E-02
 0.69320460362101068E-02
 0.20861065457307488E-03
]';
%z
z(10,:)=[
 -12.677020000000001
 -0.78791950783583664
 -0.53022705974125084
 -0.83866088424240232E-02
 -0.85520392227119851E-01
 -0.50000000000000003E-01
 -0.19345850305293150E-01
 0.31844738806426518E-02
]';

% Node 27
%x
x(11,:)=[
 31.100000000000001
 -0.25400025400038112
 -0.79889633743640676
 -0.14332514584212868E-01
 -0.45034200927233821E-02
 0.13356251958872556E-01
 0.22558258428663474E-01
 0.13037650518938654E-01
]';
%y
y(11,:)=[
 28.144563165083774
 0.38100038100057165
 0.55230569471711011
 -0.24007070646300133E-01
 0.87950387468419045
 -0.12319641574543336E-01
 -0.15368040107474893E-01
 0.63205479390179443E-02
]';
%z
z(11,:)=[
 4.2641113850546688
 -0.88900088900133345
 -0.23816603790999544
 -0.14179855298542442E-01
 0.47587041683946313
 0.13648983334950992E-01
 -0.73709585109765982E-01
 -0.13261569544607995E-01
]';

% Second Apex node: 13
%x along 13-51
xa(3,:)=[
54.184787821611351
0.00000000000000000E+00
-0.15283974508758078
-0.36744932264713995E-01
0.95720800768107539
0.00000000000000000E+00
-0.26945375764486489E-01
-0.64780663350751276E-02
]';
%x along 13-9
xa(4,:)=[
54.184787821611351
 0.00000000000000000E+00
-0.67449672786192835E-01
0.39862097676525508E-01
0.95720800768107539
0.00000000000000000E+00
-0.11891257587312644E-01
0.70276170641292313E-02
]';
% y along 13-51
ya(3,:)=[
1.3710761967949985
0.00000000000000000E+00
0.95677286068294853
0.84212949333148185E-01
0.24494381704238544
0.00000000000000000E+00
-0.20052333914582035E-02
-0.17649603676620485E-03
]';
% y along 13-9
ya(4,:)=[
1.3710761967949985
0.00000000000000000E+00
0.82714958682187845
0.18988185852833919
0.24494381704238544
0.00000000000000000E+00
-0.33282860294399672E-03
-0.76404697173558802E-04
]';
% z along 13-51
za(3,:)=[
1.5640376282135897
0.00000000000000000E+00
0.24743828600709872
-0.32562731394652839
0.15412772795293175
0.00000000000000000E+00
-0.51784236941949892E-03
0.68147748080075847E-03
]';
% z along 13-9
za(4,:)=[
1.5640376282135897
0.00000000000000000E+00
0.55791944101405133
-0.28151143208277329
 0.15412772795293175
0.00000000000000000E+00
-0.22417267913819782E-03
0.11311162024274216E-03
]';

% Node 51
%x
x(13,:)=[
 30.785259392085038
 0.26637396802298224
 -0.71145393833026249
 -0.96448714636455518E-02
 -0.27770562353319267
 0.72039043172300754E-01
 0.32664411597147856E-01
 0.81768679882643185E-02
]';
%y
y(13,:)=[
 29.746306973832940
 -0.32677081584701215E-01
 0.65111825383365873
 -0.70720974660010393E-02
 0.93852611395487973
 -0.11459655750000000E-01
 0.59969668830211376E-01
 -0.73282377248984143E-02
]';
%z
z(13,:)=[
 9.0041388011293186
 -0.96331568942834001
 -0.26434506456328311
 -0.51058329065547435E-01
 0.20505687036232909
 -0.12544286912114715E-01
 0.15021621038825692E-01
 -0.73996647853343187E-02
]';

% Node 9
%x
x(14,:)=[
 30.299147693377321
 0.25176754561110647E-01
 -0.72723892549842384
 -0.35324739407142911E-02
 -0.31211198779348509
 0.43634710538776895E-02
 0.16426253961164594E-01
 0.22393052723264908E-02
]';
%y
y(14,:)=[
 28.309521233772227
 0.56480957269322618
 0.68326522357272557
 0.97966594091838059E-02
 0.83940605807839874
 0.31899752761830615E-02
 0.23982845213665088E-01
 -0.31384377799566609E-02
]';
%z
z(14,:)=[
 15.775695966442086
 -0.82483712187550384
 0.65361911661237310E-01
 -0.39280431633117646E-01
 0.44495345457349089
 0.21849148021695565E-02
 0.41098405091615940E-02
 0.37588105405666292E-02
]';

% Node 42
%x
x(15,:)=[
 30.553520717210404
 0.27069361145743826E-02
 -0.84019861520773309
 0.27960944721785986E-02
 -0.23946666276199940
 0.41915916034631533E-03
 0.70664504237275836E-02
 -0.23239732367210967E-02
]';
%y
y(15,:)=[
 18.786572903692360
 0.88577000078387180
 0.44208884920974911
 0.24276851969426128E-01
 0.71908978517649477E-01
 0.18173039737387039E-01
 0.47373305634637215E-01
 -0.29742969022128005E-02
]';
%z
z(15,:)=[
 24.244602958945162
 -0.46411655670554530
 0.31404416314812750
 -0.43689350775664238E-02
 0.96823799565715196
 0.26723147645313867E-01
 0.23591027680675728E-05
 0.81006388367050857E-02
]';

% Node 10
%x
x(16,:)=[
 29.861087024846100
 -0.24115150912626129E-01
 -0.91425759728143619
 0.68062483429461732E-02
 -0.28107339431108640E-01
 -0.24191370996445569E-01
 -0.13004635363216627E-01
 0.38534989230674752E-02
]';
%y
y(16,:)=[
 5.0783472252785460
 0.98838181751765275
 0.16400809904544900
 0.14868647950118750E-01
 -0.82058749541343390
 0.11753747377655057E-01
 0.47249216946672591E-01
 -0.31196656839173510E-03
]';
%z
z(16,:)=[
 26.735236702104071
 0.15006612641419956
 0.37045160177906289
 0.17625879581803346E-01
 0.57082934388590456
 0.63870090619385755E-01
 0.27514629918679008E-02
 0.33310664534562887E-02
]';

% Node 54
%x
x(17,:)=[
 29.361041803386062
 0.33611119028526204E-01
 -0.94383910663519044
 -0.23656848520382575E-02
 0.49090135755571845
 -0.10022034714434422E-01
 0.42911319214878688E-02
 0.11452706155549112E-02
]';
%y
y(17,:)=[
 -8.3905405954466215
 0.89964570973329294
 -0.33901968937960318E-01
 0.11618542550819681E-01
 -0.15827724504719101
 0.12742284750344095E-01
 0.59207617370284861E-02
 -0.19247489300943879E-03
]';
%z
z(17,:)=[
 23.264522803876410
 0.43532503906406528
 0.32866152389383119
 0.20953876328395040E-04
 0.85671708915500466
 -0.20819421487715945E-01
 0.15415488461043989E-01
 0.10463825960602693E-02
]';

% Node 45
%x
x(18,:)=[
 29.108603404548081
 -0.14411540259266428
 -0.88994361430352242
 0.10600605301403956E-02
 0.32924625794799017
 -0.14593259796029993E-01
 -0.14837520297586530E-03
 0.70473748861429213E-03
]';
%y
y(18,:)=[
 -21.011298425970516
 0.62278662026417275
 -0.28001190978525087
 0.16297398785001364E-01
 -0.80007039533987634
 -0.44136350232135690E-02
 0.62578433683925716E-02
 -0.18214554933198839E-02
]';
%z
z(18,:)=[
 13.067409033642285
 0.76900427590195053
 0.35999124119733766
 0.13367786811722888E-02
 0.50148206760355796
 0.20758909293559598E-02
 0.52452517181542759E-02
 -0.43516495303292833E-03
]';

% Node 11
%x
x(19,:)=[
 30.960054813275143
 -0.56158801246229087E-01
 -0.83091207859051808
 0.25652642492092997E-02
 0.45856736964503969
 -0.16177182284319341E-03
 0.41152304430923441E-03
 -0.48817971983659272E-03
]';
%y
y(19,:)=[
 -24.720663793688235
 -0.43099850041879650
 -0.55606308370019819
 0.22278050975827321E-02
 -0.80796202486542013
 0.12291083737688438E-02
 -0.36799882806694793E-02
 0.19073354443917890E-02
]';
%z
z(19,:)=[
 -13.612890433583967
 0.90060339866077310
 -0.19467013078820879E-01
 0.13839665208380694E-01
 -0.37001801830748721
 0.58542208989759289E-03
 0.19446977102139766E-01
 -0.42640741011898186E-03
]';

% Node 48
%x
x(20,:)=[
 31.740191291056682
 -0.32834492985772859E-01
 -0.80583391514878133
 -0.34607060212597644E-02
 0.55622889528383479
 -0.10085630913628270E-01
 -0.96921927761341523E-03
 0.25960388495788520E-03
]';
%y
y(20,:)=[
 1.5207586920589364
 -0.99945562911057595
 -0.22304902029809184
 -0.90225553744079125E-02
 -0.86098157471169150E-02
 -0.84396928793960563E-02
 -0.20147203646264038E-01
 0.31165233813915416E-02
]';
%z
z(20,:)=[
 -28.791265890324571
 -0.32158217534540841E-02
 -0.54852605748500971
 0.17658425690772757E-01
 -0.83098452881153295
 0.54866731943571057E-01
 0.73484175509068881E-02
 0.51638464341281906E-03
]';

% Node 57
%x
x(21,:)=[
 30.861037401031385
 0.12939737516210670
 -0.61221629355850848
 -0.11438961340614084E-02
 0.11924150018757054
 0.13957714804512730E-01
 0.27189195018734201E-01
 -0.36197909618318887E-03
]';
%y
y(21,:)=[
 26.344707514577536
 -0.46967952694920551
 0.14909750875746847
 -0.18173603368395481E-01
 0.98129236211534965
 0.18060005320519060E-01
 -0.22754827310269127E-02
 -0.22432847231736310E-03
]';
%z
z(21,:)=[
 -11.456891325450444
 -0.87330261723295410
 -0.77650572617579505
 -0.45659402098613203E-02
 0.15115146273554703
 -0.10577394128572592E-01
 -0.30509389254280084E-01
 0.47331045035301248E-03
]';

% Node 12
%x
x(22,:)=[
 30.428536019552428
 0.11569553457720631
 -0.72934047782697342
 0.22329686372911231E-01
 -0.22672517214830781
 0.00000000000000000E+00
 0.45870124690470720E-01
 0.38764933520878279E-01
]';
%y
y(22,:)=[
 29.488180136223672
 0.41432774277372082E-01
 0.50681744331540557
 -0.24993363823321408E-02
 0.96334343034997683
 -0.22982135580721645E-01
 0.86834360157607843E-01
 0.81290023539737338E-02
]';
%z
z(22,:)=[
 4.5525820489911011
 -0.99242020762103333
 -0.45956343039275638
 -0.53770466612772662E-01
 0.14340547937878648
 -0.70034920327691208E-01
 -0.35733714131525103E-01
 0.39851469238741891E-02
]';


% apex calculations
v1=[x(2,1);y(2,1)]-[xa(1,1);ya(1,1)];
lv1 = norm(v1,2);
v1 = v1/lv1;
v2=[x(3,1);y(3,1)]-[xa(2,1);ya(2,1)];
lv2 = norm(v2,2);
v2 = v2/lv2;
n=[-v1(2);v1(1)];
ln=norm(n,2);
n=n/ln;
x(1,1) = xa(1,1);
y(1,1) = ya(1,1);
z(1,1) = za(1,1);
x(1,3) = xa(1,3);
y(1,3) = ya(1,3);
z(1,3) = ya(1,3);
x(1,2) = xa(2,3)*dot(v2,n);
y(1,2) = ya(2,3)*dot(v2,n);
z(1,2) = ya(2,3)*dot(v2,n);

v1=[x(13,1);y(13,1)]-[xa(3,1);ya(3,1)];
lv1 = norm(v1,2);
v1 = v1/lv1;
v2=[x(14,1);y(14,1)]-[xa(4,1);ya(4,1)];
lv2 = norm(v2,2);
v2 = v2/lv2;
n=[-v1(2);v1(1)];
ln=norm(n,2);
n=n/ln;
x(12,1) = xa(3,1);
y(12,1) = ya(3,1);
z(12,1) = za(3,1);
x(12,3) = xa(3,3);
y(12,3) = ya(3,3);
z(12,3) = ya(3,3);
x(12,2) = xa(4,3)*dot(v2,n);
y(12,2) = ya(4,3)*dot(v2,n);
z(12,2) = ya(4,3)*dot(v2,n);


% swap xi1 and xi2
x = [x(:,1),x(:,3),x(:,2),x(:,5),x(:,4),x(:,7),x(:,6),x(:,8)];
y = [y(:,1),y(:,3),y(:,2),y(:,5),y(:,4),y(:,7),y(:,6),y(:,8)];
z = [z(:,1),z(:,3),z(:,2),z(:,5),z(:,4),z(:,7),z(:,6),z(:,8)];

x(1,2:3) = x(1,2:3);
y(1,2:3) = y(1,2:3);
z(1,2:3) = z(1,2:3);
x(12,2:3) = x(12,2:3);
y(12,2:3) = y(12,2:3);
z(12,2:3) = z(12,2:3);

