首页 > 解决方案 > 如何用距中心的距离值来处理二维数组?

问题描述

我从学校知道这个公式可以知道一个点是否在二维数组的半径之外,但我不知道如何修改它以填充数组而不是检查距离值(圆形不是平方)到中心, 或多或少像下面的数组

if ((z * z + x * x) > (radius * radius))
                {
                    array[i] = value;
                }

this is the array I want to get, but I'm not sure if tis is the formula to start with

5 - 5 - 4 - 4 - 4 - 4 - 5 - 5
5 - 4 - 3 - 3 - 3 - 3 - 4 - 5
4 - 3 - 3 - 2 - 2 - 3 - 3 - 4
4 - 3 - 2 - 1 - 1 - 2 - 3 - 4
4 - 3 - 2 - 1 - 1 - 2 - 3 - 4
4 - 3 - 3 - 2 - 2 - 3 - 3 - 4
5 - 4 - 3 - 3 - 3 - 3 - 4 - 5
5 - 5 - 4 - 4 - 4 - 4 - 5 - 5

标签: c#arraystrigonometry

解决方案


推荐阅读