Re: Some basic Help
- To: mathgroup@smc.vnet.net
- Subject: [mg12390] Re: [mg12314] Some basic Help
- From: Robert Pratt <rpratt@math.unc.edu>
- Date: Sun, 10 May 1998 02:05:12 -0400
First a method to generate and plot random triangles in the unit square: RandomTriangle[]:=Module[{p1,p2,p3}, {p1,p2,p3}=Table[Random[],{3},{2}]; Print[{"p1 =","p2 =","p3="}//ColumnForm,{p1,p2,p3}//ColumnForm]; Show[Graphics[{Line[{p1,p2,p3,p1}],Text["p1",p1],Text["p2",p2], Text["p3",p3]}], PlotRange->{{0,1},{0,1}},AspectRatio->Automatic,Frame->True];] RandomTriangle[] Now to generate and plot random RIGHT triangles in the unit square, use the following theorem (which no doubt appears in Euclid's Elements): If a triangle T is inscribed in a circle in such a way that one of the legs L of T is a diameter of the circle, then T is a right triangle, and L is the hypotenuse. The proof is pretty straightforward using isosceles triangles, supplementary angles, and the constant angle-sum property of Euclidean triangles. Furthermore, since any three points determine a circle, EVERY right triangle arises uniquely in this way. We will choose two random points p1 and p2, and let p3 be a point randomly chosen on the (unique) circle defined by the property that p1 and p2 are diametrically opposed. If p3 happens to lie outside the unit square, we just randomly choose a different p3. RandomRightTriangle[]:=Module[{p1,p2,p3={2,2},c,r,t}, {p1,p2}=Table[Random[],{2},{2}]; c=(p1+p2)/2; r=Sqrt[(p1-p2).(p1-p2)]/2; While[Not[(0<=p3[[1]]<=1 && 0<=p3[[2]]<=1)], {t=2 Pi Random[], p3=c+r{Cos[t],Sin[t]}}]; Print[{"p1 =","p2 =","p3 ="}//ColumnForm,{p1,p2,p3}//ColumnForm]; Show[Graphics[{Line[{p1,p2,p3,p1}],Text["p1",p1],Text["p2",p2], Text["p3",p3]}], PlotRange->{{0,1},{0,1}},AspectRatio->Automatic,Frame->True];] RandomRightTriangle[] Rob Pratt Department of Mathematics The University of North Carolina at Chapel Hill CB# 3250, 331 Phillips Hall Chapel Hill, NC 27599-3250 rpratt@math.unc.edu http://www.math.unc.edu/Grads/rpratt/ On Thu, 7 May 1998, jason jacobson wrote: > Hello! > > Does anyone have any suggestions for generating Random RIGHT triangles. > I found a way to generate random triangles through the PLOT command, > but do not know how to generate right ones. > > Please email me w/ help. Thanks > >