Imagine a circle. Imagine a pie. Imagine trying to return a bool that determines whether the provided parameters of X, Y are contained within one of those pie pieces.
想象一个圆。想象一个馅饼。假设尝试返回一个bool,该bool决定是否包含X的提供参数,Y是否包含在其中一个饼块中。
What I know about the arc:
我所知道的弧:
I have the CenterX, CenterY, Radius, StartingAngle, EndingAngle, StartingPoint (point on circumference), EndingPoint (point on circumference).
我有中心,CenterY, Radius, StartingAngle, EndingAngle, StartingPoint (point on周长),EndingPoint (point on周长)。
Given a coordinate of X,Y, I'd like to determine if this coordinate is contained anywhere within the pie slide.
给定一个X,Y的坐标,我想确定这个坐标是否包含在饼图滑动的任何地方。
2 个解决方案
#1
31
Check:
检查:
- The angle from the centerX,centerY through X,Y should be between start&endangle.
- 从中心到中心的角度,通过X,Y的角度应该是在开始和结束之间。
- The distance from centerX,centerY to X,Y should be less then the Radius
- 从中心到X的距离,Y应该小于半径。
And you'll have your answer.
你会得到答案的。
#2
14
Convert X,Y to polar coordinates using this:
把X,Y转换成极坐标,用这个:
Angle = arctan(y/x); Radius = sqrt(x * x + y * y);
=反正切角(y / x);半径=√(x * x + y * y)
Then Angle must be between StartingAngle and EndingAngle, and Radius between 0 and your Radius.
然后角必须在开始角和结束角之间,半径在0和半径之间。
#1
31
Check:
检查:
- The angle from the centerX,centerY through X,Y should be between start&endangle.
- 从中心到中心的角度,通过X,Y的角度应该是在开始和结束之间。
- The distance from centerX,centerY to X,Y should be less then the Radius
- 从中心到X的距离,Y应该小于半径。
And you'll have your answer.
你会得到答案的。
#2
14
Convert X,Y to polar coordinates using this:
把X,Y转换成极坐标,用这个:
Angle = arctan(y/x); Radius = sqrt(x * x + y * y);
=反正切角(y / x);半径=√(x * x + y * y)
Then Angle must be between StartingAngle and EndingAngle, and Radius between 0 and your Radius.
然后角必须在开始角和结束角之间,半径在0和半径之间。