I have a rectangle which has known width and height.Now devide rectangle diagonally to form four triangles. Now suppose have a point p(m,n) and i have to decide that the point lies in which triangle out of four triangles.
Please suggest me some good algo.
I have a rectangle which has known width and height.Now devide rectangle diagonally to
Share
Interesting question. I think this algorithm should do it, but I haven’t tried it out yet. Assuming that the rectangle is AxB and the point p(m,n).
The variable section should then be a value between 0 and 3, depending where the point resides. The sections are called:
If you wish to name the sections another way feel free to tweak the algo.