如何获得六边形三角形的坐标? [英] How to get coordinates of triangles in hexagon?

查看:117
本文介绍了如何获得六边形三角形的坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将六边形分成三角形,并获得每个三角形点的坐标。我想如何拆分六边形,你可以在这个图片中看到。



我有三角级和班级点数

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

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; }
}





在三角形列表中,我想添加每个三角形(whith coordinates),这是在六边形。有没有人有任何想法?



谢谢!



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

Thanks!

推荐答案

谷歌的C#Triangle网格算法和你会想出各种各样的例子。
Google for "C# Triangle Mesh algorithms" and you'll come up with all kinds of examples to do it.


如果point(0)在(x,y)

那么它形成一个三角形带点

(x,y),(x,y + n),(x + SQRT(n 2 - (n / 2) 2 ),y +(n / 2))



其中n是三角形边长 - 即N / 3,其中N是六边形长度。



现在你有三角形坐标(0,1,5)每隔一个三角形可以用简单的加法来计算。
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.


这篇关于如何获得六边形三角形的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆