(* export function for plot figures *)
<<peeters`
peeters`setGitDir[ "../project/figures/GAelectrodynamics" ]

Rework the manipulate for figure in reciprocal.tex

bold = Style[ #, Bold] &;
(*(OverHat[a])( (OverHat[a]) · b ) // FullForm
(OverHat[a])( (OverHat[a]) ⋀ b ) // FullForm*)
ubold = bold["u"];
xbold = bold["x"];
(*tproj=Row[{OverHat[ubold],"(",CenterDot[OverHat[ubold],xbold], ")"}];
trej = Row[{OverHat[ubold],"(",Wedge[OverHat[ubold],xbold], ")"}];*)

(*
*)



(*tproj
trej*)

mtrej=Row[{"-(",Wedge[xbold,ubold], ")",1/ ubold}];
ref=Row[{ubold,xbold, 1/ubold}];

Manipulate[
DynamicModule[{ bproj, brej, o, s, ao, to, acap, bcap, sqn,tproj, trej},
o = {0, 0} ;
ao = {0,.15} ;
s = 0 ;
sqn= 5;
to[start_, end_, ss_ :s] =  start + (end-start)(1 + ss/Norm[end-start]) ;


acap = a/Norm[a];
bcap= b/Norm[b];
bproj = acap (acap.b);
brej = b - bproj;

tproj = Row[{Subscript["Proj",ubold], "(", xbold, ")"}];
trej = Row[{Subscript["Rej",ubold], "(", xbold, ")"}];

Graphics[{
Thick
, Arrow[{o, b}, ao]

,Darker[Blue]
, Arrow[{o, bproj}, ao]

,Darker[Purple]
, Arrow[{bproj, a}, ao]

, Darker[Red]
, Arrow[{bproj, b}, ao]

(*, Darker[Green]
, Arrow[{bproj, bproj-brej}, ao]

,Darker[Green]
, Arrow[{o, bproj-brej}, ao]*)

, Black
,PointSize[Large]
, Point[b]
(*,PointSize[Large]
, Point[bproj-brej]*)
, Text[xbold ,to[o,b, 0.3 ],Background->White]
, Text[ubold ,to[o,a ],Background->White]
, Text[tproj ,to[o,bproj/2],Background->White]
, Text[trej , to[bproj ,bproj+ brej/2 ],Background->White]
(*, Text[mtrej , to[bproj ,bproj- brej/2 ],Background->White]
*)
,Black
,Opacity[0.5]
,Parallelogram[bproj,{Normalize[brej]/sqn,Normalize[bproj]/sqn}]

}
, Frame->True
, GridLines->Automatic
, GridLinesStyle->Directive[Orange,Dashed]
,BaseStyle->14 (* this changes the font, making it bigger *)
]

] 
, {{a,{4,2}},Locator}
, {{b,{3,3}},Locator}

]



Manipulate[
DynamicModule[{ bproj, brej, o, s, ao, to, acap, bcap, sqn, tproj, trej},
o = {0, 0} ;
ao = {0,.15} ;
s = 0 ;
sqn = 5;

to[start_, end_, ss_ :s] =  start + (end-start)(1 + ss/Norm[end-start]) ;


tproj=Row[{"(",CenterDot[xbold,ubold], ")" ,1/ubold}];
trej=Row[{"(",Wedge[xbold,ubold], ")",1/ ubold}];

acap = a/Norm[a];
bcap= b/Norm[b];
bproj = acap (acap.b);
brej = b - bproj;


Graphics[{
Thick
, Arrow[{o, b}, ao]

,Darker[Blue]
, Arrow[{o, bproj}, ao]

,Darker[Purple]
, Arrow[{bproj, a}, ao]

, Darker[Red]
, Arrow[{bproj, b}, ao]

, Darker[Green]
, Arrow[{bproj, bproj-brej}, ao]

,Darker[Green]
, Arrow[{o, bproj-brej}, ao]

, Black
,PointSize[Large]
, Point[b]
,PointSize[Large]
, Point[bproj-brej]
, Text[xbold ,to[o,b, 0.3 ],Background->White]
, Text[ubold ,to[o,a ],Background->White]
, Text[tproj ,to[o,bproj/2],Background->White]
, Text[trej , to[bproj ,bproj+ brej/2 ],Background->White]
, Text[mtrej , to[bproj ,bproj- brej/2 ],Background->White]
, Text[ref , to[o ,(bproj- brej)/2 ],Background->White]
,Black
,Opacity[0.5]
,Parallelogram[bproj,{Normalize[brej]/sqn,Normalize[bproj]/sqn}]


}
, Frame->True
, GridLines->Automatic
, GridLinesStyle->Directive[Orange,Dashed]
,BaseStyle->14 (* this changes the font, making it bigger *)
]

] 
, {{a,{4,2}},Locator}
, {{b,{3,3}},Locator}

]

reflection = DynamicModule[{a={4,2},b={3,3}},DynamicModule[{bproj,brej,o,s,ao,to,acap,bcap},o={0,0};ao={0,0.15`};s=0;to[start_,end_,ss_:s]=start+(end-start) (1+(ss/(Norm[end-start])));acap=(a/(Norm[a]));bcap=(b/(Norm[b]));bproj=acap acap.b;brej=b-bproj;Graphics[{Thick,Arrow[{o,b},ao],Darker[Blue],Arrow[{o,bproj},ao],Darker[Purple],Arrow[{bproj,a},ao],Darker[Red],Arrow[{bproj,b},ao],Darker[Green],Arrow[{bproj,bproj-brej},ao],Darker[Green],Arrow[{o,bproj-brej},ao],Black,PointSize[Large],Point[b],PointSize[Large],Point[bproj-brej],Text[xbold,to[o,b,0.3`],Background->White],Text[ubold,to[o,a],Background->White],Text[tproj,to[o,(bproj/2)],Background->White],Text[trej,to[bproj,bproj+(brej/2)],Background->White],Text[mtrej,to[bproj,bproj-(brej/2)],Background->White],Text[ref,to[o,((bproj-brej)/2)],Background->White]},Frame->True,GridLines->Automatic,GridLinesStyle->Directive[Orange,Dashed],BaseStyle->14]]]

sn = DynamicModule[{a={4,2},b={3,3}},DynamicModule[{bproj,brej,o,s,ao,to,acap,bcap, sqn, tproj, trej},o={0,0};ao={0,0.15`};s=0;
sqn = 5;
to[start_,end_,ss_:s]=start+(end-start) (1+(ss/(Norm[end-start])));
tproj = Row[{Subscript["Proj",ubold], "(", xbold, ")"}];
trej = Row[{Subscript["Rej",ubold], "(", xbold, ")"}];acap=(a/(Norm[a]));bcap=(b/(Norm[b]));bproj=acap acap.b;brej=b-bproj;Graphics[{Thick,Arrow[{o,b},ao],Darker[Blue],Arrow[{o,bproj},ao],Darker[Purple],Arrow[{bproj,a},ao],Darker[Red],Arrow[{bproj,b},ao],Black,PointSize[Large],Point[b],Text[xbold,to[o,b,0.3`],Background->White],Text[ubold,to[o,a],Background->White],Text[tproj,to[o,(bproj/2)],Background->White],Text[trej,to[bproj,bproj+(brej/2)],Background->White]
,Black
,Opacity[0.5]
,Parallelogram[bproj,{Normalize[brej]/sqn,Normalize[bproj]/sqn}]
},Frame->True,GridLines->Automatic,GridLinesStyle->Directive[Orange,Dashed],BaseStyle->14]]]

sn1 = DynamicModule[{a={4,2},b={2.338`,2.5`}},DynamicModule[{bproj,brej,o,s,ao,to,acap,bcap},o={0,0};ao={0,0.15`};s=0;to[start_,end_,ss_:s]=start+(end-start) (1+(ss/(Norm[end-start])));acap=(a/(Norm[a]));bcap=(b/(Norm[b]));bproj=acap acap.b;brej=b-bproj;Graphics[{Thick,Arrow[{o,b},ao],Darker[Blue],Arrow[{o,bproj},ao],Darker[Purple],Arrow[{bproj,a},ao],Darker[Red],Arrow[{bproj,b},ao],Black,PointSize[Large],Point[b],Text[xbold,to[o,b,0.3`],Background->White],Text[ubold,to[o,a],Background->White],Text[tproj,to[o,(bproj/2)],Background->White],Text[trej,to[bproj,bproj+(brej/2)],Background->White]},Frame->True,GridLines->Automatic,GridLinesStyle->Directive[Orange,Dashed],BaseStyle->14]]]

peeters`exportForLatex["projectionAndRejectionFig1", sn]

peeters`exportForLatex["reflectionFig1", reflection]