I have 2 values and want to create a rectangle from it.
So let's say:
1 = 1,1
2 = 10,8
So I want to calculate the upper left corner which would result in 1,8 and the lower right corner which would be 10,1. How can I achieve this with Java? Are there any libraries for this or is it even possible with the standard equipment?
Based on your diagram and example, you want a rectangle with vertical and horizontal sides. If you look at your current example, all you did was take x1 and y2 for one of the points, and x2/y1 for the other point.
So, given
Point
sp1
andp2
, you could do as follows:Of course, if you do not have
Point
objects you can just use the numbers as variables accordingly.