【发布时间】:2011-10-10 12:28:04
【问题描述】:
iPhone SDK 和 Objective-C
目标:
我正在尝试计算 2 个圆的“x”和“y”坐标。我有内圆尺寸,并想计算较大外圆圆周的“x”和“y”坐标与沿大圆边缘的相同宽度(距离)与内圆匹配。 .
最后,我只需要弄清楚大圆圈边缘的 x/y 点是什么。使其与内部较小的圆圈匹配。如果内圈的宽度为 10 高,我需要知道 x/y 点以使其对较大的圆圈高 10。制作一个可以延伸的矩形。垂直线。
示例:
我正在使用以下方法计算内圆弧的前 2 组 x/y 以绘制点:
- (CGPoint)coordinatePoints:(CGFloat)radius angleDegrees:(CGFloat)degrees xAxis:(CGFloat)x yAxis:(CGFloat)y {
CGFloat pointX = (CGFloat) ((radius * cos((degrees * M_PI) / 180.0f)) + x);
CGFloat pointY = (CGFloat) ((radius * sin((degrees * M_PI) / 180.0f)) + y);
CGPoint points = CGPointMake(pointX, pointY);
return points;
}
我称它为内圈的前 2 个位置。我需要弄清楚如何让它在外圈也有距离。
CGPoint innerPoints1 = [self coordinatePoints:innerRadius angleDegrees:startingPoint xAxis:x yAxis:y];
CGPoint innerPoints2 = [self coordinatePoints:innerRadius angleDegrees:endingPoint xAxis:x yAxis:y];
如果内圆半径为 200,外圆半径为 500,我希望绘制点时从内圆到较大外圆的厚度仍然相同。
// I have these calculated.
CGContextMoveToPoint(context, innerPoints1.x, innerPoints1.y);
CGContextAddLineToPoint(context, innerPoints2.x, innerPoints2.y);
// I need to find the solution for making innerPoints3 and innerPoints4 correctly.
CGContextAddLineToPoint(context, innerPoints3.x, innerPoints3.y);
CGContextAddLineToPoint(context, innerPoints4.x, innerPoints4.y);
我有间隔 x/y 点的内圆线的坐标。我需要找到正确的方法来为较大的圆圈位置绘制相同的宽度。圆的大小总是会改变。线条的长度将是动态的。当我试图创建一个多边形时,我需要为每个段在较大的圆圈上找到 2 个坐标。
我们将不胜感激。
Information graphics: a comprehensive illustrated reference 第 74 页:在“圆形柱形图”部分,我的最终目标是能够产生与 3 张图像中显示的结果相同的结果。
【问题讨论】:
-
请重申你的“目标”。目前尚不清楚您的意思。当提到你的圆的 x 和 y 坐标时,你是指中心还是边缘上的点?你讲的是“宽度(距离)”,但你没有说之间的距离是什么。也许一张简单的图画会有所帮助。请通过编辑您的问题进行澄清。
-
@Mundi 我已经更新了目标以进一步解释。
-
对不起,我还是不明白。可以上传草图吗?
-
@vikingosegundo 我已经更新为包含一张图片。
标签: iphone objective-c cocoa-touch trigonometry