summaryrefslogtreecommitdiff
path: root/graphics/pstricks/contrib/vocaltract/VocalTract.sty
blob: 356fcff07ae349fe6b0f59374722776cabd44af9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
% VocalTract.sty
% Release version 1
%------------------------------------------------------------
% Vocal Tract Animation package for Latex:
% - for upper and lower respiration system
% - with Matlab Interoperability          
%              
%  Copyright: 
%
%  This material is subject to the LaTeX Project Public License. 
%  See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html 
%  for the details of that license.            
% 
%             Thermi, Greece, 13-03-2012
%-------------------------------------------------------------

% Required Packages 
\usepackage{color}
\definecolor{pink}{rgb}{.7,.7,.7}

\usepackage{multimedia,multido,animate,fp}
\usepackage{pstricks,pst-coil}
\usepackage{arrayjob,ifthen}

% After fp
\usepackage[point]{fltpoint}


%%=====================================================
%%   Maeda Coordinates
%%=====================================================
\@ifundefined{SpeakVec}{
\newarray\SpeakVec
\readarray{SpeakVec}{%
%%========================================================================================
%% 1. Jaw Position     4. Tongue Apex     7. Larynx Height       10. Nasal Cavity
%%  2. Tongue Position  5. Lip Aperture    8. Glottal Aperture    11. Phoneme Label 
%%   3. Tongue Shape     6. Lip Protrusion  9. Glottal Frequency  
%%========================================================================================
%%  1       2     3       4      5      6     7    8     9    10      11
%% JW      TP    TS      TA     LA     LP    LH   GA    FX    NS 
%%  3       3     3       3      3      3     3    3     3     3               Max 
%%  0       0     0       0      0      0     0    0     0     0               Relax
%% -3       3    -3      -3     -3     -3    -3   -3    -3    -3              Min
%%========================================================================================
%------------------------------------------------------------        Vowels  -------------
  0.5    &-2    & 1    &-2     & 1  & -1    & 0  & 0  &  0  & 0  &i& % 1  
  0.5    &-2    & 1    &-2     & 0  &  2    & 0  & 0  &  0  & 0  &y& % 2  (\"u)
   -1    &-1    & 1    &-2     & 1  & -0.5  & 0  & 0  &  0  & 0  &e& % 3 
   -1    &-1    & 1    &-2     & 0  &  2    & 0  & 0  &  0  & 0  &2& % 4  (\"o)
 -1.5    & 2.5  & 0    &-0.5   & 0  &  2    & 0  & 0  &  0  & 0  &E& % 5  (\"a)
 -1.5    & 1.5  & 0    & 0.5   & 0.5& -0.5  & 0  & 0  &  0  & 0  &@& % 6  (Schwa)
 -1.5    & 2.5  & 0    &-0.5   & 0.5& -0.5  & 0  & 0  &  0  & 0  &a& % 7
  0.5    & 2    & 1.5  &-2     &-1  &  1.5  & 0  & 0  &  0  & 0  &u& % 8 
 -0.4    & 3.0  & 1.5  & 0     &-0.3&  0    & 0  & 0  &  0  & 0  &o& % 9  
%-------------------------------------------------------------------Unvoiced Cons.--------
    0    &  0   & 0    &  0    &-3  &  0    & 0  &-3  & -3  & -3 &p& % 10 % UPlosives
    0    & -0.5 &-1    &  2.3  & 0  &  0    & 0  &-3  & -3  & -3 &t& % 11
    0    & -1.5 & 3    & -3    & 0  &  0    & 0  &-3  & -3  & -3 &k& % 12
    2    &  1   & 0    &  0    &-1.5& -2    & 0  &-3  & -3  & -3 &f& % 13 % UFricatives
    2.5  &  0   & 0    &  0.4  & 0  &  0    & 0  &-3  & -3  & -3 &s& % 14
    0    & -1   & 3    & -3    & 0  &  0    & 0  &-3  & -3  & -3 &x& % 15
%----------------------------------------------------------------- Voiced Cons. --------
    0    &  0   & 0    &  0    &-3  &  0    &-1  & -1 &  0  & -3 &b& % 16 % VPlosives 
    0    & -0.5 &-1    &  2.3  & 0  &  0    & 0  & -1 &  0  & -3 &d& % 17
    0    & -1.5 & 3    & -3    & 0  &  0    & 0  & -1 &  0  & -3 &g& % 18
    1    &  0   & 0    &  3    & 0  &  0    & 0  & -1 &  0  &  0 &r& % 19 % Rolled
    0    & -2   & 3    &  3    & 0  &  0    & 0  & -1 &  0  &  0 &l& % 20 % Lateral
    0    &  2.3 & 2.5  & -2    & 0  &  0    & 0  & -1 &  0  &  0 &R& % 21 % Approximants
    1    &  0   & 2    &  0    & 0  &  0    & 0  & -1 &  0  &  0 &j& % 22
    2    &  1   & 0    &  0    &-1.5& -2    & 0  & -1 &  0  &  0 &v& % 23 % VFricatives
    2.5  &  0   & 0    &  0.4  & 0  &  0    & 0  & -1 &  0  &  0 &z& % 24
    0    &  0   & 0    &  0    &-3  & -1    & 0  & -1 &  0  &  0 &m& % 25 % Nasals   
    0.5  &  0   & 0    &  3    & 0  &  0    & 0  & -1 &  0  &  0 &n& % 26 
}                                                                   
\dataheight=11                                                      
\def\Nframes{27}                                                     
}{}                                                                 
%--------------------------------------------------------------------------------------
% Maeda Loading Factors for                                         
%                                       Tongue                                                                                 Larynx                                       Lips
%  A[i][0]     A[i][1]     A[i][2]     A[i][3]    s_tng[i]   u_tng[i    vtos[i].x   vtos[i].y   igd[i].x  igd[i].y  |    A_lrx[i][0,1]      s_rlx[i]      u_lrx[i]   |       A_lip[i][0,1,2]               s_lip[i]    u_lip[i]   
%                                                                                                             10               11,12            13            14               15,16,17                       18           19          
\newarray\AMaeda                                                    
\readarray{AMaeda}{%                                                
  1.000000 &  0.000000 &  0.000000 &  0.000000 & 0.293351 & 1.105280 &  0        & 0        & 0         & 0         &  1.000000 & 0.000000 & 0.293351 &   1.105280 &  1.000000 &  0.000000 &  0.000000  & 0.293351 & 1.105280 &%
 -0.464047 &  0.098776 & -0.251690 &  0.228351 & 0.317448 & 4.706277  &  0.980785 &-0.195090 & 10.634367 & 5.134503  & -0.208338 & 0.262446 & 0.440889 &   1.517271 &  0.178244 & -0.395733 &  0.888897  & 0.350522 & 1.301809 &% 
 -0.328015 &  0.337579 & -0.283667 &  0.568234 & 0.473761 & 4.775106  &  0.980785 &-0.195090 & 10.829458 & 6.115289  &  0.127814 & 0.991798 & 0.694961 & -10.051230 & -0.154638 &  0.987971 &  0.000000  & 1.053558 & 1.440946 &% 
 -0.213039 &  0.485565 & -0.283533 &  0.653696 & 1.052688 & 4.239388  &  0.980785 &-0.195090 & 11.024549 & 7.096074  & -0.131840 & 0.300784 & 0.470351 &   4.289589 & -0.217332 &  0.825187 & -0.303429  & 2.268359 & 4.880673 &% 
 -0.302565 &  0.705432 & -0.379044 &  0.392917 & 1.026836 & 3.695193 &  0.980785 &-0.195090 & 11.219639 & 8.076859  &  0.097688 & 0.934267 & 0.701163 & -10.207126 &  0        &  0        &  0         & 0        & 0        &%
 -0.327806 &  0.786897 & -0.388116 &  0.245703 & 0.891888 & 3.722520  &  0.980785 &-0.195090 & 11.414729 & 9.057644  &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.325065 &  0.852409 & -0.285125 &  0.176843 & 0.830590 & 3.873289 &  0.980785 &-0.195090 & 11.609819 & 10.038429 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.325739 &  0.904725 & -0.142602 &  0.138558 & 0.777910 & 3.925084  &  0.980785 &-0.195090 & 11.804910 & 11.019215 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.313741 &  0.926339 &  0.021042 &  0.122976 & 0.773024 & 3.775744  &  0.980785 &-0.195090 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.288138 &  0.924019 &  0.131949 &  0.116762 & 0.757404 & 3.624036  &  1.000000 & 0.000000 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.249008 &  0.909585 &  0.250320 &  0.112433 & 0.734461 & 3.520446  &  0.980785 & 0.195090 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.196936 &  0.882236 &  0.369083 &  0.112396 & 0.706124 & 3.464362  &  0.923880 & 0.382684 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.128884 &  0.830243 &  0.499894 &  0.115700 & 0.674199 & 3.461033  &  0.831470 & 0.555570 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
 -0.040825 &  0.730520 &  0.651662 &  0.112048 & 0.635628 & 3.515299  &  0.707107 & 0.707107 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &% 
  0.073420 &  0.543080 &  0.807947 &  0.126204 & 0.600972 & 3.637658  &  0.555570 & 0.831470 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.202726 &  0.230555 &  0.919065 &  0.163735 & 0.598000 & 3.829419  &  0.382684 & 0.923880 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.298853 & -0.162541 &  0.899074 &  0.213884 & 0.657375 & 4.083451  &  0.195090 & 0.980785 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.332785 & -0.491647 &  0.748869 &  0.243163 & 0.776293 & 4.365362  &  0.000000 & 1.000000 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.349955 & -0.681313 &  0.567615 &  0.245295 & 0.890489 & 4.618332  & -0.195090 & 0.980785 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.377277 & -0.771200 &  0.410502 &  0.249425 & 0.969776 & 4.823429  & -0.382684 & 0.923879 & 12.000000 & 12.000000 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.422713 & -0.804874 &  0.270513 &  0.274015 & 0.997716 & 4.905002  & -0.382684 & 0.923880 & 11.076120 & 11.617316 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.474635 & -0.797704 &  0.129324 &  0.314454 & 1.009611 & 4.802065  & -0.382684 & 0.923880 & 10.152241 & 11.234632 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.526087 & -0.746938 & -0.026201 &  0.366149 & 0.991273 & 4.581855  & -0.382684 & 0.923880 & 9.228361  & 10.851950 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.549466 & -0.643572 & -0.190005 &  0.422848 & 0.985804 & 4.317999  & -0.382684 & 0.923880 & 8.304482  & 10.469266 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.494200 & -0.504012 & -0.350434 &  0.488056 & 1.069908 & 4.076241  & -0.382683 & 0.923880 & 7.380602  & 10.086582 &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
  0.448797 & -0.417352 & -0.445410 &  0.500909 & 1.129032 & 3.856664  & -0.382684 & 0.923880 & 6.456723  & 9.703898  &  0        & 0        & 0        &   0        &  0        &  0        &  0         & 0        & 0        &%
}
\dataheight=19





%---------------------------------------------------------------------------------------
% Recall values from array
\def\RdVal#1#2#3{%
\dataheight=11
\checkSpeakVec(#2,#3)
\edef#1{\cachedata}}

\def\RdValM#1#2#3{%
\dataheight=19
\checkAMaeda(#2,#3)
\edef#1{\cachedata}}

% --  Tongue --     1      2        3     4   5    6   7  
%               {\vtngCx}{\vtngCy}{\JW}{\TP}{\TS}{\TA}{3}
\def\TongDepolarLinSys#1#2#3#4#5#6#7{
% Maeda Linear Transformations by Factor Analysis
%         vA         vB         vC          vD
%1 = \ATongA*2 + \ATongB*3 + \ATongC*4 + \ATongD*5
\RdValM{\ATongA}{#7}{1}
\RdValM{\ATongB}{#7}{2}
\RdValM{\ATongC}{#7}{3}
\RdValM{\ATongD}{#7}{4}
\fpMul\vA{\ATongA}{#3}
\fpMul\vB{\ATongB}{#4}
\fpMul\vC{\ATongC}{#5}
\fpMul\vD{\ATongD}{#6}
\fpAdd\v\vA\vB
\fpAdd\v\v\vC        
\fpAdd\v\v\vD
   %------ Depolarize --------
\RdValM{\stng}{#7}{5}
\RdValM{\utng}{#7}{6}
\RdValM{\vtosx}{#7}{7}
\RdValM{\vtosy}{#7}{8}
\RdValM{\igdx}{#7}{9}
\RdValM{\igdy}{#7}{10}
%
% Estimate v_tng[i] from v
\fpMul\vtng{\stng}{\v}
\fpAdd\vtng\vtng{\utng}
% Estimate x1 y1  from vtos[i].x  vtos[i].y  igd[i].x  igd[i].y 
% x1
\fpMul{#1}\vtosx\vtng
\fpAdd{#1}{#1}{\igdx}
\fpSub{#1}{20}{#1} % Reverse orientation
% y1
\fpMul{#2}{\vtosy}\vtng
\fpAdd{#2}{#2}{\igdy}
% Tranform to Ververidis system
\LinMov2Verver{#1}{#2}
%\psdot(#1,#2)
}


%----- Larynx ---------
%1     i=1 (xFront) ,2 (yFront), 3(xBack),4(yBack)  
%2.    v = A_lrx[i][0]*p[0] + A_lrx[i][1]*p[1]
%3.    v_lrx[i] = s_lrx[i]*v + u_lrx[i];         %
%
%                   1         2   3   4  
%               {\vlrxXorY}{\JW}{\LH}{3}    % X are 2,4   Y are 3,5
\def\LrxDepolarLinSys#1#2#3#4{
% Maeda Linear Transformations by Factor Analysis
%         vA         vB    
%1 = \ALrxA*2 + \ALrxB*3 
\RdValM{\ALrxA}{#4}{11}
\RdValM{\ALrxB}{#4}{12}
\fpMul\vLA{\ALrxA}{#2}
\fpMul\vLB{\ALrxB}{#3}
\fpAdd\vL\vLA\vLB
%   %------ Depolarize --------
\RdValM{\slrx}{#4}{13}
\RdValM{\ulrx}{#4}{14}
%%
%% Estimate v_tng[i] from v
\fpMul#1{\slrx}{\vL}
\fpAdd#1#1{\ulrx}

%% if X then reverse
%% Tranform to Ververidis system
\def\dum{3}
\ifthenelse{#4=2 \or #4=4}
{\fpSub{#1}{8}{#1}\LinMov2Verver{#1}{\dum}}{\fpAdd{#1}{12}{#1}\LinMov2Verver{\dum}{#1}}
%\rput(3,#4){#1}
}


%-------- Lips -------
%                      JW                LA                LP 
%1.  v =  A_lip[i][0]*p[0] + A_lip[i][1]*p[1] + A_lip[i][2]*p[2]
%2.  v_lip[i] = s_lip[i]*v + u_lip[i]        %
%
%                   1    2   3     4   5 
%               {\vlip}{\JW}{\LA}{\LP}{3} 
\def\LipDepolarLinSys#1#2#3#4#5{
%         vA         vB      vC  
%1 = \ALipA*2 + \ALipB*3 +  \ALipC*4
\RdValM{\ALipA}{#5}{15}
\RdValM{\ALipB}{#5}{16}
\RdValM{\ALipC}{#5}{17}
\fpMul\vA{\ALipA}{#2}
\fpMul\vB{\ALipB}{#3}
\fpMul\vC{\ALipC}{#4}
\fpAdd\vLip\vA\vB
\fpAdd\vLip\vLip\vC
%   %------ Depolarize --------
\RdValM{\slip}{#5}{18}
\RdValM{\ulip}{#5}{19}
%%
%% Estimate v_tng[i] from v
\fpMul#1{\slip}{\vLip}
\fpAdd#1#1{\ulip}
%
%% if X then reverse
%% Tranform to Ververidis system
%\def\dum{3}
%\ifthenelse{#4=2 \or #4=4}
%{\fpSub{#1}{8}{#1}\LinMov2Verver{#1}{\dum}}{\fpAdd{#1}{12}{#1}\LinMov2Verver{\dum}{#1}}
%\rput(3,#5){#1}
}



%-------------- Transform to Ververidis Coordinates  --------
\def\LinMov2Verver#1#2{
% X
\fpSub{#1}{#1}{1.0465}
\fpDiv{#1}{#1}{13.1774}
\fpAdd{#1}{#1}{1.04}
% Y
\fpSub{#2}{#2}{1.8}
\fpDiv{#2}{#2}{12.3704}
\fpAdd{#2}{#2}{4.5}
}




%============= Breath Oscillation Params ====
\def\OscAmp{0}
\newcommand{\SetOscAmp}[2]{%
   \FPmul\OscAmp{#1}{0.314}
   \FPadd\OscAmp{\OscAmp}{1.57}
   \FPcos\OscAmp{\OscAmp}                 %     cos(i*2pi/20 + pi/2)/2
   \FPmul\OscAmp{\OscAmp}{#2}
   \UpdateRespOscillation    % For Breath 
}


\def\VarOut{0}
\def\ScaledOsc{0}
\newcommand{\SetScaledOsc}[2]{%
  \FPmul{\ScaledOsc}{#1}{\OscAmp}
  \FPadd{#2}{\ScaledOsc}{#2}
}


%========== Upper Respiration Sustem Cords
%
% Nose - Esophagus (Static)
\def\NoseBaseX{2.325}      \def\NoseBaseY{6} 
\def\NoseEdgeX{2.4375}     \def\NoseEdgeY{6.1} 
\def\NoseBoneUpX{2.28}    \def\NoseBoneUpY{6.37}
\def\NoseBoneDownX{2.43} \def\NoseBoneDownY{6.15}
\def\NoseBoneInX{2.32}     \def\NoseBoneInY{6.2}  
\def\NasalCavFrontX{2.175}  \def\NasalCavFrontY{6.4}
\def\NasalCavCeilX{1.8}   \def\NasalCavCeilY{6.5}
\def\NasalCavBackX{1.35}   \def\NasalCavBackY{6.4}
\def\NasalSphenoidUpX{1.35}    \def\NasalSphenoidUpY{6.3}
\def\NasalSphenoidDownX{1.275}  \def\NasalSphenoidDownY{6.2}
\def\NasalPortStaticUpX{1.07}    \def\NasalPortStaticUpY{5.7}    %1.05,5.7
\def\NasalPortStaticDownX{1.04}    \def\NasalPortStaticDownY{5.55}    %1.05,5.7
%
\def\PharynxBackUpStaticX{1.04}  \def\PharynxBackUpStaticY{5.43}         %1.0875,5.3
\def\PharynxBackMiddleStaticX{1.07}  \def\PharynxBackMiddleStaticY{5.14}
\def\PharynxBackDownStaticX{1.1}      \def\PharynxBackDownStaticY{4.81}
%
\def\EsophagusBackX{0.9375}      \def\EsophagusBackY{4.3}   
\def\EsophagusFrontX{1.0875}     \def\EsophagusFrontY{4.3}
\def\EsophagusPortX{1.2}      \def\EsophagusPortY{4.7}     %1.27,4.9     ok
%
\def\LarynxFrontX{1.35}        \def\LarynxFrontY{4.3} 
\def\LarynxBackX{1.2}         \def\LarynxBackY{4.3}
%
 
%
% Jaw and Jugular notch
\def\JugularNotchX{1.65}      \def\JugularNotchY{4.2}
\def\AdamsAppleX{1.725}       \def\AdamsAppleY{4.8}
\def\ThyroidX{1.7}          \def\ThyroidY{4.9}
%
%Lips
\def\LipUpOutX{\LipOutX}        \def\LipUpOutY{\LipUpY}
\def\LipUpInX{\LipInX}          \def\LipUpInY{\LipUpY}  
\def\LipDownOutX{\LipOutX}      \def\LipDownOutY{\LipDownY}
\def\LipDownInX{\LipInX}        \def\LipDownInY{\LipDownY}

% Up
\def\LipUpBaseOutX{2.25}    \def\LipUpBaseOutY{5.8}

%
% Oral-Nasal Separation
\def\NasalCavAlvX{2.025}   \def\NasalCavAlvY{6.05}
\def\NasalCavPalX{1.725}   \def\NasalCavPalY{6.05}
\def\NasalCavVelarX{1.275} \def\NasalCavVelarY{5.9}
%
                             \def\NasalCavMovY{5.72}       
\def\UvularX{1.31}           \def\UvularY{5.73}              
\def\VelarX{1.4}             \def\VelarY{5.75}              
\def\PalatalX{1.66}          \def\PalatalY{5.85}           
% 
\def\PostPostAlveolarX{1.83} \def\PostPostAlveolarY{5.81} 
\def\PostAlveolarX{1.95}     \def\PostAlveolarY{5.725} 
\def\AlveolarX{2.02}         \def\AlveolarY{5.675}                               
                           

% Epiglotis to Tongue to DownTeeth
\def\HyoidUpX{1.255}       \def\HyoidUpY{4.9}
\def\HyoidDownX{1.260}       \def\HyoidDownY{4.8}
\def\EpiglotisBaseX{1.275}   \def\EpiglotisBaseY{5.1}
\def\EpiglotisX{1.2}       \def\EpiglotisY{5.3}
\def\TongueBaseX{1.35}      \def\TongueBaseY{5.1}
\def\TonguePharynxX{1.275}   \def\TonguePharynxY{5.4}
%
\def\TongueUvularX{1.3125}
\def\TongueVelarX{1.5}
\def\TonguePalatalX{1.725}
\def\TonguePostAlvX{1.875}
%
\def\TongueBaseFrontX{2} \def\TongueBaseFrontY{5.3} 
% Teeth
% up
\def\TeethUpBaseInX{2.1}  \def\TeethUpBaseInY{5.675}
\def\TeethUpEdgeX{2.185}       \def\TeethUpEdgeY{5.57}    
\def\TeethUpBaseOutX{2.2125} \def\TeethUpBaseOutY{5.7}    
% down
\def\TeethDownBaseInX{2.1}  \def\TeethDownBaseInY{5.4}
\def\TeethDownEdgeX{2.175}     \def\TeethDownEdgeY{5.5}
\def\TeethDownBaseOutX{2.2}  \def\TeethDownBaseOutY{5.35}
%
\def\SubTongueSalX{2.025}     \def\SubTongueSalY{5.3}




%============= LowerRespiration System Cords
\def\TracheaFrontX{1.35}\def\TracheaFrontY{4} 
\def\TracheaBackX{1.2} \def\TracheaBackY{4}
%
\def\LungsChestLevelFrontX{2.1}     \def\LungsChestLevelFrontY{2.5}
\def\LungsChestLevelBackX{0.45}      \def\LungsChestLevelBackY{2.5}
%
\def\LungsSternLevelBackX{0.3}      \def\LungsSternLevelBackY{1.2}
\def\LungsSternLevelBackXHelp{0.375}  \def\LungsSternLevelBackYHelp{1.3}
%
\def\LungsSternLevelFrontX{2.1}     \def\LungsSternLevelFrontY{1.2}
\def\LungsSternLevelFrontXHelp{2.1} \def\LungsSternLevelFrontYHelp{1.3}
%
\def\LungsSternLevelMiddleX{1.125}    \def\LungsSternLevelMiddleY{1.5}
%
\def\SkinChestFrontX{2.25}             \def\SkinChestFrontY{2.7}
%
\def\DiaphragmX{1.125}                \def\DiaphragmY{1.3}



%\pscustom[fillstyle=gradient,gradmidpoint=5,gradangle=45, gradbegin=white,gradend=red,showpoints=true,linecolor=black,linewidth=0pt]{ 


%================== ANDROID =====================
\newcommand{\BackToNoseEdge}{
% Back
\pscurve[linearc=0.3](0,0.5)(0.15,2)(0.75,5)
% Back Head to Eyes
\pscurve[linearc=0.3](0.75,5)(0.3,6.5)(0.75,7.3)(1.125,7.5)(1.875,7.4)(2.25,7)(2.25,6.5)(\NoseBoneUpX,\NoseBoneUpY)
% Nose
\pscurve(\NoseBoneUpX,\NoseBoneUpY)(\NoseBoneDownX,\NoseBoneDownY)
}

% Nose Edge to Lip Up
%[linearc=0.3,showpoints=false,linecolor=black,linewidth=1pt]
\newcommand{\NoseEdgeToLipUp}{
\pscurve(\NoseBoneDownX,\NoseBoneDownY)(\NoseEdgeX,\NoseEdgeY)(\NoseBaseX,\NoseBaseY)(\LipUpBaseOutX,\LipUpBaseOutY)}

% LipDown to JugularNotch
\newcommand{\LipDowntoJugularNotch}{
\pscurve(\LipDownOutX,\LipDownOutY)(\ChinUpX,\ChinUpY)(\ChinMiddleX,\ChinMiddleY)(\ChinDownX,\ChinDownY)(\ThyroidX,\ThyroidY)(\AdamsAppleX,\AdamsAppleY)(\JugularNotchX,\JugularNotchY)}
% Chest
\newcommand{\Chest}{
\pscurve[linearc=0.2](\JugularNotchX,\JugularNotchY)(\SkinChestFrontX,\SkinChestFrontY)(2.25,0.5)}


% Diaphragm
\newcommand{\Diaphragm}{\pscurve[linearc=1.5](0,0.5)(\DiaphragmX,\DiaphragmY)(2.25,0.5)}

%
%
% Nose, Nasal Cavity, Nasal Port 
% NasalUpperCav To Pharynx
\newcommand{\NasalCavUpToPharynx}{
\pscurve(\NoseBoneDownX,\NoseBoneDownY)(\NoseBoneInX,\NoseBoneInY)(\NasalCavFrontX,\NasalCavFrontY)(\NasalCavCeilX,\NasalCavCeilY)(\NasalCavBackX,\NasalCavBackY)(\NasalSphenoidUpX,\NasalSphenoidUpY)(\NasalSphenoidDownX,\NasalSphenoidDownY)
(\NasalPortStaticUpX,\NasalPortStaticUpY)(\NasalPortStaticDownX,\NasalPortStaticDownY)(\PharynxBackUpStaticX,\PharynxBackUpStaticY)}
%
% Pharynx, Esophagus, EsoPort
\newcommand{\PharynxToEsophag}{
\psline(\PharynxBackUpStaticX,\PharynxBackUpStaticY)(\PharynxBackMiddleStaticX,\PharynxBackMiddleStaticY)(\PharynxBackDownStaticX,\PharynxBackDownStaticY)%
(\EsophagusBackX,\EsophagusBackY)(\EsophagusBackX,3.5)%
(\EsophagusFrontX,3.75)(\EsophagusFrontX,\EsophagusFrontY)%
(\EsophagusPortX,\EsophagusPortY)(\ChordsJointBackX,\ChordsJointBackY)}
%
% LarynxBack, Trachea, Lungs, LarynxFront
\newcommand{\LarynxLungsChords}{
\psline(\ChordsJointBackX,\ChordsJointBackY)(\TracheaBackX,\TracheaBackY)(\LungsChestLevelBackX,\LungsChestLevelBackY)(\LungsSternLevelBackX,\LungsSternLevelBackY)     
%
\pscurve(\LungsSternLevelBackX,\LungsSternLevelBackY)(\LungsSternLevelBackXHelp,\LungsSternLevelBackYHelp)(\LungsSternLevelMiddleX,\LungsSternLevelMiddleY)(\LungsSternLevelFrontX,\LungsSternLevelFrontY)       
%
\pscurve(\LungsSternLevelFrontX,\LungsSternLevelFrontY)(\LungsSternLevelFrontXHelp,\LungsSternLevelFrontYHelp)(\LungsChestLevelFrontX,\LungsChestLevelFrontY)(\TracheaFrontX,\TracheaFrontY)(\LarynxFrontX,\LarynxFrontY)
%
\psline(\LarynxFrontX,\LarynxFrontY)(\ChordsJointFrontX,\ChordsJointFrontY)
}    
%
% Vocal Chords
\newcommand{\VocalChords}{%
{
%
\FPadd\MidXChords{\ChordsJointBackX}{\ChordsJointFrontX}
\FPdiv\MidXChords{\MidXChords}{2}
\FPsub\GlotalWidth\ChordsJointFrontX\ChordsJointBackX
\FPdiv\GlotalWidth{\GlotalWidth}{2}
%
\fpAdd\ChordsJointFrontBackAveY\ChordsJointBackY\ChordsJointFrontY
\fpDiv\ChordsJointFrontBackAveY\ChordsJointFrontBackAveY{2}
%
\pscustom[fillstyle=solid,fillcolor=pink]{
\psellipse[linewidth=0.2pt](\MidXChords,\ChordsJointFrontBackAveY)(\GlotalWidth,0.05)
\psellipse[linewidth=0.2pt](\MidXChords,\ChordsJointFrontBackAveY)(\GlotalWidth,\GlottalAperture)}
%
\psellipse*[linecolor=white,linewidth=0.2pt](\MidXChords,\ChordsJointFrontBackAveY)(\GlotalWidth,\GlottalAperture)
\psellipse[linewidth=0.2pt](\MidXChords,\ChordsJointFrontBackAveY)(\GlotalWidth,\GlottalAperture)
\FPmul\MinusFx\FX{-2}
\ifthenelse{\FX>2}{%
\pscoil[coilaspect=0,coilheight=0.7,coilwidth=0.1,coilarm=0.02,linewidth=\ChordsFrequency pt]%
(\ChordsJointBackX,\ChordsJointBackY)(\ChordsJointFrontX,\ChordsJointFrontY)}{}
}%
}
%
% Oral-Nasal Border (NoseBase, NasalFloor, OralCeil, TeethUp, LipUp
\newcommand{\OralNasalBorder}{
\pscurve[linewidth=0.5pt](\NoseBaseX,\NoseBaseY)(\NasalCavAlvX,\NasalCavAlvY)(\NasalCavPalX,\NasalCavPalY)(\NasalCavVelarX,\NasalCavVelarY)
\pscurve[linewidth=0.5pt](\NasalCavVelarX,\NasalCavVelarY)(\NasalCavMovX,\NasalCavMovY)(\UvularX,\UvularY)(\VelarX,\VelarY)(\PalatalX,\PalatalY)(\PostPostAlveolarX,\PostPostAlveolarY)(\PostAlveolarX,\PostAlveolarY)(\AlveolarX,\AlveolarY)
\psline[linewidth=0.5pt](\AlveolarX,\AlveolarY)(\TeethUpBaseInX,\TeethUpBaseInY)(\TeethUpEdgeX,\TeethUpEdgeY)(\TeethUpBaseOutX,\TeethUpBaseOutY)
\pscurve[linewidth=0.5pt](\TeethUpBaseOutX,\TeethUpBaseOutY)(\LipUpInX,\LipUpInY)(\LipUpOutX,\LipUpOutY)(\LipUpBaseOutX,\LipUpBaseOutY)(\NoseBaseX,\NoseBaseY)
}
%
% Chords to TongueAtPharynx
\newcommand{\ChordsToTongue}{
\pscurve[curvature=0.2 -0.5 -0.5](\ChordsJointFrontX,\ChordsJointFrontY)(\HyoidDownX,\HyoidDownY)(\HyoidUpX,\HyoidUpY)(\EpiglotisBaseX,\EpiglotisBaseY)
(\EpiglotisX,\EpiglotisY)(\TongueBaseX,\TongueBaseY)}
%
% Tongue at Pharynx to Tongue Base Front
\newcommand{\Tongue}{
\pscurve(\TonguePharynxX,\TonguePharynxY)(\TongueUvularX,\TongueUvularY)
(\TongueVelarX,\TongueVelarY)(\TonguePalatalX,\TonguePalatalY)(\TonguePostAlvX,\TonguePostAlvY)(\TongueAlveolarX,\TongueAlveolarY)(\TongueBaseFrontX,\TongueBaseFrontY)}

% Tongue Base Front to Down Lips
\newcommand{\TeethDownLips}{
\psline(\TongueBaseFrontX,\TongueBaseFrontY)(\SubTongueSalX,\SubTongueSalY)
(\TeethDownBaseInX,\TeethDownBaseInY)
(\TeethDownEdgeX,\TeethDownEdgeY)(\TeethDownBaseOutX,\TeethDownBaseOutY)
\pscurve[curvature=1 0.5 -0.5](\TeethDownBaseOutX,\TeethDownBaseOutY)
(\LipDownInX,\LipDownInY)(\LipDownOutX,\LipDownOutY)}


%========================
%   Stomach Compartment
%========================
\newcommand{\StomachCompartment}{
\psline[linearc=0](0,0.5)(0,0)(2.25,0)(2.25,0.5)
\FPsub\DiaphragmYALittleSmaller\DiaphragmY{0.05}
\pscustom[fillcolor=white,fillstyle=solid]{
\pscurve[linearc=0.1](0.9,\DiaphragmYALittleSmaller)(0.9,.7)(0.525,0.4) % Back Stomach
                     (1.125,0.2)                    % Bottom Point of Stomach
                     (1.725,0.4)(1.275,.7)(1.2,\DiaphragmY)} % Front Stomach

% ---- Electrode -----
%\psline[linecolor=gray,linewidth=1pt](1.35,\DiaphragmY)(1.35,1.9)    % Up Elect Sensor
%\psline[linewidth=1pt](1.35,0.5)(1.35,\DiaphragmY)   % Down Electr Sensor
}





%=======================
%     Red Flesh
%=======================

%Begin from 0,0.5 and end there also
\newcommand{\DrawRedFlesh}
{\pscustom[fillstyle=solid,fillcolor=pink]
{  
\BackToNoseEdge
\NasalCavUpToPharynx
\PharynxToEsophag
%
% Larynx until LungsBackStern
\psline(\ChordsJointBackX,\ChordsJointBackY)(\TracheaBackX,\TracheaBackY)(\LungsChestLevelBackX,\LungsChestLevelBackY)(\LungsSternLevelBackX,\LungsSternLevelBackY)
%
% LungsBackStern to LungsFrontStern
\pscurve(\LungsSternLevelBackX,\LungsSternLevelBackY)(\LungsSternLevelBackXHelp,\LungsSternLevelBackYHelp)(\LungsSternLevelMiddleX,\LungsSternLevelMiddleY)(\LungsSternLevelFrontX,\LungsSternLevelFrontY)
% LungsFrontStern to Trachea
\pscurve(\LungsSternLevelFrontX,\LungsSternLevelFrontY)(\LungsSternLevelFrontXHelp,\LungsSternLevelFrontYHelp)(\LungsChestLevelFrontX,\LungsChestLevelFrontY)(\TracheaFrontX,\TracheaFrontY)(\LarynxFrontX,\LarynxFrontY)
% Larynx to Chords 
\psline(\LarynxFrontX,\LarynxFrontY)(\ChordsJointFrontX,\ChordsJointFrontY)
% Chords to Epiglotis
\pscurve[curvature=0.2 -0.5 -0.5](\ChordsJointFrontX,\ChordsJointFrontY)(\HyoidDownX,\HyoidDownY)(\HyoidUpX,\HyoidUpY)(\EpiglotisBaseX,\EpiglotisBaseY)(\EpiglotisX,\EpiglotisY)(\TongueBaseX,\TongueBaseY)
%TongueBase to TongueFront
\Tongue
% Tongue Front to Lips Down
\TeethDownLips
% Lips Down to Jugular Notch
\LipDowntoJugularNotch
% Jugular Notch to Chest to Stern
\Chest
% Stern Diaphragm to Back
\pscurve[linearc=1.5](2.25,0.5)(\DiaphragmX,\DiaphragmY)(0,0.5)
}
}


\newcommand{\DrawRedFleshOralNasalBorder}
{\pscustom[fillstyle=solid,fillcolor=pink,linewidth=0.5pt]
{ 
\OralNasalBorder
}}

\newcommand{\DrawRedFleshStomach}
{\pscustom[fillstyle=solid,fillcolor=pink]
{\Diaphragm
\psline[linearc=0](2.25,0.5)(2.25,0)(0,0)(0,0.5)
}}

%===============================
% Update Respiration Oscillation 
%================================
\newcommand{\UpdateRespOscillation}{
    \SetScaledOsc{-0.2}{\LungsChestLevelFrontX}
    \SetScaledOsc{0.1}{\LungsChestLevelBackX}
    \SetScaledOsc{0.2}{\LungsSternLevelBackX}
    \SetScaledOsc{0.4}{\LungsSternLevelBackY}
    \SetScaledOsc{0.2}{\LungsSternLevelBackXHelp}
    \SetScaledOsc{0.4}{\LungsSternLevelBackYHelp}
     \SetScaledOsc{-0.2}{\LungsSternLevelFrontX}
    \SetScaledOsc{0.3}{\LungsSternLevelFrontY}
    \SetScaledOsc{-0.2}{\LungsSternLevelFrontXHelp}
    \SetScaledOsc{0.3}{\LungsSternLevelFrontYHelp}
    \SetScaledOsc{0.4}{\LungsSternLevelMiddleY}
    \SetScaledOsc{0.4}{\LungsSternLevelMiddleY}
    \SetScaledOsc{-0.2}{\SkinChestFrontX}
    \SetScaledOsc{0.6}{\DiaphragmY}
}

 
%\rput(0,0){\DiaphragmYLower}

%=============================================
%      Update Vocal Tract from File 
%=============================================
\newcommand{\UpdateVocalTract}[1]{
\RdVal{\JW}{#1}{1}
\RdVal{\TP}{#1}{2}
\RdVal{\TS}{#1}{3}
\RdVal{\TA}{#1}{4}
\RdVal{\LA}{#1}{5}
\RdVal{\LP}{#1}{6}
\RdVal{\LH}{#1}{7}
\RdVal{\GA}{#1}{8}
\RdVal{\FX}{#1}{9}
\RdVal{\NS}{#1}{10}
%% Linear Transfroms of Coordinates from Maeda to Ververidis
%% [-3,3] to [1.05,1.2]
%%1         % 3           % 5           % 7         %9     
%%F0 %LA    % NC || %UV    %VE   %PA   %PsAy  %ALx %ALy ||  LOx    LIx    LUy    LDy || GA    
%%-----------------------------------------------------------------------------------
%%0   4.5   1.09 || 5.45   5.6   5.65   5.65  2.025 5.5 || 2.250  2.197  5.58   5.45 || 0     Min (Open)
%%1   4.8   1.20 || 6.15   5.78  5.84   5.83  2.175 5.68|| 2.360  2.287   5.65   5.6 || 0.04  Max (Closed)
%-- \NasalCavMovX
\fpAdd\NSb\NS{3}
\fpDiv{\NSb}{\NSb}{6}
\fpMul{\NSb}{\NSb}{0.15}
\fpAdd{\NasalCavMovX}{\NSb}{1.09}
%-- \ChordsFrequency
\fpAdd\FX\FX{3}
\fpDiv\ChordsFrequency\FX{6}
%-- \GlottalAperture
\fpMul\GAb\GA{-1}
\fpAdd\GAb\GAb{3}
\fpDiv{\GAb}{\GAb}{6}
\fpMul{\GlottalAperture}{\GAb}{0.025}
%-- These are expressed as a linear transformation of the JW,TP,TS,TA,LA,LP,LH

% This is the way for the tongue

% C is Hyoid Down
\TongDepolarLinSys{\HyoidDownX}{\HyoidDownY}{\JW}{\TP}{\TS}{\TA}{2}
% D is Hyoid Up
\TongDepolarLinSys{\HyoidUpX}{\HyoidUpY}{\JW}{\TP}{\TS}{\TA}{3}
% D is EpiglotisBase
%\TongDepolarLinSys{\vtngEx}{\vtngEy}{\JW}{\TP}{\TS}{\TA}{4}
\def\EpiglotisBaseX{\HyoidUpX}
\def\EpiglotisBaseY{\HyoidUpY}
%\TongDepolarLinSys{\vtngFx}{\vtngFy}{\JW}{\TP}{\TS}{\TA}{5}
% G is TongueBase
\TongDepolarLinSys{\TongueBaseX}{\TongueBaseY}{\JW}{\TP}{\TS}{\TA}{6}
% H is Tongue Pharynx
\TongDepolarLinSys{\TonguePharynxX}{\TonguePharynxY}{\JW}{\TP}{\TS}{\TA}{7}
%\psdot[linecolor=blue,linewidth=4pt](\TonguePharynxX,\TonguePharynxY)
% I is Epiglotis (x,y are a bit reduced)
\TongDepolarLinSys{\EpiglotisXa}{\EpiglotisYa}{\JW}{\TP}{\TS}{\TA}{8}
\fpSub\EpiglotisX\EpiglotisXa{0.03}
\fpSub\EpiglotisY\EpiglotisYa{0.1}
%\psdot[linecolor=blue](\EpiglotisX,\EpiglotisY)
%\TongDepolarLinSys{\vtngJx}{\vtngJy}{\JW}{\TP}{\TS}{\TA}{9}
%\TongDepolarLinSys{{\vtngKy}{{\vtngKy}{\JW}{\TP}{\TS}{\TA}{10}
%\TongDepolarLinSys{\vtngLx}{\vtngLy}{\JW}{\TP}{\TS}{\TA}{11}
% M is Uvular
\TongDepolarLinSys{\TongueUvularX}{\TongueUvularY}{\JW}{\TP}{\TS}{\TA}{12}
%\psdot[linecolor=blue](\TongueUvularX,\TongueUvularY)
%\TongDepolarLinSys{\vtngNx}{\vtngNy}{\JW}{\TP}{\TS}{\TA}{13}
%\TongDepolarLinSys{\vtngOx}{\vtngOy}{\JW}{\TP}{\TS}{\TA}{14}
% P is velar
\TongDepolarLinSys{\TongueVelarX}{\TongueVelarY}{\JW}{\TP}{\TS}{\TA}{15}
%\psdot[linecolor=blue](\TongueVelarX,\TongueVelarY)
%\TongDepolarLinSys{\vtngQx}{\vtngQy}{\JW}{\TP}{\TS}{\TA}{16}
%\TongDepolarLinSys{\vtngRx}{\vtngRy}{\JW}{\TP}{\TS}{\TA}{17}
%\TongDepolarLinSys{\vtngSx}{\vtngSy}{\JW}{\TP}{\TS}{\TA}{18}
% T is Palatal
\TongDepolarLinSys{\TonguePalatalX}{\TonguePalatalY}{\JW}{\TP}{\TS}{\TA}{19} %\def\TonguePalatalY{5.65}
%\psdot[linecolor=blue](\TonguePalatalX,\TonguePalatalY)
%\TongDepolarLinSys{\vtngUx}{\vtngUy}{\JW}{\TP}{\TS}{\TA}{20}
%\TongDepolarLinSys{\vtngVx}{\vtngVy}{\JW}{\TP}{\TS}{\TA}{21}
% W is TonguePostAlv
\TongDepolarLinSys{\TonguePostAlvX}{\TonguePostAlvY}{\JW}{\TP}{\TS}{\TA}{22}
%\psdot[linecolor=blue](\TonguePostAlvX,\TonguePostAlvY)
\TongDepolarLinSys{\vtngXx}{\vtngXy}{\JW}{\TP}{\TS}{\TA}{23}
\TongDepolarLinSys{\vtngYx}{\vtngYy}{\JW}{\TP}{\TS}{\TA}{24}
% Z is TongueAlveolar
\TongDepolarLinSys{\TongueAlveolarX}{\TongueAlveolarY}{\JW}{\TP}{\TS}{\TA}{25}
%\psdot[linecolor=blue](\TongueAlveolarX,\TongueAlveolarY)
%\TongDepolarLinSys{\vtngPhix}{\vtngPhiy}{\JW}{\TP}{\TS}{\TA}{26}

%---------- Chord Joint Front and Back --------- 
\LrxDepolarLinSys{\ChordsJointFrontX}{\JW}{\LH}{2}
\LrxDepolarLinSys{\ChordsJointFrontY}{\JW}{\LH}{3}
\LrxDepolarLinSys{\ChordsJointBackX}{\JW}{\LH}{4}
\LrxDepolarLinSys{\ChordsJointBackY}{\JW}{\LH}{5}
%------------ Lips --------------------------------
\LipDepolarLinSys{\vlipA}{\JW}{\LA}{\LP}{2}

\fpDiv\LAVerver\LA{3} % Verver here

\LipDepolarLinSys{\vlipB}{\JW}{\LAVerver}{\LP}{3}
\LipDepolarLinSys{\vlipC}{\JW}{\LA}{\LP}{4}

\def\LipInX{3.65}                  % In X  
\fpSub\LipInX{20}\LipInX
\def\Dumm{0}
\LinMov2Verver{\LipInX}{\Dumm}

\def\LipUpY{15.18}                % Up Y 
\LinMov2Verver{\Dumm}{\LipUpY}

\def\LipOutX{3.65}                % Out X
\fpSub\LipOutX\LipOutX{\vlipA}
\fpSub\LipOutX{20}\LipOutX
\LinMov2Verver{\LipOutX}{\Dumm}

\fpSub\LipDownY{15.18}{\vlipB}    % Down Y 
\LinMov2Verver{\Dumm}{\LipDownY}

%vlip[1] = 1.3
%vlip[2] = 1.44
%vlip[3] = 4.88
%----------------- JAW Components ----------

\fpAdd\JawRadiiY\JW{-3}  
\fpMul\JawRadiiY\JW{0.015}  

\def\ChinDownX{2.25}            \fpAdd\ChinDownY{5.1}\JawRadiiY
\def\ChinMiddleX{2.325}         \fpAdd\ChinMiddleY{5.2}\JawRadiiY
\def\ChinUpX{2.25}              \fpAdd\ChinUpY{5.3}\JawRadiiY
\def\LipDownBaseOutX{2.25}      \fpAdd\LipDownBaseOutY{5.4}\JawRadiiY


\def\TeethDownBaseInX{2.1}  \fpAdd\TeethDownBaseInY{5.4}\JawRadiiY
\def\TeethDownEdgeX{2.175}     \fpAdd\TeethDownEdgeY{5.5}\JawRadiiY
\def\TeethDownBaseOutX{2.2}  \fpAdd\TeethDownBaseOutY{5.35}\JawRadiiY
%
\def\SubTongueSalX{2.025}     \fpAdd\SubTongueSalY{5.3}\JawRadiiY


%
\BackToNoseEdge
\NasalCavUpToPharynx
\PharynxToEsophag
\LarynxLungsChords
\Diaphragm
\Chest
\LipDowntoJugularNotch
%
\NoseEdgeToLipUp
\OralNasalBorder
%
\ChordsToTongue

\Tongue
\TeethDownLips
%
\DrawRedFlesh
\DrawRedFleshOralNasalBorder
\DrawRedFleshStomach
}

%=======================================
%       Plot dots Movable Parts 
%=======================================
\newcommand{\PlotDotsVocal}{
\uput[45](\ChordsJointBackX,\ChordsJointBackY){\scriptsize 1.Freq.}

\rput[c](\ChordsJointFrontX,\ChordsJointFrontY){$\bullet$}
\uput[320](\ChordsJointFrontX,4.7){\scriptsize 2.Larynx Height}

\rput[c](\NasalCavMovX,\NasalCavMovY){$\bullet$}
\uput[40](\NasalCavMovX,\NasalCavMovY){\scriptsize 3.NasalCav}

\rput[c](\TongueUvularX,\TongueUvularY){$\bullet$}
\uput[300](\TongueUvularX,\TongueUvularY){\scriptsize 4.Uvular}

\rput[c](\TongueVelarX,\TongueVelarY){$\bullet$}
\uput[270](\TongueVelarX,\TongueVelarY){\scriptsize 5.Velar}

\rput[c](\TonguePalatalX,\TonguePalatalY){$\bullet$}
\uput[270](\TonguePalatalX,\TonguePalatalY){\scriptsize 6.Palatal}

\rput[c](\TonguePostAlvX,\TonguePostAlvY){$\bullet$}
\uput[100](\TonguePostAlvX,\TonguePostAlvY){\scriptsize 7.PostAlv}

\rput[c](\TongueAlveolarX,\TongueAlveolarY){$\bullet$}
\uput[20](\TongueAlveolarX,\TongueAlveolarY){\scriptsize 8.Alveolar}

\rput[c](\LipUpOutX,\LipUpOutY){$\bullet$}
\uput[0](\LipUpOutX,\LipUpOutY){\scriptsize 9.LipUpOut}
\rput[c](\LipDownOutX,\LipDownOutY){$\bullet$}
\uput[0](\LipDownOutX,\LipDownOutY){\scriptsize 10.LipDownOut}

\rput[c](\LipUpInX,\LipUpInY){$\bullet$}
\uput[90](\LipUpInX,\LipUpInY){\scriptsize 11.LipUpIn}
\rput[c](\LipDownInX,\LipDownInY){$\bullet$}
\uput[270](\LipDownInX,\LipDownInY){\scriptsize 12.LipDownIn}}


%============================================
%  Show Phonemes German
%============================================
\newcommand{\ShowPhonemesGerman}[1]{
\RdVal{\PhonemeLabel}{#1}{11}
\parbox{2cm}{\Large\PhonemeLabel}}


%============================================
%     Show Red Pressure
%============================================

\newcommand\ShowPressure[1]{%
\RdVal{\PhonemeLabel}{#1}{11}
% p 
\ifthenelse{\equal{\PhonemeLabel}{p}\or\equal{\PhonemeLabel}{b}}{\pscustom[fillcolor=red,fillstyle=solid]{%
%% Chords to Tongue Base
\ChordsToTongue
%% Tongue at Pharynx to Tongue Base Front
\Tongue
% Tongue Base Front to Down Lips In
\psline(\TongueBaseFrontX,\TongueBaseFrontY)(\SubTongueSalX,\SubTongueSalY)
(\TeethDownBaseInX,\TeethDownBaseInY)
(\TeethDownEdgeX,\TeethDownEdgeY)(\TeethDownBaseOutX,\TeethDownBaseOutY)
\pscurve(\TeethDownBaseOutX,\TeethDownBaseOutY)
(\LipDownInX,\LipDownInY)
% LipUpIn to TeethBaseOut
\pscurve(\LipUpInX,\LipUpInY)(\TeethUpBaseOutX,\TeethUpBaseOutY)
% TeethBaseOut to Alveolar 
\psline(\TeethUpBaseOutX,\TeethUpBaseOutY)(\TeethUpEdgeX,\TeethUpEdgeY)(\TeethUpBaseInX,\TeethUpBaseInY)(\AlveolarX,\AlveolarY)
% NasalCavMov to Alveolar
\pscurve(\AlveolarX,\AlveolarY)(\PostAlveolarX,\PostAlveolarY)(\PostPostAlveolarX,\PostPostAlveolarY)(\PalatalX,\PalatalY)(\VelarX,\VelarY)(\UvularX,\UvularY)(\NasalCavMovX,\NasalCavMovY)
% NCavPort to Pharynx
\psline(\NasalCavMovX,\NasalCavMovY)(\NasalPortStaticUpX,\NasalPortStaticUpY)
(\NasalPortStaticDownX,\NasalPortStaticDownY)(\PharynxBackUpStaticX,\PharynxBackUpStaticY)
%
% Pharynx, Esophagus, EsoPort
\PharynxToEsophag
% LarynxBack, Trachea, Lungs, LarynxFront
\LarynxLungsChords
}}{}
% t
\ifthenelse{\equal{\PhonemeLabel}{t} \or \equal{\PhonemeLabel}{d}}{
\pscustom[fillcolor=red,fillstyle=solid]{%
%% Chords to Tongue Base
\ChordsToTongue
%% Tongue at Pharynx to Tongue Base Front
\pscurve(\TonguePharynxX,\TonguePharynxY)(\TongueUvularX,\TongueUvularY)
(\TongueVelarX,\TongueVelarY)(\TonguePalatalX,\TonguePalatalY)(\TonguePostAlvX,\TonguePostAlvY)(\TongueAlveolarX,\TongueAlveolarY)
%
\pscurve(\AlveolarX,\AlveolarY)(\PostAlveolarX,\PostAlveolarY)
(\PostPostAlveolarX,\PostPostAlveolarY)(\PalatalX,\PalatalY)
(\VelarX,\VelarY)(\UvularX,\UvularY)(\NasalCavMovX,\NasalCavMovY)
% NCavPort to Pharynx
\psline(\NasalCavMovX,\NasalCavMovY)(\NasalPortStaticUpX,\NasalPortStaticUpY)
(\NasalPortStaticDownX,\NasalPortStaticDownY)(\PharynxBackUpStaticX,\PharynxBackUpStaticY)
(\PharynxBackMiddleStaticX,\PharynxBackMiddleStaticY)(\PharynxBackDownStaticX,\PharynxBackDownStaticY)
% Pharynx, Esophagus, EsoPort
\PharynxToEsophag
% LarynxBack, Trachea, Lungs, LarynxFront
\LarynxLungsChords
}}{}
%
%k
\ifthenelse{\equal{\PhonemeLabel}{k} \or \equal{\PhonemeLabel}{g}}{\pscustom[fillcolor=red,fillstyle=solid]{%
%% Chords to Tongue Base
\ChordsToTongue
%% Tongue at Pharynx to Tongue Base Front
\pscurve(\TonguePharynxX,\TonguePharynxY)(\TongueUvularX,\TongueUvularY)
(\TongueVelarX,\TongueVelarY)
%
\pscurve(\VelarX,\VelarY)(\UvularX,\UvularY)(\NasalCavMovX,\NasalCavMovY)
% NCavPort to Pharynx
\psline(\NasalCavMovX,\NasalCavMovY)(\NasalPortStaticUpX,\NasalPortStaticUpY)(\NasalPortStaticDownX,\NasalPortStaticDownY)
(\PharynxBackUpStaticX,\PharynxBackUpStaticY)
% Pharynx, Esophagus, EsoPort
\PharynxToEsophag
% LarynxBack, Trachea, Lungs, LarynxFront
\LarynxLungsChords
}}{}
%
}

%=========================================
%     Show Linear Vocal Tube
%=========================================
\newcommand\ShowLinearTubes[1]{
% ChordsFront to DownLips
\psline[linecolor=blue,showpoints=true](\ChordsJointFrontX,\ChordsJointFrontY)(\HyoidDownX,\HyoidDownY)
(\HyoidUpX,\HyoidUpY)(\EpiglotisBaseX,\EpiglotisBaseY)(\EpiglotisX,\EpiglotisY)(\TonguePharynxX,\TonguePharynxY)
(\TongueUvularX,\TongueUvularY)(\TongueVelarX,\TongueVelarY)(\TonguePalatalX,\TonguePalatalY)
(\TonguePostAlvX,\TonguePostAlvY)(\TongueAlveolarX,\TongueAlveolarY)(\SubTongueSalX,\SubTongueSalY)
(\TeethDownBaseInX,\TeethDownBaseInY)(\TeethDownEdgeX,\TeethDownEdgeY)(\LipDownInX,\LipDownInY)(\LipDownOutX,\LipDownOutY)
% ChordsBack to NPortStatic
\psline[linecolor=blue,showpoints=true](\ChordsJointBackX,\ChordsJointBackY)(\EsophagusPortX,\EsophagusPortY)
(\PharynxBackDownStaticX,\PharynxBackDownStaticY)
(\PharynxBackMiddleStaticX,\PharynxBackMiddleStaticY)
(\PharynxBackUpStaticX,\PharynxBackUpStaticY)
(\NasalPortStaticDownX,\NasalPortStaticDownY)
(\NasalPortStaticUpX,\NasalPortStaticUpY)
%
%NPortStatic to Nose
%\ifthenelse{#2=1.2}{%
\psline[linecolor=blue,showpoints=true](\NasalPortStaticDownX,\NasalPortStaticDownY)(\NasalPortStaticUpX,\NasalPortStaticUpY)(\NasalSphenoidDownX,\NasalSphenoidDownY)(\NasalSphenoidUpX,\NasalSphenoidUpY)(\NasalCavBackX,\NasalCavBackY)(\NasalCavCeilX,\NasalCavCeilY)(\NasalCavFrontX,\NasalCavFrontY)(\NoseBoneInX,\NoseBoneInY)(\NoseBoneDownX,\NoseBoneDownY)%}{}
% Nose to NCavPort To Upper Lips
\psline[linecolor=blue,showpoints=true](\NoseBaseX,\NoseBaseY)(\NasalCavAlvX,\NasalCavAlvY)(\NasalCavPalX,\NasalCavPalY)(\NasalCavVelarX,\NasalCavVelarY)(\NasalCavMovX,\NasalCavMovY)(\UvularX,\UvularY)(\VelarX,\VelarY)(\PalatalX,\PalatalY)(\PostPostAlveolarX,\PostPostAlveolarY)(\PostAlveolarX,\PostAlveolarY)(\AlveolarX,\AlveolarY)(\TeethUpBaseInX,\TeethUpBaseInY)(\TeethUpEdgeX,\TeethUpEdgeY)%(\TeethUpBaseOutX,\TeethUpBaseOutY)
(\LipUpInX,\LipUpInY)(\LipUpOutX,\LipUpOutY)
}

%=========================================
%     Show CrossSection Areas
%=========================================
\newcommand\ShowParameters{%
%Lines
% 1. JW: Jaw Position
\rput[l](1.8  ,4.8  ){1}
% 2. TP: Tongue Position
\rput[l](1.2  ,5){2}
% 3. TS: Tongue Shape
\rput[l](1.4  ,5){3}
% 4. TA: Tongue Apex
\rput[l](2  ,5.8){4}
%% 5. LA: LIPS APERTURE 
%\psline[linecolor=green,showpoints=true](\LipOutX,\LipDownY)(\LipOutX,\LipUpY)
\rput[t](\LipOutX,\LipUpY){5}
%%% 6. LP: LIPS PROTRUSION
%\psline[linecolor=green,showpoints=true](\LipDownInX,\LipDownInY)(\LipDownOutX,\LipDownOutY)
\rput[lt](\LipDownOutX,\LipDownOutY){6}
%%% 7. LH: LARYNX HEIGHT
%\psline[linecolor=green,showpoints=true](\ChordsJointFrontX,\ChordsJointFrontY)(\HyoidDownX,\HyoidDownY)
%%% 8. GA: Glottis Aperture
%%% 9. FX: Fund. Frequency
\rput[l](\ChordsJointFrontX,\ChordsJointFrontY){7,8,9}
%%% 10. NS: Nasal Cavity 
%\psline[linecolor=green,showpoints=true](\NasalCavMovX,\NasalCavMovY)(\NasalPortStaticUpX,\NasalPortStaticUpY)
\rput[rb](\NasalPortStaticUpX,\NasalPortStaticUpY){10\hspace{0.75cm}}
%
%
\rput[l](0.75,1.7){\parbox{5cm}{1. JW: Jaw Position    = \JW \\
                              2. TP: Tongue Position = \TP \\
                              3. TS: Tongue Shape    = \TS \\
                              4. TA: Tongue Apex     = \TA \\ 
                              5. LA: Lips Aperture   = \LA \\
                              6. LP: Lips Protrusion = \LP \\
                              7. LH: Larynx Heigh    = \LH \\
                              8. GA: Glottis Aperture= \GA \\
                              9. FX: Fund. Frequency = \FX \\
                             10. NS: Nasal Cavity   = \NS}}
}