Question: VBA CODE Write a VBA (Visual Basic for Applications) sub program to verify whether a point (with x and y coordinates) lies within a specified

VBA CODE Write a VBA (Visual Basic for Applications) sub program to verify whether a point (with x and y coordinates) lies within a specified irregular polygon.

- The irregular polygon must be described by a series of coordinates connected by straight lines.

- Make sure the point declared in such a way that the lines connecting two adjacent points do not intersect.

Specific Requirements: The program should allow the user to:

Define a polygon with a maximum of 8 edges. (Use the inputbox function to prompt the user to insert number of edges as well as the coordinates of the polygon.)

Define a maximum of 20 points to evaluate whether each point lies inside or outside the area.

VBA CODE Write a VBA (Visual Basic for Applications) sub program toverify whether a point (with x and y coordinates) lies within aspecified irregular polygon. - The irregular polygon must be described by aI know there are many ways to write code to achieve the same result, but keep the coding as simplistic if possible! Thank you :)

Write a VBA sub program to verify whether a point (with x and y coordinates) lies within a specified irregular polygon. Here is the basic principle and process that you need to understand to classify whether a point lies within the irregular polygon or not. 1. 1. The irregular polygon that you consider must be described by a series of coordinates connected by straight lines. In the example illustrated in the figure below, an irregular polygon is drawn considering the following set of points X Co-ordinate Y Co-ordinate 27 18 9 28 11 31 44 27 28 20 36 30.5 30.5 22 27 18 (Note: As seen from the figure below, each consecutive pair of coordinates form a line on the chart.) 2. It is essential that the polygon is a closed area for the procedure to work properly. (This condition has to be checked in the subprogram) 3. Make sure the points declared in such a way that the lines connecting two adjacent points do not intersect. Hints: 1. Area is enclosed if the last point and first point are equal 2. If the polygon considered has eight edges, there will be 9 points that user has to provide as input. Define the number of edges for irregular polygon first and then use this input further in the program 2. Principle: The standard method to determine whether a point lies inside or outside the figure is to draw a "ray" from the point extending out to infinity. If the ray crosses the boundary line(s of the figure an odd number of times, the point lies inside the figure. In the example illustrated in the figure below, when a "ray" is drawn vertically upwards from the orange point, the ray crosses the boundary lines an odd number of times while the ray drawn from the grey point crosses the boundary lines an even number of times 3. A general algorithm (procedure/pseudo code to test whether a point xA,yA lies within the figure is as follows For each Nedges that make up the figure: 1) If the x coordinates of both ends of the edge lie to the left of xA, then go to the next edge Write a VBA sub program to verify whether a point (with x and y coordinates) lies within a specified irregular polygon. Here is the basic principle and process that you need to understand to classify whether a point lies within the irregular polygon or not. 1. 1. The irregular polygon that you consider must be described by a series of coordinates connected by straight lines. In the example illustrated in the figure below, an irregular polygon is drawn considering the following set of points X Co-ordinate Y Co-ordinate 27 18 9 28 11 31 44 27 28 20 36 30.5 30.5 22 27 18 (Note: As seen from the figure below, each consecutive pair of coordinates form a line on the chart.) 2. It is essential that the polygon is a closed area for the procedure to work properly. (This condition has to be checked in the subprogram) 3. Make sure the points declared in such a way that the lines connecting two adjacent points do not intersect. Hints: 1. Area is enclosed if the last point and first point are equal 2. If the polygon considered has eight edges, there will be 9 points that user has to provide as input. Define the number of edges for irregular polygon first and then use this input further in the program 2. Principle: The standard method to determine whether a point lies inside or outside the figure is to draw a "ray" from the point extending out to infinity. If the ray crosses the boundary line(s of the figure an odd number of times, the point lies inside the figure. In the example illustrated in the figure below, when a "ray" is drawn vertically upwards from the orange point, the ray crosses the boundary lines an odd number of times while the ray drawn from the grey point crosses the boundary lines an even number of times 3. A general algorithm (procedure/pseudo code to test whether a point xA,yA lies within the figure is as follows For each Nedges that make up the figure: 1) If the x coordinates of both ends of the edge lie to the left of xA, then go to the next edge

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!