Convert column vector to list:
In[]:=
cvToL:=
{a,b}
a_ |
b_ |
In[]:=
p=
,
,
/.cvToL;
0 |
2 |
-2 |
-1.5 |
4 |
-1 |
In[]:=
line[a_,b_]:=Det
0
a〚1〛 | b〚1〛 | x |
a〚2〛 | b〚2〛 | y |
1 | 1 | 1 |
Midpoint:
In[]:=
mid[a_,b_]:=
a+b
2
Unit normal to a line through points a and b:
In[]:=
perp[a_,b_]:=Normalize
.(b-a)
0 | -1 |
1 | 0 |
Distance from origin of line through a and b;
dist[a_,b_]:=
Det[{a,b}]
Norm[a-b]
With[{inset=0.2,m1=mid[p〚1〛,p〚2〛],m2=mid[p〚2〛,p〚3〛],m3=mid[p〚3〛,p〚1〛]},Show[Graphics[{(*EdgeForm[{Thick,Red}],FaceForm[None],Polygon[p],*)PointSize[0.02],Point[p,VertexColors{Red,Yellow,Blue}],Point[{0,0}],(*Point[{x,y}]/.Solve[line[p〚1〛,p〚2〛]&&line[p〚2〛,p〚3〛],{x,y}],*)Red,Arrow[{m1,m1+perp[p〚1〛,p〚2〛]}],Yellow,Arrow[{m2,m2+perp[p〚2〛,p〚3〛]}],Blue,Arrow[{m3,m3+perp[p〚3〛,p〚1〛]}]}],ContourPlot[{line[p〚1〛,p〚2〛],line[p〚2〛,p〚3〛],line[p〚3〛,p〚1〛]}//Evaluate,{x,-4,4},{y,-3,3},ContourStyle{Red,Yellow,Blue}],ContourPlot[{line[p〚1〛,p〚2〛]/.line[p〚1〛,p〚2〛]〚2〛line[p〚1〛,p〚2〛]〚2〛+inset*Norm[p〚1〛-p〚2〛],line[p〚2〛,p〚3〛]/.line[p〚2〛,p〚3〛]〚2〛line[p〚2〛,p〚3〛]〚2〛+inset*Norm[p〚2〛-p〚3〛],line[p〚3〛,p〚1〛]/.line[p〚3〛,p〚1〛]〚2〛line[p〚2〛,p〚1〛]〚2〛+inset*Norm[p〚3〛-p〚1〛]}//Evaluate,{x,-4,4},{y,-3,3},ContourStyle{LightRed,LightYellow,LightBlue}],BoxRatios{1,1},FrameTrue]]
Out[]=