Terms and conditions
Preamble:
This Agreement, signed on Jun 10, 2012 [hereinafter: Effective Date] governs the relationship between the Enduser, a private person, (hereinafter: Licensee) and Paul N...
If you think the Android project Operation-Valkyrie listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.opencv.core;
/*fromwww.java2s.com*/publicclass RotatedRect {
public Point center;
public Size size;
publicdouble angle;
public RotatedRect() {
this.center = new Point();
this.size = new Size();
this.angle = 0;
}
public RotatedRect(Point c, Size s, double a) {
this.center = c.clone();
this.size = s.clone();
this.angle = a;
}
public RotatedRect(double[] vals) {
this();
set(vals);
}
publicvoid set(double[] vals) {
if (vals != null) {
center.x = vals.length > 0 ? (double) vals[0] : 0;
center.y = vals.length > 1 ? (double) vals[1] : 0;
size.width = vals.length > 2 ? (double) vals[2] : 0;
size.height = vals.length > 3 ? (double) vals[3] : 0;
angle = vals.length > 4 ? (double) vals[4] : 0;
} else {
center.x = 0;
center.x = 0;
size.width = 0;
size.height = 0;
angle = 0;
}
}
publicvoid points(Point pt[])
{
double _angle = angle * Math.PI / 180.0;
double b = (double) Math.cos(_angle) * 0.5f;
double a = (double) Math.sin(_angle) * 0.5f;
pt[0] = new Point(
center.x - a * size.height - b * size.width,
center.y + b * size.height - a * size.width);
pt[1] = new Point(
center.x + a * size.height - b * size.width,
center.y - b * size.height - a * size.width);
pt[2] = new Point(
2 * center.x - pt[0].x,
2 * center.y - pt[0].y);
pt[3] = new Point(
2 * center.x - pt[1].x,
2 * center.y - pt[1].y);
}
public Rect boundingRect()
{
Point pt[] = new Point[4];
points(pt);
Rect r = new Rect((int) Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
(int) Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
(int) Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
(int) Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
r.width -= r.x - 1;
r.height -= r.y - 1;
return r;
}
public RotatedRect clone() {
returnnew RotatedRect(center, size, angle);
}
@Override
publicint hashCode() {
finalint prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(center.x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(center.y);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(size.width);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(size.height);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(angle);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
publicboolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof RotatedRect)) return false;
RotatedRect it = (RotatedRect) obj;
return center.equals(it.center) && size.equals(it.size) && angle == it.angle;
}
@Override
public String toString() {
return"{ " + center + " " + size + " * " + angle + " }";
}
}