0
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ 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}]. $\endgroup$ – BoLe Apr 23 '13 at 9:03
3
$\begingroup$

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}}}
$\endgroup$
  • $\begingroup$ 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". $\endgroup$ – billc Aug 1 '15 at 4:58
  • $\begingroup$ @billc I am glad you found it of value. :-) $\endgroup$ – Mr.Wizard Aug 1 '15 at 5:36
  • $\begingroup$ 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 !! $\endgroup$ – billc Aug 1 '15 at 5:38

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.