Convert column vector to list:
In[]:=
cvToL:=
{a,b}
a_ |
b_ |
In[]:=
p=
,
,
/.cvToL;
0 |
2 |
4 |
-1 |
-2 |
-1.5 |
Plus or minus according to orientation of triangle (CCW or CW):
In[]:=
orient[a_,b_,c_]:=SignDet
a〚1〛 | b〚1〛 | c〚1〛 |
a〚2〛 | b〚2〛 | c〚2〛 |
1 | 1 | 1 |
In[]:=
orient[p〚1〛,p〚2〛,p〚3〛]
Out[]=
1
Equation for line through point a and b:
In[]:=
line[a_,b_]:=Det
0
a〚1〛 | b〚1〛 | x |
a〚2〛 | b〚2〛 | y |
1 | 1 | 1 |
Equation for line inset by i from the line through point a and b:
In[]:=
insetL[a_,b_,i_]:=Det
iNorm[a-b]
a〚1〛 | b〚1〛 | x |
a〚2〛 | b〚2〛 | y |
1 | 1 | 1 |
In[]:=
Solve[insetL[p〚1〛,p〚2〛]&&insetL[p〚2〛,p〚3〛],{x,y}]
Out[]=
Solve[insetL[{0,2},{4,-1}]&&insetL[{4,-1},{-2,-1.5}],{x,y}]
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]
In[]:=
With[{inset=0.2,m1=mid[p〚1〛,p〚2〛],m2=mid[p〚2〛,p〚3〛],m3=mid[p〚3〛,p〚1〛],s=orient[p〚1〛,p〚2〛,p〚3〛]},Show[Graphics[{PointSize[0.02],Point[p,VertexColors{Red,Yellow,Blue}],Point[{0,0}],Point[{x,y}]/.Solve[insetL[p〚1〛,p〚2〛,s*inset]&&insetL[p〚2〛,p〚3〛,s*inset],{x,y}],Point[{x,y}]/.Solve[insetL[p〚2〛,p〚3〛,s*inset]&&insetL[p〚3〛,p〚1〛,s*inset],{x,y}],Point[{x,y}]/.Solve[insetL[p〚3〛,p〚1〛,s*inset]&&insetL[p〚1〛,p〚2〛,s*inset],{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[{insetL[p〚1〛,p〚2〛,s*inset],insetL[p〚2〛,p〚3〛,s*inset],insetL[p〚3〛,p〚1〛,s*inset]}//Evaluate,{x,-4,4},{y,-3,3},ContourStyle{LightRed,LightYellow,LightBlue}],BoxRatios{1,1},FrameTrue]]
Out[]=
