计算“饼图段”面积的边界点 和“子区域”
背景:
我最近正在使用 GDI+ 绘制一个“光盘”,显示 360 度的全面颜色变化。 (我挖了一些HSL到RGB的代码来循环HSL(1,1,1) -> HSL(360,1,1))
关于光盘,我首先使用上面的方法画了一个完整的实心圆,然后中心上的第二个灰色圆圈给出以下
所以这一切都很好..但我意识到 GDI+ 使我们免受通过 FillPie
方法进行的许多棘手的匹配。 此外,FillPie 要求您提供饼图的边界矩形,而不是半径长度。 它还执行完整的段填充,并且不允许您仅指定该段的一部分。
问题:
任何人都可以向我指出一些数学函数的方向,或者对我需要什么论坛来计算面积和面积给出任何解释吗? 给出以下“绿色填充区域”的绘图点:
Point `c` - an x,y co-ordinate
Angle `A` - an angle from horizontal
Angle `B - an angle from horizontal where `B` - `A` == the sweep angle
Length `r` - a distance from `c`
Length `r2` - a distance from `c` where `r2` - `r` == the `height` of the segment to be filled.
数学源的链接很好但我已经快速谷歌& 看看 Wolfram Math 可以找到我正在寻找的东西。 另外,如果有某种方法可以生成可以作为 Point[]
传递给 Graphics.FillPolygon 的边界 (x,y) co-or 序列,那也很酷。
Background:
I was recently playing around with GDI+ to draw a "Disc" displaying a sweeping color change through 360 degrees. (I dug up some HSL to RGB code to loop through HSL(1,1,1) -> HSL(360,1,1))
Regarding the disc, I first drew a full solid circle using the above, and then a second circle in Grey over the center to give the following
So this is all fine... but I realised that GDI+ is insulating us from a lot of the tricky match that's going on here by way of the FillPie
method. Also, FillPie
requires you to supply a bounding rectangle for the pie as opposed to a Radius Length. It also does a full segment fill and doesnt allow you to specify a part of that segment only.
Question:
Can anyone point me in the direction of some Math functions or give any explanation on what forumla I would need to calculate the area & plot points of the following "Green Filled Area" given:
Point `c` - an x,y co-ordinate
Angle `A` - an angle from horizontal
Angle `B - an angle from horizontal where `B` - `A` == the sweep angle
Length `r` - a distance from `c`
Length `r2` - a distance from `c` where `r2` - `r` == the `height` of the segment to be filled.
Links to Math sources are fine but I've had a quick google & look at Wolfram Math and could find what I was looking for. Also, if there was some way to generate a sequence of bounding (x,y) co-or's that could be passed as a Point[]
to Graphics.FillPolygon, that'd be cool too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
该面积是外圆盘部分和内圆盘部分的差。 圆盘部分的面积与扫角成正比:
a
和b
必须以弧度表示。对于
ba = 2*Pi
,area = Pi*(r+r2)^2 - Pi*r^2
是外盘和内盘面积之差。在内/外圆上生成点。
您可以使用其中
t
从a
到b
变化的方式The area is the difference of the outer and inner disc parts. The area of a disc part is proportional to the angle sweep:
a
andb
must be expressed in radians.For
b-a = 2*Pi
,area = Pi*(r+r2)^2 - Pi*r^2
is the difference of the areas of the outer and inner discs.You can generate points on the inner / outer circle using
Where
t
varies froma
tob
.希望这可以帮助。 第二部分提供了计算圆扇形面积的方法
http://www.wikihow.com/Calculate-the-Area-of-a-Circle
Hope this helps. The second part provides a method for calculating the area of a sector of a circle
http://www.wikihow.com/Calculate-the-Area-of-a-Circle
圆弧的面积就是圆弧的角度(以弧度为单位)乘以半径。 所以绿色圆圈的面积显然是:
The area of a segment of a circle is simply the angle of the arc (in radians) times the radius. So the area of the green circle is obviously:
您需要画线(此伪代码):
对于足够小的角度增量和足够小的半径,这应该没问题。
您要寻找的点是每个角度 aa 的 (x1,y1) 和 (x2,y2)
You need to draw lines (this pseudo code):
for a small-enough increment in the angles, and small-enough radii, this should be OK.
The points you're looking for are (x1,y1) and (x2,y2) for each angle aa