Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ios中绘制三角形上的小圆图像_Ios_Image_Drawing_Geometry - Fatal编程技术网

在ios中绘制三角形上的小圆图像

在ios中绘制三角形上的小圆图像,ios,image,drawing,geometry,Ios,Image,Drawing,Geometry,我有一个三角形,我将在上面画一个空心的圆圈来创造一个花环,我们可以称之为念珠。 每个圆都是一个图像,我需要把它放在特定位置的三角形上 伙计们,让我知道我将如何使之成为可能?如果你们需要更多的澄清,让我知道 提前谢谢 像这样: 目标C: UIBezierPath* polygonPath = UIBezierPath.bezierPath; [polygonPath moveToPoint: CGPointMake(80.5, 33)]; [polygonPath addLineToPoint:

我有一个三角形,我将在上面画一个空心的圆圈来创造一个花环,我们可以称之为念珠。 每个圆都是一个图像,我需要把它放在特定位置的三角形上

伙计们,让我知道我将如何使之成为可能?如果你们需要更多的澄清,让我知道

提前谢谢

像这样:

目标C:

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(80.5, 33)];
[polygonPath addLineToPoint: CGPointMake(119.9, 101.25)];
[polygonPath addLineToPoint: CGPointMake(41.1, 101.25)];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];

UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(58, 56, 45, 45)];
[UIColor.redColor setFill];
[ovalPath fill];
UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(40, 18, 91, 91)];
[UIColor.redColor setFill];
[ovalPath fill];

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(85.5, 18)];
[polygonPath addLineToPoint: CGPointMake(124.9, 86.25)];
[polygonPath addLineToPoint: CGPointMake(46.1, 86.25)];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];
CGContextRef context = UIGraphicsGetCurrentContext();

CGRect frame = CGRectMake(75, 28, 76, 66);
CGContextSaveGState(context);
CGContextBeginTransparencyLayer(context, NULL);
CGContextClipToRect(context, frame);

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 1.48684 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.42424 * CGRectGetHeight(frame))];
[polygonPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 1.98823 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.42424 * CGRectGetHeight(frame))];
[polygonPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.98546 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.42424 * CGRectGetHeight(frame))];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];

UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 44) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 44) * 1.00000 + 0.5), 44, 44)];
[UIColor.redColor setFill];
[ovalPath fill];

CGContextEndTransparencyLayer(context);
CGContextRestoreGState(context);
斯威夫特:

var polygonPath = UIBezierPath()
polygonPath.moveToPoint(CGPointMake(80.5, 33))
polygonPath.addLineToPoint(CGPointMake(119.9, 101.25))
polygonPath.addLineToPoint(CGPointMake(41.1, 101.25))
polygonPath.closePath()
UIColor.grayColor().setFill()
polygonPath.fill()

var ovalPath = UIBezierPath(ovalInRect: CGRectMake(58, 56, 45, 45))
UIColor.redColor().setFill()
ovalPath.fill()
两者都产生了这一点:

或者这个:

目标C:

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(80.5, 33)];
[polygonPath addLineToPoint: CGPointMake(119.9, 101.25)];
[polygonPath addLineToPoint: CGPointMake(41.1, 101.25)];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];

UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(58, 56, 45, 45)];
[UIColor.redColor setFill];
[ovalPath fill];
UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(40, 18, 91, 91)];
[UIColor.redColor setFill];
[ovalPath fill];

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(85.5, 18)];
[polygonPath addLineToPoint: CGPointMake(124.9, 86.25)];
[polygonPath addLineToPoint: CGPointMake(46.1, 86.25)];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];
CGContextRef context = UIGraphicsGetCurrentContext();

CGRect frame = CGRectMake(75, 28, 76, 66);
CGContextSaveGState(context);
CGContextBeginTransparencyLayer(context, NULL);
CGContextClipToRect(context, frame);

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 1.48684 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.42424 * CGRectGetHeight(frame))];
[polygonPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 1.98823 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.42424 * CGRectGetHeight(frame))];
[polygonPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.98546 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.42424 * CGRectGetHeight(frame))];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];

UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 44) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 44) * 1.00000 + 0.5), 44, 44)];
[UIColor.redColor setFill];
[ovalPath fill];

CGContextEndTransparencyLayer(context);
CGContextRestoreGState(context);
斯威夫特:

var ovalPath = UIBezierPath(ovalInRect: CGRectMake(40, 18, 91, 91))
UIColor.redColor().setFill()
ovalPath.fill()

var polygonPath = UIBezierPath()
polygonPath.moveToPoint(CGPointMake(85.5, 18))
polygonPath.addLineToPoint(CGPointMake(124.9, 86.25))
polygonPath.addLineToPoint(CGPointMake(46.1, 86.25))
polygonPath.closePath()
UIColor.grayColor().setFill()
polygonPath.fill()
为此:

还有一个框架:

目标C:

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(80.5, 33)];
[polygonPath addLineToPoint: CGPointMake(119.9, 101.25)];
[polygonPath addLineToPoint: CGPointMake(41.1, 101.25)];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];

UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(58, 56, 45, 45)];
[UIColor.redColor setFill];
[ovalPath fill];
UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(40, 18, 91, 91)];
[UIColor.redColor setFill];
[ovalPath fill];

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(85.5, 18)];
[polygonPath addLineToPoint: CGPointMake(124.9, 86.25)];
[polygonPath addLineToPoint: CGPointMake(46.1, 86.25)];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];
CGContextRef context = UIGraphicsGetCurrentContext();

CGRect frame = CGRectMake(75, 28, 76, 66);
CGContextSaveGState(context);
CGContextBeginTransparencyLayer(context, NULL);
CGContextClipToRect(context, frame);

UIBezierPath* polygonPath = UIBezierPath.bezierPath;
[polygonPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 1.48684 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.42424 * CGRectGetHeight(frame))];
[polygonPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 1.98823 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.42424 * CGRectGetHeight(frame))];
[polygonPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.98546 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.42424 * CGRectGetHeight(frame))];
[polygonPath closePath];
[UIColor.grayColor setFill];
[polygonPath fill];

UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 44) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 44) * 1.00000 + 0.5), 44, 44)];
[UIColor.redColor setFill];
[ovalPath fill];

CGContextEndTransparencyLayer(context);
CGContextRestoreGState(context);
斯威夫特:

var ovalPath = UIBezierPath(ovalInRect: CGRectMake(40, 18, 91, 91))
UIColor.redColor().setFill()
ovalPath.fill()

var polygonPath = UIBezierPath()
polygonPath.moveToPoint(CGPointMake(85.5, 18))
polygonPath.addLineToPoint(CGPointMake(124.9, 86.25))
polygonPath.addLineToPoint(CGPointMake(46.1, 86.25))
polygonPath.closePath()
UIColor.grayColor().setFill()
polygonPath.fill()
let context=UIGraphicsGetCurrentContext

let frame = CGRectMake(75, 28, 76, 66)

CGContextSaveGState(context)
CGContextBeginTransparencyLayer(context, nil)

CGContextClipToRect(context, frame)

var polygonPath = UIBezierPath()
polygonPath.moveToPoint(CGPointMake(frame.minX + 1.48684 * frame.width, frame.minY + 0.42424 * frame.height))
polygonPath.addLineToPoint(CGPointMake(frame.minX + 1.98823 * frame.width, frame.minY + 1.42424 * frame.height))
polygonPath.addLineToPoint(CGPointMake(frame.minX + 0.98546 * frame.width, frame.minY + 1.42424 * frame.height))
polygonPath.closePath()
UIColor.grayColor().setFill()
polygonPath.fill()

var ovalPath = UIBezierPath(ovalInRect: CGRectMake(frame.minX + floor((frame.width - 44) * 0.50000 + 0.5), frame.minY + floor((frame.height - 44) * 1.00000 + 0.5), 44, 44))
UIColor.redColor().setFill()
ovalPath.fill()


CGContextEndTransparencyLayer(context)
CGContextRestoreGState(context)
这显然不会在三角形中画出一堆小圆圈,但您没有指定需要画多少个圆圈,因此如果没有这些非常重要的信息,就无法进一步帮助您,但这将给您一个开始

作为参考,这里是您需要访问的地方,以下信息涉及包装问题和数学,特别是三角形内拟合圆圈的包装问题:

然后这个:

等边三角形中的等圆盘密填料R.L.Graham, 卢巴切夫斯基

以前出版的等边圆盘填料 triangle已处理多达21个磁盘。我们使用一个新的离散事件 模拟算法,可为多达34个磁盘生成封装。每人 n在22范围内≤N≤34我们展示了我们认为最密集的东西 n个相等圆盘在等边三角形中的可能堆积。对于 我们还列出了第二个,通常是第三个,有时是第三个 在我们找到的包装中排名第四。在每种情况下 填料的结构意味着最小距离dn 磁盘中心之间是带整数的多项式Pn的根 系数。在大多数情况下,我们不显式地计算Pn,但在所有情况下 在某些情况下,我们计算并报告dn为15位有效十进制数字

等边三角形中的磁盘填料与正方形或三角形中的磁盘填料不同 圆圈中的三角形有无穷多个值 对于n,已知dn的精确值,即当n为 形式Δk:=kk+12。也有人推测dn−1=dn 在这种情况下。根据我们的计算,我们提出了猜想 其他七类无限n的最优填充,即

n=Δ(2k)+1,Δ(2k+1)+1,Δ(k+2)−2,Δ(2k+3)−3,Δ(3k+1)+2,4Δ(k), and 2Δ(k+1)+2Δ(k)−1.
我们还报告了我们发现的其他n值的最佳填料 大于34的这些形式,即n=37,40,42,43,46, 49、56、57、60、63、67、71、79、84、92、93、106、112、121和254, 也适用于n=58、95、108、175、255、256、258和260。我们说 n个磁盘的无限类封装,n=n1,n2,…nk,…,为 紧固,如果[1/dnk+1−1/dnk]在k移动时远离零 无限远。我们猜想我们的一些无限类是 紧,其他的不紧,而且有无限多的紧 上课

这也是:

摘要

本文提出了一种计算方法来寻找好的,推测的 等边三角形的最佳覆盖,最多36个等边三角形 圈子。该算法由两个嵌套层组成:内部层 水平三角形的未覆盖区域通过局部网格最小化 当圆的半径保持不变时,执行优化例程。 在外层调整半径以找到局部最优解 覆盖应用该算法得到了良好的覆盖 重复随机初始配置

确定了覆盖物的结构,并确定了覆盖物的坐标 每个圆都使用数学公式进行高精度计算 由受拉钢筋组成的理想物理结构模型 和无摩擦销接头。最佳发现的等边覆盖 显示最多36个圆的三角形,其中19个为 新的或改进早期出版的封面

最后,这个:

谢谢Larcerax

我需要在三角形的边界上画53个圆,就像念珠一样。每个圆将以特定的距离绘制。 在53个圆圈中,5个在拐角处比其他圆圈大3个,另外2个在两边中间。
三角形会像圆锥一样立着。

你能说说三角形的代码吗