/usr/include/agg2/agg_trans_perspective.h is in libagg-dev 2.5+dfsg1-9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 | //----------------------------------------------------------------------------
// Anti-Grain Geometry (AGG) - Version 2.5
// A high quality rendering engine for C++
// Copyright (C) 2002-2006 Maxim Shemanarev
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://antigrain.com
//
// AGG is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// AGG is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with AGG; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
//----------------------------------------------------------------------------
#ifndef AGG_TRANS_PERSPECTIVE_INCLUDED
#define AGG_TRANS_PERSPECTIVE_INCLUDED
#include "agg_trans_affine.h"
namespace agg
{
//=======================================================trans_perspective
struct trans_perspective
{
double sx, shy, w0, shx, sy, w1, tx, ty, w2;
//------------------------------------------------------- Construction
// Identity matrix
trans_perspective() :
sx (1), shy(0), w0(0),
shx(0), sy (1), w1(0),
tx (0), ty (0), w2(1) {}
// Custom matrix
trans_perspective(double v0, double v1, double v2,
double v3, double v4, double v5,
double v6, double v7, double v8) :
sx (v0), shy(v1), w0(v2),
shx(v3), sy (v4), w1(v5),
tx (v6), ty (v7), w2(v8) {}
// Custom matrix from m[9]
explicit trans_perspective(const double* m) :
sx (m[0]), shy(m[1]), w0(m[2]),
shx(m[3]), sy (m[4]), w1(m[5]),
tx (m[6]), ty (m[7]), w2(m[8]) {}
// From affine
explicit trans_perspective(const trans_affine& a) :
sx (a.sx ), shy(a.shy), w0(0),
shx(a.shx), sy (a.sy ), w1(0),
tx (a.tx ), ty (a.ty ), w2(1) {}
// Rectangle to quadrilateral
trans_perspective(double x1, double y1, double x2, double y2,
const double* quad);
// Quadrilateral to rectangle
trans_perspective(const double* quad,
double x1, double y1, double x2, double y2);
// Arbitrary quadrilateral transformations
trans_perspective(const double* src, const double* dst);
//-------------------------------------- Quadrilateral transformations
// The arguments are double[8] that are mapped to quadrilaterals:
// x1,y1, x2,y2, x3,y3, x4,y4
bool quad_to_quad(const double* qs, const double* qd);
bool rect_to_quad(double x1, double y1,
double x2, double y2,
const double* q);
bool quad_to_rect(const double* q,
double x1, double y1,
double x2, double y2);
// Map square (0,0,1,1) to the quadrilateral and vice versa
bool square_to_quad(const double* q);
bool quad_to_square(const double* q);
//--------------------------------------------------------- Operations
// Reset - load an identity matrix
const trans_perspective& reset();
// Invert matrix. Returns false in degenerate case
bool invert();
// Direct transformations operations
const trans_perspective& translate(double x, double y);
const trans_perspective& rotate(double a);
const trans_perspective& scale(double s);
const trans_perspective& scale(double x, double y);
// Multiply the matrix by another one
const trans_perspective& multiply(const trans_perspective& m);
// Multiply "m" by "this" and assign the result to "this"
const trans_perspective& premultiply(const trans_perspective& m);
// Multiply matrix to inverse of another one
const trans_perspective& multiply_inv(const trans_perspective& m);
// Multiply inverse of "m" by "this" and assign the result to "this"
const trans_perspective& premultiply_inv(const trans_perspective& m);
// Multiply the matrix by another one
const trans_perspective& multiply(const trans_affine& m);
// Multiply "m" by "this" and assign the result to "this"
const trans_perspective& premultiply(const trans_affine& m);
// Multiply the matrix by inverse of another one
const trans_perspective& multiply_inv(const trans_affine& m);
// Multiply inverse of "m" by "this" and assign the result to "this"
const trans_perspective& premultiply_inv(const trans_affine& m);
//--------------------------------------------------------- Load/Store
void store_to(double* m) const;
const trans_perspective& load_from(const double* m);
//---------------------------------------------------------- Operators
// Multiply the matrix by another one
const trans_perspective& operator *= (const trans_perspective& m)
{
return multiply(m);
}
const trans_perspective& operator *= (const trans_affine& m)
{
return multiply(m);
}
// Multiply the matrix by inverse of another one
const trans_perspective& operator /= (const trans_perspective& m)
{
return multiply_inv(m);
}
const trans_perspective& operator /= (const trans_affine& m)
{
return multiply_inv(m);
}
// Multiply the matrix by another one and return
// the result in a separete matrix.
trans_perspective operator * (const trans_perspective& m)
{
return trans_perspective(*this).multiply(m);
}
trans_perspective operator * (const trans_affine& m)
{
return trans_perspective(*this).multiply(m);
}
// Multiply the matrix by inverse of another one
// and return the result in a separete matrix.
trans_perspective operator / (const trans_perspective& m)
{
return trans_perspective(*this).multiply_inv(m);
}
trans_perspective operator / (const trans_affine& m)
{
return trans_perspective(*this).multiply_inv(m);
}
// Calculate and return the inverse matrix
trans_perspective operator ~ () const
{
trans_perspective ret = *this;
ret.invert();
return ret;
}
// Equal operator with default epsilon
bool operator == (const trans_perspective& m) const
{
return is_equal(m, affine_epsilon);
}
// Not Equal operator with default epsilon
bool operator != (const trans_perspective& m) const
{
return !is_equal(m, affine_epsilon);
}
//---------------------------------------------------- Transformations
// Direct transformation of x and y
void transform(double* x, double* y) const;
// Direct transformation of x and y, affine part only
void transform_affine(double* x, double* y) const;
// Direct transformation of x and y, 2x2 matrix only, no translation
void transform_2x2(double* x, double* y) const;
// Inverse transformation of x and y. It works slow because
// it explicitly inverts the matrix on every call. For massive
// operations it's better to invert() the matrix and then use
// direct transformations.
void inverse_transform(double* x, double* y) const;
//---------------------------------------------------------- Auxiliary
const trans_perspective& from_affine(const trans_affine& a);
double determinant() const;
double determinant_reciprocal() const;
bool is_valid(double epsilon = affine_epsilon) const;
bool is_identity(double epsilon = affine_epsilon) const;
bool is_equal(const trans_perspective& m,
double epsilon = affine_epsilon) const;
// Determine the major affine parameters. Use with caution
// considering possible degenerate cases.
double scale() const;
double rotation() const;
void translation(double* dx, double* dy) const;
void scaling(double* x, double* y) const;
void scaling_abs(double* x, double* y) const;
//--------------------------------------------------------------------
class iterator_x
{
double den;
double den_step;
double nom_x;
double nom_x_step;
double nom_y;
double nom_y_step;
public:
double x;
double y;
iterator_x() {}
iterator_x(double px, double py, double step, const trans_perspective& m) :
den(px * m.w0 + py * m.w1 + m.w2),
den_step(m.w0 * step),
nom_x(px * m.sx + py * m.shx + m.tx),
nom_x_step(step * m.sx),
nom_y(px * m.shy + py * m.sy + m.ty),
nom_y_step(step * m.shy),
x(nom_x / den),
y(nom_y / den)
{}
void operator ++ ()
{
den += den_step;
nom_x += nom_x_step;
nom_y += nom_y_step;
double d = 1.0 / den;
x = nom_x * d;
y = nom_y * d;
}
};
//--------------------------------------------------------------------
iterator_x begin(double x, double y, double step) const
{
return iterator_x(x, y, step, *this);
}
};
//------------------------------------------------------------------------
inline bool trans_perspective::square_to_quad(const double* q)
{
double dx = q[0] - q[2] + q[4] - q[6];
double dy = q[1] - q[3] + q[5] - q[7];
if(dx == 0.0 && dy == 0.0)
{
// Affine case (parallelogram)
//---------------
sx = q[2] - q[0];
shy = q[3] - q[1];
w0 = 0.0;
shx = q[4] - q[2];
sy = q[5] - q[3];
w1 = 0.0;
tx = q[0];
ty = q[1];
w2 = 1.0;
}
else
{
double dx1 = q[2] - q[4];
double dy1 = q[3] - q[5];
double dx2 = q[6] - q[4];
double dy2 = q[7] - q[5];
double den = dx1 * dy2 - dx2 * dy1;
if(den == 0.0)
{
// Singular case
//---------------
sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0;
return false;
}
// General case
//---------------
double u = (dx * dy2 - dy * dx2) / den;
double v = (dy * dx1 - dx * dy1) / den;
sx = q[2] - q[0] + u * q[2];
shy = q[3] - q[1] + u * q[3];
w0 = u;
shx = q[6] - q[0] + v * q[6];
sy = q[7] - q[1] + v * q[7];
w1 = v;
tx = q[0];
ty = q[1];
w2 = 1.0;
}
return true;
}
//------------------------------------------------------------------------
inline bool trans_perspective::invert()
{
double d0 = sy * w2 - w1 * ty;
double d1 = w0 * ty - shy * w2;
double d2 = shy * w1 - w0 * sy;
double d = sx * d0 + shx * d1 + tx * d2;
if(d == 0.0)
{
sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0;
return false;
}
d = 1.0 / d;
trans_perspective a = *this;
sx = d * d0;
shy = d * d1;
w0 = d * d2;
shx = d * (a.w1 *a.tx - a.shx*a.w2);
sy = d * (a.sx *a.w2 - a.w0 *a.tx);
w1 = d * (a.w0 *a.shx - a.sx *a.w1);
tx = d * (a.shx*a.ty - a.sy *a.tx);
ty = d * (a.shy*a.tx - a.sx *a.ty);
w2 = d * (a.sx *a.sy - a.shy*a.shx);
return true;
}
//------------------------------------------------------------------------
inline bool trans_perspective::quad_to_square(const double* q)
{
if(!square_to_quad(q)) return false;
invert();
return true;
}
//------------------------------------------------------------------------
inline bool trans_perspective::quad_to_quad(const double* qs,
const double* qd)
{
trans_perspective p;
if(! quad_to_square(qs)) return false;
if(!p.square_to_quad(qd)) return false;
multiply(p);
return true;
}
//------------------------------------------------------------------------
inline bool trans_perspective::rect_to_quad(double x1, double y1,
double x2, double y2,
const double* q)
{
double r[8];
r[0] = r[6] = x1;
r[2] = r[4] = x2;
r[1] = r[3] = y1;
r[5] = r[7] = y2;
return quad_to_quad(r, q);
}
//------------------------------------------------------------------------
inline bool trans_perspective::quad_to_rect(const double* q,
double x1, double y1,
double x2, double y2)
{
double r[8];
r[0] = r[6] = x1;
r[2] = r[4] = x2;
r[1] = r[3] = y1;
r[5] = r[7] = y2;
return quad_to_quad(q, r);
}
//------------------------------------------------------------------------
inline trans_perspective::trans_perspective(double x1, double y1,
double x2, double y2,
const double* quad)
{
rect_to_quad(x1, y1, x2, y2, quad);
}
//------------------------------------------------------------------------
inline trans_perspective::trans_perspective(const double* quad,
double x1, double y1,
double x2, double y2)
{
quad_to_rect(quad, x1, y1, x2, y2);
}
//------------------------------------------------------------------------
inline trans_perspective::trans_perspective(const double* src,
const double* dst)
{
quad_to_quad(src, dst);
}
//------------------------------------------------------------------------
inline const trans_perspective& trans_perspective::reset()
{
sx = 1; shy = 0; w0 = 0;
shx = 0; sy = 1; w1 = 0;
tx = 0; ty = 0; w2 = 1;
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective&
trans_perspective::multiply(const trans_perspective& a)
{
trans_perspective b = *this;
sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0;
shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1;
tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2;
shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0;
sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1;
ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2;
w0 = a.w0 *b.sx + a.w1 *b.shy + a.w2*b.w0;
w1 = a.w0 *b.shx + a.w1 *b.sy + a.w2*b.w1;
w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2*b.w2;
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective&
trans_perspective::multiply(const trans_affine& a)
{
trans_perspective b = *this;
sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0;
shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1;
tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2;
shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0;
sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1;
ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2;
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective&
trans_perspective::premultiply(const trans_perspective& b)
{
trans_perspective a = *this;
sx = a.sx *b.sx + a.shx*b.shy + a.tx*b.w0;
shx = a.sx *b.shx + a.shx*b.sy + a.tx*b.w1;
tx = a.sx *b.tx + a.shx*b.ty + a.tx*b.w2;
shy = a.shy*b.sx + a.sy *b.shy + a.ty*b.w0;
sy = a.shy*b.shx + a.sy *b.sy + a.ty*b.w1;
ty = a.shy*b.tx + a.sy *b.ty + a.ty*b.w2;
w0 = a.w0 *b.sx + a.w1 *b.shy + a.w2*b.w0;
w1 = a.w0 *b.shx + a.w1 *b.sy + a.w2*b.w1;
w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2*b.w2;
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective&
trans_perspective::premultiply(const trans_affine& b)
{
trans_perspective a = *this;
sx = a.sx *b.sx + a.shx*b.shy;
shx = a.sx *b.shx + a.shx*b.sy;
tx = a.sx *b.tx + a.shx*b.ty + a.tx;
shy = a.shy*b.sx + a.sy *b.shy;
sy = a.shy*b.shx + a.sy *b.sy;
ty = a.shy*b.tx + a.sy *b.ty + a.ty;
w0 = a.w0 *b.sx + a.w1 *b.shy;
w1 = a.w0 *b.shx + a.w1 *b.sy;
w2 = a.w0 *b.tx + a.w1 *b.ty + a.w2;
return *this;
}
//------------------------------------------------------------------------
const trans_perspective&
trans_perspective::multiply_inv(const trans_perspective& m)
{
trans_perspective t = m;
t.invert();
return multiply(t);
}
//------------------------------------------------------------------------
const trans_perspective&
trans_perspective::multiply_inv(const trans_affine& m)
{
trans_affine t = m;
t.invert();
return multiply(t);
}
//------------------------------------------------------------------------
const trans_perspective&
trans_perspective::premultiply_inv(const trans_perspective& m)
{
trans_perspective t = m;
t.invert();
return *this = t.multiply(*this);
}
//------------------------------------------------------------------------
const trans_perspective&
trans_perspective::premultiply_inv(const trans_affine& m)
{
trans_perspective t(m);
t.invert();
return *this = t.multiply(*this);
}
//------------------------------------------------------------------------
inline const trans_perspective&
trans_perspective::translate(double x, double y)
{
tx += x;
ty += y;
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective& trans_perspective::rotate(double a)
{
multiply(trans_affine_rotation(a));
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective& trans_perspective::scale(double s)
{
multiply(trans_affine_scaling(s));
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective& trans_perspective::scale(double x, double y)
{
multiply(trans_affine_scaling(x, y));
return *this;
}
//------------------------------------------------------------------------
inline void trans_perspective::transform(double* px, double* py) const
{
double x = *px;
double y = *py;
double m = 1.0 / (x*w0 + y*w1 + w2);
*px = m * (x*sx + y*shx + tx);
*py = m * (x*shy + y*sy + ty);
}
//------------------------------------------------------------------------
inline void trans_perspective::transform_affine(double* x, double* y) const
{
double tmp = *x;
*x = tmp * sx + *y * shx + tx;
*y = tmp * shy + *y * sy + ty;
}
//------------------------------------------------------------------------
inline void trans_perspective::transform_2x2(double* x, double* y) const
{
double tmp = *x;
*x = tmp * sx + *y * shx;
*y = tmp * shy + *y * sy;
}
//------------------------------------------------------------------------
inline void trans_perspective::inverse_transform(double* x, double* y) const
{
trans_perspective t(*this);
if(t.invert()) t.transform(x, y);
}
//------------------------------------------------------------------------
inline void trans_perspective::store_to(double* m) const
{
*m++ = sx; *m++ = shy; *m++ = w0;
*m++ = shx; *m++ = sy; *m++ = w1;
*m++ = tx; *m++ = ty; *m++ = w2;
}
//------------------------------------------------------------------------
inline const trans_perspective& trans_perspective::load_from(const double* m)
{
sx = *m++; shy = *m++; w0 = *m++;
shx = *m++; sy = *m++; w1 = *m++;
tx = *m++; ty = *m++; w2 = *m++;
return *this;
}
//------------------------------------------------------------------------
inline const trans_perspective&
trans_perspective::from_affine(const trans_affine& a)
{
sx = a.sx; shy = a.shy; w0 = 0;
shx = a.shx; sy = a.sy; w1 = 0;
tx = a.tx; ty = a.ty; w2 = 1;
return *this;
}
//------------------------------------------------------------------------
inline double trans_perspective::determinant() const
{
return sx * (sy * w2 - ty * w1) +
shx * (ty * w0 - shy * w2) +
tx * (shy * w1 - sy * w0);
}
//------------------------------------------------------------------------
inline double trans_perspective::determinant_reciprocal() const
{
return 1.0 / determinant();
}
//------------------------------------------------------------------------
inline bool trans_perspective::is_valid(double epsilon) const
{
return fabs(sx) > epsilon && fabs(sy) > epsilon && fabs(w2) > epsilon;
}
//------------------------------------------------------------------------
inline bool trans_perspective::is_identity(double epsilon) const
{
return is_equal_eps(sx, 1.0, epsilon) &&
is_equal_eps(shy, 0.0, epsilon) &&
is_equal_eps(w0, 0.0, epsilon) &&
is_equal_eps(shx, 0.0, epsilon) &&
is_equal_eps(sy, 1.0, epsilon) &&
is_equal_eps(w1, 0.0, epsilon) &&
is_equal_eps(tx, 0.0, epsilon) &&
is_equal_eps(ty, 0.0, epsilon) &&
is_equal_eps(w2, 1.0, epsilon);
}
//------------------------------------------------------------------------
inline bool trans_perspective::is_equal(const trans_perspective& m,
double epsilon) const
{
return is_equal_eps(sx, m.sx, epsilon) &&
is_equal_eps(shy, m.shy, epsilon) &&
is_equal_eps(w0, m.w0, epsilon) &&
is_equal_eps(shx, m.shx, epsilon) &&
is_equal_eps(sy, m.sy, epsilon) &&
is_equal_eps(w1, m.w1, epsilon) &&
is_equal_eps(tx, m.tx, epsilon) &&
is_equal_eps(ty, m.ty, epsilon) &&
is_equal_eps(w2, m.w2, epsilon);
}
//------------------------------------------------------------------------
inline double trans_perspective::scale() const
{
double x = 0.707106781 * sx + 0.707106781 * shx;
double y = 0.707106781 * shy + 0.707106781 * sy;
return sqrt(x*x + y*y);
}
//------------------------------------------------------------------------
inline double trans_perspective::rotation() const
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 0.0;
transform(&x1, &y1);
transform(&x2, &y2);
return atan2(y2-y1, x2-x1);
}
//------------------------------------------------------------------------
void trans_perspective::translation(double* dx, double* dy) const
{
*dx = tx;
*dy = ty;
}
//------------------------------------------------------------------------
void trans_perspective::scaling(double* x, double* y) const
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 1.0;
trans_perspective t(*this);
t *= trans_affine_rotation(-rotation());
t.transform(&x1, &y1);
t.transform(&x2, &y2);
*x = x2 - x1;
*y = y2 - y1;
}
//------------------------------------------------------------------------
void trans_perspective::scaling_abs(double* x, double* y) const
{
*x = sqrt(sx * sx + shx * shx);
*y = sqrt(shy * shy + sy * sy);
}
}
#endif
|