TXM2: Distance geometry between two points
1
.
Note​
​TXM is the author’s initials, 2 is the author’s formula code
2
.
Caption​
LetΔABCandP,Qaretwoarbitrarypoints.Thenwehave:​​
2
PQ
=
S
A
2
u
+
S
B
2
v
+
S
C
2
w
4
2
S
​​Where​​u=P
2
B
+Q
2
C
-P
2
C
-Q
2
B
​​v=P
2
C
+Q
2
A
-P
2
A
-Q
2
C
​​w=P
2
A
+Q
2
B
-P
2
B
-Q
2
A
​​S=2areaΔABC,
S
θ
=Scotθ(Conwaytrianglenotation)
3
.
Code
In[]:=
ManipulateModule{a,b,c,SA,SB,SC,S,AA,BB,CC,P,Q,PQ,PA,PB,PC,QA,QB,QC,u,v,w},a=Sqrt[y^2+yz+z^2];b=Sqrt[z^2+zx+x^2];c=Sqrt[x^2+xy+y^2];SA=(b^2+c^2-a^2)2;SB=(c^2+a^2-b^2)2;SC=(a^2+b^2-c^2)2;S=Sqrt[SASB+SBSC+SCSA];AA={b,0};BB={SC/b,S/b};​​CC={0,0};P={m,n};Q={p,q};PQ=EuclideanDistance[P,Q];PA=EuclideanDistance[P,AA];PB=EuclideanDistance[P,BB];PC=EuclideanDistance[P,CC];QA=EuclideanDistance[Q,AA];QB=EuclideanDistance[Q,BB];QC=EuclideanDistance[Q,CC];u=N[
2
PB
+
2
QC
-
2
PC
-
2
QB
];v=N[
2
PC
+
2
QA
-
2
PA
-
2
QC
];w=N[
2
PA
+
2
QB
-
2
PB
-
2
QA
];Column​​Text@Grid
​
​
"u=
2
PB
+
2
QC
-
2
PC
-
2
QB
","v=
2
PC
+
2
QA
-
2
PA
-
2
QC
","w=
2
PA
+
2
QB
-
2
PB
-
2
QA
",Style["
2
PQ
",Red],Style"
S
A
2
u
+
S
B
2
v
+
S
C
2
w
4
2
S
",Red,
​
​
u,v,w,Style[N[
2
PQ
],Red],Style
SA
2
u
+SB
2
v
+SC
2
w
4
2
S
,Red,Frame->All,FrameStyle->Hue[.6,.4,.8],Background->{None,{{None,GrayLevel[.9]}},{{1,1}->Hue[.6,.2,1],{1,2}->Hue[.6,.2,1],{1,3}->Hue[.6,.2,1],{1,4}->Hue[.6,.2,1],{1,5}->Hue[.6,.2,1],{1,6}->Hue[.6,.2,1]}},BaseStyle->{FontFamily->Times,FontSize->20},
{
Graphics[{Style[Point/@{AA,BB,CC,P}],Text[Style["A",20,"Label"],AA+{0,.15}],Text[Style["B",20,"Label"],BB+{0,.15}],Text[Style["C",20,"Label"],CC+{0,.15}],Text[Style["P",20,"Label"],P+{0,.15}],Text[Style["Q",20,"Label"],Q+{0,.15}],Style[Line[{P,Q}],Red,Thickness[0.01`]],Style[{Line[{P,AA}],Line[{P,BB}],Line[{P,CC}],Line[{Q,AA}],Line[{Q,BB}],Line[{Q,CC}]},Gray,DotDashed,Thickness[0.01`]],Style[Triangle[{AA,BB,CC}],Opacity[.2`],RGBColor[x,y,z],EdgeForm[{Thickness[0.01`],Blue}]]},ImageSize{450,375}]},Alignment{Center,Top},Style["TXM2",30,FontFamily->"Times",Bold],Column[{Row[{Control@{{m,2,Style["m",15]},-5,5,1/6,Appearance->"Labeled"},Control@{{x,1,Style["x",15]},-5,5,1/6,Appearance->"Labeled"}}],Row[{Control@{{n,1,Style["n",15]},-5,5,1/6,Appearance->"Labeled"},Control@{{y,2,Style["y",15]},-5,5,1/6,Appearance->"Labeled"}}],Row[{Control@{{p,1,Style["p",15]},-5,5,1/6,Appearance->"Labeled"},Control@{{z,2/3,Style["z",15]},-5,5,1/6,Appearance->"Labeled"}}],Row[{Control@{{q,2,Style["q",15]},-5,5,1/6,Appearance->"Labeled"}}]}],SaveDefinitions->True
Out[]=
​
TXM2
m
2
x
1
n
1
y
2
p
1
z
2
3
q
2
u=
2
PB
+
2
QC
-
2
PC
-
2
QB
v=
2
PC
+
2
QA
-
2
PA
-
2
QC
w=
2
PA
+
2
QB
-
2
PB
-
2
QA
2
PQ
S
A
2
u
+
S
B
2
v
+
S
C
2
w
4
2
S
4.15654
2.90593
-7.06247
2.
2.


4
.
Related Links
​https://community.wolfram.com/groups/-/m/t/2510942?p_p_auth=JsdU7w9j
5
.
Author information​
Trịnh Xuân Minh