1

I want to find vertices (has integer coordinates) of the triangle $ABC$ with the centorid is $G(1,1)$ and orthocenter is $H(3,3)$. I tried

a = {x1, y1};
g = {1, 1};
h = {3, 3};
b = {x2, y2};
c = {x3, y3};
Solve[{x1 + x2 + x3 == 3 g[[1]], 
  y1 + y2 + y3 == 3 g[[2]], (h - a).(c - b) == 0, (h - b).(c - a) == 
   0, -20 < x1 < 20, -20 < y1 < 20, -20 < x2 < 20, -20 < y2 < 20, 
  x2*y3 - x1*y3 + x1*y2 - y2*x3 + y1*x3 - y1*x2 != 0}, {x1, y1, x2, 
  y2, x3, y3}, Integers]

enter image description here

There are some duplicate triangles. How to delete this duplicate triangles?

minthao_2011
  • 4,503
  • 3
  • 31
  • 46
  • You can Thread[a + b + c == 3 g] to relate the components of two separate lists more elegantly, not that this answer your question. Also Thread[-20 < a < 20], and Flatten[{a, b, c}]. – BoLe Apr 23 '13 at 09:03

1 Answers1

4

I am not certain I understand, but starting with sols = Solve[ . . . ] does this help?:

{{x1, y1}, {x2, y2}, {x3, y3}} /. sols;

Union[Sort /@ %]
{{{-17, 7}, {7, -17}, {13, 13}},
 {{-11, 3}, {7, -9}, {7, 9}},
 {{-9, -3}, {3, 9}, {9, -3}},
 {{-9, 7}, {3, -11}, {9, 7}},
 {{-5, -5}, {1, 7}, {7, 1}},
 {{-3, -9}, {-3, 9}, {9, 3}},
 {{-3, 3}, {3, -3}, {3, 3}}}
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • This is a great little solution! And calls attention to a useful case I'd never thought of, that Union[myList] returns myList as a "set". – billc Aug 01 '15 at 04:58
  • @billc I am glad you found it of value. :-) – Mr.Wizard Aug 01 '15 at 05:36
  • I was looking for away to improve the output of sols = Solve[Sin[x] == Cos[2 x] && 0 < x < 2 \[Pi], x]. You can simple add // Union !! – billc Aug 01 '15 at 05:38