You could look into using an array - however I agree with the comments by wildbill about sticking to the multiple if statements until you're comfortable with them.
However, should you want to investigate further, here is a simple program showing one way to do it. It is written in C, but works as a C++ program. To do it in C++ would (or rather could!) involve use of classes, and would be relatively trivial to write once you have some more experience. It has been written to compile on a desktop system, but you can extract the relevant language constructs and use them in the arduino.
The other tip I would suggest - if I understand your application correctly, overlapping areas would be an error. If that is the case, I would add a check in the setup() routine to walk through the array and confirm the lack of overlap.
Finally, you pointed out in your original message that you want to drigger the actions once for each revolution for each area the pointer comes across. If that is the case, then you could setup a flag for each area, and check it when an area is found. If the flag is set, do nothing, otherwise set the flag and carry out the tasks. As the cylinder passes through the zero point, reset all the flags (this assumes no area crosses the zero point).
// Actually written out as a C program, but of course works
// as c++. compiles using:
// g++ -o areatest area.cpp
// (assuming this is saved as area.cpp)
#include <stdio.h>
// Structures for point and area
// This is a way to collect the positions of the two
// encoders for a point
struct POINT {
int a;
int b;
};
// An AREA is defined by the coordinates of the top left
// and bottom right corners, and is given an id
struct AREA {
int id;
POINT topLeft;
POINT bottomRight;
};
// Declaration of the function which will identify
// which zone includes the point being checked.
int inZone(POINT);
// This is a static array of areas. There is
// no check to see if the areas overlap
AREA zones[] = {
// id , topLeft, bottomRight
{1, {2,3}, {4,5}},
{2, {5,5}, {10,10}},
{3, {5,10}, {10,15}},
{4, {5,15}, {10,10}},
{5, {10,5}, {15,10}},
{6, {20,20},{25,25}}
};
// Test routine in main to show how the function works
int main(int argc, char *argv[])
{
POINT myPoint = {6,8}; // Point to check
int myZone; // save the zone returned
myZone = inZone(myPoint); // Get the zone
if (myZone > 0) // If the zone isn't found it returns -1
printf("myPoint is in zone %d\n", myZone);
else
printf("myPoint is not in any of the zones!\n");
return 0;
}
int inZone(POINT point)
{
// Step through the zones[] array. Note - if there
// are overlapping zones, the first one found will
// be returned
for (int i = 0; i <= sizeof(zones); i++) {
if ((point.a > zones[i].topLeft.a) &&
(point.b > zones[i].topLeft.b) &&
(point.a <= zones[i].bottomRight.a) &&
(point.b <= zones[i].bottomRight.b))
return(zones[i].id);
}
return(-1); // not in any of the areas in zones[]
}