I’m trying to solve this particular problem using c++.
Problem:
Given a set of (x,y) coordinates on a Euclidean geometric plane, and a set of four (x,y) coordinates that define a square, I need to determine if all the points are contained within the defined square. Points that are found on the sides of the square or the corners of the square count as points in the square. The square is not necessarily parallel to the axes.
The input is a bit interesting and there are no prompts, just strictly typing in coordinates.
Input: A set of comma separated (x,y) coordinates, which are separated by spaces.
The first four coordinates define the corners of a square (in no particular order) and the remainder of the comma separated coordinates will be the points.
So for example:
0,0 0,5 5,0 5,5 1,1 2,2 3,3
(Defines a square with corners (0,0)/(0,5)/(5,0)/(5,5) and three points (1,1)/(2,2)/(3,3))
I’m assuming the best course of action is to use getline and then parse the input.
Output is true or false if at least one point is outside the square.
It’s been difficult trying to wrap my head around this and I can really appreciate help.
For the input I recommend looking up Inserter interators.
Something like the following:
Usage: