c# - 如何用距中心的距离值来处理二维数组?
问题描述
我从学校知道这个公式可以知道一个点是否在二维数组的半径之外,但我不知道如何修改它以填充数组而不是检查距离值(圆形不是平方)到中心, 或多或少像下面的数组
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
解决方案
推荐阅读
- node.js - 无法从节点 js 中的异步发送响应
- dictionary - 如何将整个嵌套结构转换为地图
- node.js - 猫鼬查询检查数组是否包含猫鼬查询中的元素
- javascript - 当我的键是随机的时,如何按值组织 JSON?
- c# - 使用值对象创建聚合
- php - 为什么我收到此错误?“未定义变量:表”,“C:\....数据库\迁移\2020_08_25_082835_create_featured_products_table.php”,[])
- python - 从每一列中删除 NaN 并使用 python pandas/numpy 重新排列它
- assembly - 如何组装 RISC-V 指令集的 RVC(压缩指令)扩展?
- python - 集群标签比较 - 标签匹配
- oracle - 时间戳总和