From: adam Date: Sun, 21 Jun 2009 23:43:00 +0000 (+0000) Subject: add Affine.rotateBox(), min(), max() X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=faa4ae356d464a80e08540d5eb8bbee6296c1dbc add Affine.rotateBox(), min(), max() darcs-hash:20090621234300-5007d-6ce198d57b0c332b0ec05b03efbfe15637dff69e.gz --- diff --git a/src/org/ibex/graphics/Affine.java b/src/org/ibex/graphics/Affine.java index 36cb17f..e5d86b6 100644 --- a/src/org/ibex/graphics/Affine.java +++ b/src/org/ibex/graphics/Affine.java @@ -5,6 +5,7 @@ // FIXME package org.ibex.graphics; import java.util.*; +import org.ibex.util.*; /** an affine transform; all operations are destructive */ public final class Affine { @@ -40,6 +41,20 @@ public final class Affine { public boolean equalsIgnoringTranslation(Affine x) { return a == x.a && b == x.b && c == x.c && d == x.d; } public Affine clearTranslation() { e = (float)0.0; f = (float)0.0; return this; } + public long rotateBox(long box) { return rotateBox(Encode.longToFloat1(box), Encode.longToFloat2(box)); } + public long rotateBox(float x, float y) { + float width = + max(max(multiply_px(0, 0), multiply_px(x, y)), max(multiply_px(x, 0), multiply_px(0, y))) - + min(min(multiply_px(0, 0), multiply_px(x, y)), min(multiply_px(x, 0), multiply_px(0, y))); + float height = + max(max(multiply_py(0, 0), multiply_py(x, y)), max(multiply_py(x, 0), multiply_py(0, y))) - + min(min(multiply_py(0, 0), multiply_py(x, y)), min(multiply_py(x, 0), multiply_py(0, y))); + return Encode.twoFloatsToLong(width, height); + } + + static float min(float a, float b) { if (ab) return a; else return b; } + public boolean equals(Object o) { if (!(o instanceof Affine)) return false; Affine x = (Affine)o;