【C#】由内到外螺旋旋转制作蜂巢

由内到外螺旋旋转制作蜂巢

  这几天需要用蜂巢形状,网上找了几个生成正六边形的代码感觉都不是我想要的,基本上都由六边形的一个顶点开始计算下个顶点的位置,但是这样得到的正六边形不是很正,不是我想要的,于是就自己写了一个。

正六边形

如上图,假设正六边形的边长为1,坐标原点O为正六边形ABCDEF内切圆的圆心,通过运算可以得到正六边形六个顶点的坐标,并且也能得到环绕在这个正六边形周围的正六边形内切圆圆心的坐标,通过这些坐标为以后无限递归提供了可行性。

这些点的坐标保存在一个公共类里,当做以后生产正六边形的系数。

    public static class Common
    {
        public static double SqrtMod = Math.Sqrt(3) / 2;
        public static Point Mod_A = new Point(-1, 0);
        public static Point Mod_B = new Point(-0.5, SqrtMod);
        public static Point Mod_C = new Point(0.5, SqrtMod);
        public static Point Mod_D = new Point(1, 0);
        public static Point Mod_E = new Point(0.5, -SqrtMod);
        public static Point Mod_F = new Point(-0.5, -SqrtMod);

        public static Point Mod_A1 = new Point(-1.5, -SqrtMod);
	public static Point Mod_B1 = new Point(-1.5, SqrtMod);
        public static Point Mod_C1 = new Point(0, 2 * SqrtMod);
        public static Point Mod_D1 = new Point(1.5, SqrtMod);
	public static Point Mod_E1 = new Point(1.5, -SqrtMod);
        public static Point Mod_F1 = new Point(0, -2 * SqrtMod);
        
	//保存各个正六边形内切圆圆点坐标
        public static List<Point> HexagonIndex = new List<Point> { };
    }

建立一个正六边形类,具体如下:
    public class Hexagon
    {
        #region points
        //正六边定点
        private Point A { get; set; }
        private Point B { get; set;
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

叫我三三

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值