[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob/src/util intersect.cxx
From: |
Asko Soukka |
Subject: |
[Gzz-commits] libvob/src/util intersect.cxx |
Date: |
Wed, 13 Aug 2003 04:08:41 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Asko Soukka <address@hidden> 03/08/13 04:08:41
Modified files:
src/util : intersect.cxx
Log message:
a quick fix
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/util/intersect.cxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: libvob/src/util/intersect.cxx
diff -u libvob/src/util/intersect.cxx:1.2 libvob/src/util/intersect.cxx:1.3
--- libvob/src/util/intersect.cxx:1.2 Wed Aug 13 02:42:01 2003
+++ libvob/src/util/intersect.cxx Wed Aug 13 04:08:41 2003
@@ -50,11 +50,12 @@
int i0, j0;
Pt box = t->getSqSize();
float x1=0, y1=0, x2=0, y2=0;
+
DBG(dbg_intersect) << "Find bb "<<t<<" "<<box<<"\n";
for (i0=0; i0<=1; i0+=1) {
for (j0=0; j0<=1; j0+=1) {
float i = i0 * box.x;
- float j = j0 * box.x;
+ float j = j0 * box.y;
if (i==0 && j==0) {
/** Initializing. */
ZPt tmpPt = t->transform(ZPt(i, j, 0));
@@ -74,66 +75,68 @@
p2 = ZPt(x2, y2, 0);
DBG(dbg_intersect) << "Return "<<p1<<" "<<p2<<"\n";
}
+
void findDistortedBoundingBox(const Transform *t, ZPt &p1, ZPt &p2) {
double i, step_x, step_y;
Pt box = t->getSqSize();
- float x1, y1, x2, y2;
+ float x1=0, y1=0, x2=0, y2=0;
int check_dist;
DBG(dbg_intersect) << "Find distortedbb "<<t<<" "<<box<<"\n";
- /** Initializing. */
- check_dist = 100; // XXX Adjusts the scanning frequency.
+ if (box.x>0 && box.y>0) { // box area must be positive
+ /** Initializing. */
+ check_dist = 100; // XXX Adjusts the scanning frequency.
- ZPt o = t->transform(ZPt(0, 0, 0));
- ZPt u = t->transform(ZPt(box.x, box.y, 0));
+ ZPt o = t->transform(ZPt(0, 0, 0));
+ ZPt u = t->transform(ZPt(box.x, box.y, 0));
- if (fabs(o.x - u.x) / check_dist > box.x)
- step_x = box.x/(fabs(o.x - u.x) / check_dist);
- else step_x = box.x;
- if (fabs(o.y - u.y) / check_dist > box.y)
- step_y = box.y/(fabs(o.y - u.y) / check_dist);
- else step_y = box.y;
-
- x1 = u.x; y1 = u.y;
- x2 = u.x; y2 = u.y;
-
- /** Sweeps the box's vertices. */
- /** Vertice (0,0) -> (w,0). */
- for (i=0; i < box.x; i+=step_x) {
- ZPt tmpPt = t->transform(ZPt(i, 0, 0));
- if (tmpPt.x < x1) x1 = tmpPt.x;
- else if (tmpPt.x > x2) x2 = tmpPt.x;
- if (tmpPt.y < y1) y1 = tmpPt.y;
- else if (tmpPt.y > y2) y2 = tmpPt.y;
- }
+ if (fabs(o.x - u.x) / check_dist > box.x)
+ step_x = box.x/(fabs(o.x - u.x) / check_dist);
+ else step_x = box.x;
+ if (fabs(o.y - u.y) / check_dist > box.y)
+ step_y = box.y/(fabs(o.y - u.y) / check_dist);
+ else step_y = box.y;
+
+ x1 = u.x; y1 = u.y;
+ x2 = u.x; y2 = u.y;
+
+ /** Sweeps the box's vertices. */
+ /** Vertice (0,0) -> (w,0). */
+ for (i=0; i < box.x; i+=step_x) {
+ ZPt tmpPt = t->transform(ZPt(i, 0, 0));
+ if (tmpPt.x < x1) x1 = tmpPt.x;
+ else if (tmpPt.x > x2) x2 = tmpPt.x;
+ if (tmpPt.y < y1) y1 = tmpPt.y;
+ else if (tmpPt.y > y2) y2 = tmpPt.y;
+ }
- /** Vertice (0,0) -> (0,h). */
- for (i=step_y; i < box.y; i+=step_y) {
- ZPt tmpPt = t->transform(ZPt(0, i, 0));
- if (tmpPt.x < x1) x1 = tmpPt.x;
- else if (tmpPt.x > x2) x2 = tmpPt.x;
- if (tmpPt.y < y1) y1 = tmpPt.y;
- else if (tmpPt.y > y2) y2 = tmpPt.y;
- }
+ /** Vertice (0,0) -> (0,h). */
+ for (i=step_y; i < box.y; i+=step_y) {
+ ZPt tmpPt = t->transform(ZPt(0, i, 0));
+ if (tmpPt.x < x1) x1 = tmpPt.x;
+ else if (tmpPt.x > x2) x2 = tmpPt.x;
+ if (tmpPt.y < y1) y1 = tmpPt.y;
+ else if (tmpPt.y > y2) y2 = tmpPt.y;
+ }
- /** Vertice (0,h) -> (w,h) */
- for (i=0; i < box.x; i+=step_x) {
- ZPt tmpPt = t->transform(ZPt(i, box.y, 0));
- if (tmpPt.x < x1) x1 = tmpPt.x;
- else if (tmpPt.x > x2) x2 = tmpPt.x;
- if (tmpPt.y < y1) y1 = tmpPt.y;
- else if (tmpPt.y > y2) y2 = tmpPt.y;
- }
+ /** Vertice (0,h) -> (w,h). */
+ for (i=0; i < box.x; i+=step_x) {
+ ZPt tmpPt = t->transform(ZPt(i, box.y, 0));
+ if (tmpPt.x < x1) x1 = tmpPt.x;
+ else if (tmpPt.x > x2) x2 = tmpPt.x;
+ if (tmpPt.y < y1) y1 = tmpPt.y;
+ else if (tmpPt.y > y2) y2 = tmpPt.y;
+ }
- /** Vertice (w,0) -> (w,h) */
- for (i=0; i < box.y; i+=step_y) {
- ZPt tmpPt = t->transform(ZPt(box.x, i, 0));
- if (tmpPt.x < x1) x1 = tmpPt.x;
- else if (tmpPt.x > x2) x2 = tmpPt.x;
- if (tmpPt.y < y1) y1 = tmpPt.y;
- else if (tmpPt.y > y2) y2 = tmpPt.y;
+ /** Vertice (w,0) -> (w,h). */
+ for (i=0; i < box.y; i+=step_y) {
+ ZPt tmpPt = t->transform(ZPt(box.x, i, 0));
+ if (tmpPt.x < x1) x1 = tmpPt.x;
+ else if (tmpPt.x > x2) x2 = tmpPt.x;
+ if (tmpPt.y < y1) y1 = tmpPt.y;
+ else if (tmpPt.y > y2) y2 = tmpPt.y;
+ }
}
-
p1 = ZPt(x1, y1, 0);
p2 = ZPt(x2, y2, 0);
DBG(dbg_intersect) << "Return "<<p1<<" "<<p2<<"\n";
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] libvob/src/util intersect.cxx,
Asko Soukka <=