I'm trying to make an algorithm in pseudocode that allows one to select points on a map(at least two(which would make a rectangle)), and then create a closed shape out of the points. After the shape is made, I need to be able to record the parts of the map within the shape so I can be able to tell if a point will be within the shape or not. Thank you.
Let's say that the two points are (x1,y1), (x2,y2)
Since the shape you are creating is a rectangle, you only need two opposite points.
So let's assume (x1,y1) is the point that can be found on the top left and (x2,y2) is the point that can be found on the bottom right.
The bottom left point can be accessed by (x1,y2) [X stays the same because it's a rectangle, y is set to the y value of the bottom point, again, it's called the bottom left point, so the top-left point is being moved down.]
The top right point can be accessed by (x2,y1) [X stays the same again because it's again a rectangle, y is set to the y value of the top point because the bottom-right point is being moved up)
Visual Representation:
(x1,y1) (?,?)
(?,?) (x2,y2)
So the points are now
(x1,y1) (x2,y2)
(x1,y2) (x2,y2)
But sometimes, (x2,y2) can be switched with (x1,y1), or they will be moved up or down, left or right. You will have to compare the coordinates to compare which points they correspond to.