Formatting update
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / geometry / Rectangle.java
1 /*
2  * Sixth 3D engine. Author: Svjatoslav Agejenko. 
3  * This project is released under Creative Commons Zero (CC0) license.
4  */
5 package eu.svjatoslav.sixth.e3d.geometry;
6
7 public class Rectangle {
8
9     public Point2D p1, p2;
10
11     public Rectangle(final double size) {
12         p2 = new Point2D(size / 2, size / 2);
13         p1 = p2.clone().invert();
14     }
15
16     public Rectangle(final Point2D p1, final Point2D p2) {
17         this.p1 = p1;
18         this.p2 = p2;
19     }
20
21     public double getHeight() {
22         return Math.abs(p1.y - p2.y);
23     }
24
25     public double getLowerX() {
26         if (p1.x < p2.x)
27             return p1.x;
28         return p2.x;
29     }
30
31     public double getLowerY() {
32         if (p1.y < p2.y)
33             return p1.y;
34         return p2.y;
35     }
36
37     public double getWidth() {
38         return Math.abs(p1.x - p2.x);
39     }
40
41 }