Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi, I want to split hexagon into triangles and get the coordinates for the each of treangle point. How i want to split hexagon, you can see in this picture.

I have class triangle and class point
C#
class Triangle
{
    public Point A { get; set; }
    public Point B { get; set; }
    public Point C { get; set; }
}

class Point
{
    public double x { get; set; }
    public double y { get; set; }
}


On the list of triangles i want to add each triangle (whith coordinates) which is in hexagon. Does anyone have any idea?

Thanks!
Posted
Updated 14-Mar-15 16:21pm
v2
Comments
Sergey Alexandrovich Kryukov 14-Mar-15 22:20pm    
What do you mean by "does anyone"? This is a trivial problem, well too many people can solve it.
What have you tried so far?
—SA

Google for "C# Triangle Mesh algorithms" and you'll come up with all kinds of examples to do it.
 
Share this answer
 
If point(0) is at (x,y)
then it forms a triangle with points
(x,y) , (x, y+n) , (x + SQRT(n2 - (n/2)2) , y + (n/2))

where n is the length of side of the triangle - which is N / 3 where N is the hexagon side length.

now you have the coordinates of triangle (0,1,5) every other triangle can be calculated trivially using simple addition.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900