1
$\begingroup$

I have a list of vertices of triangles

{{2, 3, 5},  {1, -7, -12},  {12, 4, 10}}, { {2, 3, 6},  {1, -7, -11},  {12, 4, 11}}, { {2, 3, 8},  {1, -7, -9},  {12, 4, 13}}, { {2, 3, 9},  {1, -7, -8},  {12, 4, 14}}, { {2, 4, 3},  {1, -6, -14},  {12, 5, 8}}, { {2, 4, 6},  {1, -6, -11},  {12, 5, 11}}, { {2, 4, 8},  {1, -6, -9},  {12, 5, 13}}, { {2, 4, 9},  {1, -6, -8},  {12, 5, 14}}, { {2, 5, 3},  {1, -5, -14},  {12, 6, 8}}, { {2, 5, 4},  {1, -5, -13},  {12, 6, 9}}, { {2, 5, 8},  {1, -5, -9},  {12, 6, 13}}, { {2, 5, 9},  {1, -5, -8},  {12, 6, 14}}, { {2, 6, 3},  {1, -4, -14},  {12, 7, 8}}, { {2, 6, 4},  {1, -4, -13},  {12, 7, 9}}, { {2, 6, 5},  {1, -4, -12},  {12, 7, 10}}, { {2, 6, 8},  {1, -4, -9},  {12, 7, 13}}, { {2, 6, 9},  {1, -4, -8},  {12, 7, 14}}, { {2, 7, 4},  {1, -3, -13},  {12, 8, 9}}, { {2, 7, 5},  {1, -3, -12},  {12, 8, 10}}, { {2, 7, 6},  {1, -3, -11},  {12, 8, 11}}, { {2, 7, 9},  {1, -3, -8},  {12, 8, 14}}, { {2, 8, 5},  {1, -2, -12},  {12, 9, 10}}, { {2, 8, 6},  {1, -2, -11},  {12, 9, 11}}, { {2, 9, 3},  {1, -1, -14},  {12, 10, 8}}, { {2, 9, 6},  {1, -1, -11},  {12, 10, 11}}, { {2, 9, 8},  {1, -1, -9},  {12, 10, 13}}, { {3, 4, 1},  {2, -6, -16},  {13, 5, 6}}, { {3, 4, 6},  {2, -6, -11},  {13, 5, 11}}, { {3, 4, 7},  {2, -6, -10},  {13, 5, 12}}, { {3, 4, 9},  {2, -6, -8},  {13, 5, 14}}, { {3, 5, 4},  {2, -5, -13},  {13, 6, 9}}, { {3, 5, 7},  {2, -5, -10},  {13, 6, 12}}, { {3, 5, 9},  {2, -5, -8},  {13, 6, 14}}, { {3, 6, 4},  {2, -4, -13},  {13, 7, 9}}, { {3, 6, 5},  {2, -4, -12},  {13, 7, 10}}, { {3, 6, 9},  {2, -4, -8},  {13, 7, 14}}, { {3, 7, 1},  {2, -3, -16},  {13, 8, 6}}, { {3, 7, 4},  {2, -3, -13},  {13, 8, 9}}, { {3, 7, 5},  {2, -3, -12},  {13, 8, 10}}, { {3, 7, 6},  {2, -3, -11},  {13, 8, 11}}, { {3, 7, 9},  {2, -3, -8},  {13, 8, 14}}, { {3, 8, 1},  {2, -2, -16},  {13, 9, 6}}, { {3, 8, 5},  {2, -2, -12},  {13, 9, 10}}, { {3, 8, 6},  {2, -2, -11},  {13, 9, 11}}, { {3, 8, 7},  {2, -2, -10},  {13, 9, 12}}, { {3, 9, 1},  {2, -1, -16},  {13, 10, 6}}, { {3, 9, 6},  {2, -1, -11},  {13, 10, 11}}, { {3, 9, 7},  {2, -1, -10},  {13, 10, 12}}, { {4, 1, 5},  {3, -9, -12},  {14, 2, 10}}, { {4, 1, 6},  {3, -9, -11},  {14, 2, 11}}, { {4, 1, 7},  {3, -9, -10},  {14, 2, 12}}, { {4, 5, 2},  {3, -5, -15},  {14, 6, 7}}, { {4, 5, 7},  {3, -5, -10},  {14, 6, 12}}, { {4, 5, 8},  {3, -5, -9},  {14, 6, 13}}, { {4, 6, 5},  {3, -4, -12},  {14, 7, 10}}, { {4, 6, 8},  {3, -4, -9},  {14, 7, 13}}, { {4, 7, 1},  {3, -3, -16},  {14, 8, 6}}, { {4, 7, 5},  {3, -3, -12},  {14, 8, 10}}, { {4, 7, 6},  {3, -3, -11},  {14, 8, 11}}, { {4, 8, 1},  {3, -2, -16},  {14, 9, 6}}, { {4, 8, 2},  {3, -2, -15},  {14, 9, 7}}, { {4, 8, 5},  {3, -2, -12},  {14, 9, 10}}, { {4, 8, 6},  {3, -2, -11},  {14, 9, 11}}, { {4, 8, 7},  {3, -2, -10},  {14, 9, 12}}, { {4, 9, 1},  {3, -1, -16},  {14, 10, 6}}, { {4, 9, 2},  {3, -1, -15},  {14, 10, 7}}, { {4, 9, 6},  {3, -1, -11},  {14, 10, 11}}, { {4, 9, 7},  {3, -1, -10},  {14, 10, 12}}, { {4, 9, 8},  {3, -1, -9},  {14, 10, 13}}, { {5, 1, 3},  {4, -9, -14},  {15, 2, 8}}, { {5, 1, 6},  {4, -9, -11},  {15, 2, 11}}, { {5, 1, 7},  {4, -9, -10},  {15, 2, 12}}, { {5, 1, 9},  {4, -9, -8},  {15, 2, 14}}, { {5, 2, 1},  {4, -8, -16},  {15, 3, 6}}, { {5, 2, 6},  {4, -8, -11},  {15, 3, 11}}, { {5, 2, 7},  {4, -8, -10},  {15, 3, 12}}, { {5, 2, 8},  {4, -8, -9},  {15, 3, 13}}, { {5, 6, 3},  {4, -4, -14},  {15, 7, 8}}, { {5, 6, 8},  {4, -4, -9},  {15, 7, 13}}, { {5, 6, 9},  {4, -4, -8},  {15, 7, 14}}, { {5, 7, 1},  {4, -3, -16},  {15, 8, 6}}, { {5, 7, 6},  {4, -3, -11},  {15, 8, 11}}, { {5, 7, 9},  {4, -3, -8},  {15, 8, 14}}, { {5, 8, 1},  {4, -2, -16},  {15, 9, 6}}, { {5, 8, 2},  {4, -2, -15},  {15, 9, 7}}, { {5, 8, 6},  {4, -2, -11},  {15, 9, 11}}, { {5, 8, 7},  {4, -2, -10},  {15, 9, 12}}, { {5, 9, 1},  {4, -1, -16},  {15, 10, 6}}, { {5, 9, 2},  {4, -1, -15},  {15, 10, 7}}, { {5, 9, 3},  {4, -1, -14},  {15, 10, 8}}, { {5, 9, 6},  {4, -1, -11},  {15, 10, 11}}, { {5, 9, 7},  {4, -1, -10},  {15, 10, 12}}, { {5, 9, 8},  {4, -1, -9},  {15, 10, 13}}, { {6, 1, 3},  {5, -9, -14},  {16, 2, 8}}, { {6, 1, 4},  {5, -9, -13},  {16, 2, 9}}, { {6, 1, 7},  {5, -9, -10},  {16, 2, 12}}, { {6, 1, 9},  {5, -9, -8},  {16, 2, 14}}, { {6, 2, 4},  {5, -8, -13},  {16, 3, 9}}, { {6, 2, 7},  {5, -8, -10},  {16, 3, 12}}, { {6, 2, 8},  {5, -8, -9},  {16, 3, 13}}, { {6, 3, 2},  {5, -7, -15},  {16, 4, 7}}, { {6, 3, 7},  {5, -7, -10},  {16, 4, 12}}, { {6, 3, 8},  {5, -7, -9},  {16, 4, 13}}, { {6, 3, 9},  {5, -7, -8},  {16, 4, 14}}, { {6, 7, 4},  {5, -3, -13},  {16, 8, 9}}, { {6, 7, 9},  {5, -3, -8},  {16, 8, 14}}, { {6, 8, 2},  {5, -2, -15},  {16, 9, 7}}, { {6, 8, 7},  {5, -2, -10},  {16, 9, 12}}, { {6, 9, 2},  {5, -1, -15},  {16, 10, 7}}, { {6, 9, 3},  {5, -1, -14},  {16, 10, 8}}, { {6, 9, 7},  {5, -1, -10},  {16, 10, 12}}, { {6, 9, 8},  {5, -1, -9},  {16, 10, 13}}, { {7, 1, 3},  {6, -9, -14},  {17, 2, 8}}, { {7, 1, 4},  {6, -9, -13},  {17, 2, 9}}, { {7, 1, 5},  {6, -9, -12},  {17, 2, 10}}, { {7, 1, 9},  {6, -9, -8},  {17, 2, 14}}, { {7, 2, 4},  {6, -8, -13},  {17, 3, 9}}, { {7, 2, 5},  {6, -8, -12},  {17, 3, 10}}, { {7, 2, 8},  {6, -8, -9},  {17, 3, 13}}, { {7, 3, 5},  {6, -7, -12},  {17, 4, 10}}, { {7, 3, 8},  {6, -7, -9},  {17, 4, 13}}, { {7, 3, 9},  {6, -7, -8},  {17, 4, 14}}, { {7, 4, 3},  {6, -6, -14},  {17, 5, 8}}, { {7, 4, 8},  {6, -6, -9},  {17, 5, 13}}, { {7, 4, 9},  {6, -6, -8},  {17, 5, 14}}, { {7, 8, 5},  {6, -2, -12},  {17, 9, 10}}, { {7, 9, 3},  {6, -1, -14},  {17, 10, 8}}, { {7, 9, 8},  {6, -1, -9},  {17, 10, 13}}, { {8, 1, 4},  {7, -9, -13},  {18, 2, 9}}, { {8, 1, 5},  {7, -9, -12},  {18, 2, 10}}, { {8, 1, 6},  {7, -9, -11},  {18, 2, 11}}, { {8, 1, 9},  {7, -9, -8},  {18, 2, 14}}, { {8, 2, 1},  {7, -8, -16},  {18, 3, 6}}, { {8, 2, 4},  {7, -8, -13},  {18, 3, 9}}, { {8, 2, 5},  {7, -8, -12},  {18, 3, 10}}, { {8, 2, 6},  {7, -8, -11},  {18, 3, 11}}, { {8, 3, 1},  {7, -7, -16},  {18, 4, 6}}, { {8, 3, 5},  {7, -7, -12},  {18, 4, 10}}, { {8, 3, 6},  {7, -7, -11},  {18, 4, 11}}, { {8, 3, 9},  {7, -7, -8},  {18, 4, 14}}, { {8, 4, 1},  {7, -6, -16},  {18, 5, 6}}, { {8, 4, 6},  {7, -6, -11},  {18, 5, 11}}, { {8, 4, 9},  {7, -6, -8},  {18, 5, 14}}, { {8, 5, 4},  {7, -5, -13},  {18, 6, 9}}, { {8, 5, 9},  {7, -5, -8},  {18, 6, 14}}, { {8, 9, 1},  {7, -1, -16},  {18, 10, 6}}, { {8, 9, 6},  {7, -1, -11},  {18, 10, 11}}, { {9, 1, 5},  {8, -9, -12},  {19, 2, 10}}, { {9, 1, 6},  {8, -9, -11},  {19, 2, 11}}, { {9, 1, 7},  {8, -9, -10},  {19, 2, 12}}, { {9, 2, 1},  {8, -8, -16},  {19, 3, 6}}, { {9, 2, 5},  {8, -8, -12},  {19, 3, 10}}, { {9, 2, 6},  {8, -8, -11},  {19, 3, 11}}, { {9, 2, 7},  {8, -8, -10},  {19, 3, 12}}, { {9, 3, 1},  {8, -7, -16},  {19, 4, 6}}, { {9, 3, 2},  {8, -7, -15},  {19, 4, 7}}, { {9, 3, 5},  {8, -7, -12},  {19, 4, 10}}, { {9, 3, 6},  {8, -7, -11},  {19, 4, 11}}, { {9, 3, 7},  {8, -7, -10},  {19, 4, 12}}, { {9, 4, 1},  {8, -6, -16},  {19, 5, 6}}, { {9, 4, 2},  {8, -6, -15},  {19, 5, 7}}, { {9, 4, 6},  {8, -6, -11},  {19, 5, 11}}, { {9, 4, 7},  {8, -6, -10},  {19, 5, 12}}, { {9, 5, 2},  {8, -5, -15},  {19, 6, 7}}, { {9, 5, 7},  {8, -5, -10},  {19, 6, 12}}, { {9, 6, 5},  {8, -4, -12},  {19, 7, 10}}

Now I want to find coordinates of centroid, orthocenter and center of out circle the list of triangles. With each triangle, e.g with center of out circle, I tried

a = {1, 3, 4};
b = {20, 14, 2};
c = {9, 10, -3};
t = {x, y, z};
u = b - a;
v = c - a;
n = Cross[u, v];
k = t - a;
w = k.n;
Reduce[{SquaredEuclideanDistance[a, t] == 
   SquaredEuclideanDistance[b, t], 
  SquaredEuclideanDistance[a, t] == SquaredEuclideanDistance[c, t], 
  w == 0}, {x, y, z}, Reals]

and with orthocenter, I tried

a = {1, 3, 4};
b = {20, 14, 2};
c = {9, 10, -3};
h = {x1, y1, z1};
u = b - a;
v = c - a;
k = h - a;
n = Cross[u, v];
w = k.n;
Reduce[{(h - a). (c - b) == 0, (h - b).(c - a) == 0, w == 0}, {x1, y1, z1}, Reals]

And with centroid, I tried, (a + b + c)/3.

I want to out put has the form {{1, 3, 4}, {20, 14, 2}, {9, 10, -3}, {coordinates of centroid},{coordinates of orthocenter},{coordinates of center of out circle} }

I saw http://www.mapleprimes.com/questions/203101-How-Can-I-Make-A-Triangle-With-Integer and wrote a program in Maple. I got all results [![enter image description here][1]][1]

$\endgroup$
  • $\begingroup$ Your "list of vertices of triangles" should use braces and not brackets; otherwise, it's not a valid list. $\endgroup$ – J. M. will be back soon Jul 28 '16 at 3:39
  • $\begingroup$ @J.M. Edited now. $\endgroup$ – minhthien_2016 Jul 28 '16 at 3:49
  • $\begingroup$ So, all your triangles are in 3D? $\endgroup$ – J. M. will be back soon Jul 28 '16 at 3:51
  • $\begingroup$ @J.M. Yes. All my triangles are in 3D. $\endgroup$ – minhthien_2016 Jul 28 '16 at 3:53
  • $\begingroup$ By "outcircle", you mean the circumcircle, right? $\endgroup$ – J. M. will be back soon Jul 28 '16 at 4:07
4
$\begingroup$

I am certain there are better ways. In the following the black point is the orthocentre, the red point is the centroid and the green point the circumcentre.

oc[a_, b_, c_] := 
 Module[{pt = {a, b, c}, s1 = b - a, s2 = c - b, s3 = a - c, pr, 
   lines},
  pr = MapThread[#1 + 
      Norm[#2[[3]]] Cos[
        VectorAngle[#2[[1]], -#2[[3]]]] Normalize[#2[[1]]] &, {{a, b, 
      c}, Table[RotateLeft[{s1, s2, s3}, j], {j, 0, 2}]}];
  lines = 
   MapThread[InfiniteLine[{#1, #2}] &, {pr, RotateRight[pt, 1]}];
  {lines, RegionIntersection[lines[[{1, 2}]]]}
  ]
cc[a_, b_, c_] := 
 Module[{pt = {a, b, c}, s1 = b - a, s2 = c - b, s3 = c - a, nu, de},
  nu = (s3.s3) Cross[Cross[s1, s3], s1] + (s1.s1) Cross[s3, 
      Cross[s1, s3]];
  de = Cross[s1, s3];
  a + nu/(2 de.de)
  ]
cn[a_, b_, c_] := Module[{pt = {a, b, c}, bis, lines},
  bis = (#1 + #2)/2 & @@@ Partition[pt, 2, 1, 1];
  lines = MapThread[Line[{#1, #2}] &, {bis, RotateRight[pt]}];
  {lines, RegionIntersection[lines[[{1, 2}]]]}
  ]
circle[a_, b_, c_] := Module[{pt = {a, b, c}, ccn = cc[a, b, c], i, j},
  i = a - ccn;
  j = Normalize@Cross[Cross[i, b - ccn], i];
  ParametricPlot3D[
   Evaluate[ccn + Cos[t] i + Sqrt[i.i] Sin[t] j], {t, 0, 2 Pi}]]

Visualizing:

vis[a_, b_, c_] := 
 Module[{ort = oc[a, b, c], p3 = Point[cc[a, b, c]], 
   cnt = cn[a, b, c], l1, l2, p1, p2, circ = circle[a, b, c]},
  {l1, p1} = ort;
  {l2, p2} = cnt;
  Show[Graphics3D[{Polygon[{a, b, c}], Black , l1, PointSize[0.04], 
     p1, Red, l2, p2, Green, p3, Purple, Thick, 
     Line[{p1[[1]], p2[[1, 1]], p3[[1]]}]}], circ]]

Examples:

DynamicModule[{pts = RandomReal[1, {3, 3}]}, 
 Dynamic[Column[{vis @@ pts, 
    Button["Random triangle", pts = RandomReal[1, {3, 3}]]}, 
   Frame -> True]]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.