I am working on some gesture recognition for my game and I want to find if a point is inside the triangle created by the user or not. For that I need three vertices. Currently I am using the '$1 recogniser algorithm' which gives me the centroid and the first vertex. So how do I find the other two vertices using the centroid and one vertex?
-
$\begingroup$ You can't. There is not enough information. There are an inifinity of triangles with one given vertex and one given centroid. $\endgroup$– MartiganJan 7, 2015 at 12:08
-
$\begingroup$ Damn! so what should I try to find ? I just have one vertex and a centroid unfortunately. $\endgroup$– Anand DhavleJan 7, 2015 at 12:21
-
$\begingroup$ The question is : do you need to have the precise triangle, or does an approximation suffice? $\endgroup$– MartiganJan 7, 2015 at 12:45
-
$\begingroup$ Approximation will also suffice. $\endgroup$– Anand DhavleJan 7, 2015 at 12:57
1 Answer
Let's suppose that the triangle is equilateral. Then the three sides are equal, as is the distance between the centroid $O$ and each of the vertices. The centroid coordinates are also the mean of the coordinates of the vertices.
This conditions should give you enough equations to compute the other vertices coordinates.
An other solution is to take the centroid as the center of the vector space, and take $OA$ ($A$ being the known vertex) as a basis. The other vertices you get woth a rotation of $\dfrac{2\pi}{3}$.