I'm creating android app, I'm going to build dialer, and spin the dialer. If the arrow intersect with the specific layer, it will pop out the result. I'm using sliced dialer into many layers, each layer represent different data and I have one arrow, pointing to the layer. This arrow is going to intersect with either one layer. I want to make the arrow calculate the percentage of overlapping among the layers so that the arrow can determine which it's pointing to. This is just my whole picture of doing it. Any suggestions or improvements ? BTW, how to calculate images overlapping percentage ?
Asked
Active
Viewed 325 times
0
-
what images are you talking about? – pskink Jul 25 '14 at 04:21
-
@pskink The A to P layers and the red arrow. I want to calculate the red arrow overlapping percentage with the layers. The highest overlapping percentage between red arrow and layer will result which red arrow is pointing to. – user3138965 Jul 25 '14 at 04:26
-
but what layers are you referring to? are you using LayerDrawable? o r are you using a custom View? how do you draw the whole view? your question is verry unclear... what exactly do you want to achieve? – pskink Jul 25 '14 at 04:35
-
Looks similar to http://stackoverflow.com/questions/11753730/rotating-speedometer-needle-gauge-around-its-center-as-the-speed-changes/ – JiTHiN Jul 25 '14 at 04:59
1 Answers
1
I'd recommend keeping track the angle of the arrow and using that to calculate which section it is on. You should have the angle since you probably need it to draw the arrow. With the angle, it is quite simple to calculate which section it is on.
The code would look something like this:
public static final int TOTAL_DEGREES = 360;
public int calculateSelectedSection(float degrees, int numSections) {
return (int) (degrees / TOTAL_DEGREES * numSections);
}

gabrielwong
- 301
- 1
- 6