// ------------------------------------------------------------------------ // This program is complementary material for the book: // // Frank Nielsen // // Visual Computing: Geometry, Graphics, and Vision // // ISBN: 1-58450-427-7 // // Charles River Media, Inc. // // // All programs are available at http://www.charlesriver.com/visualcomputing/ // // You may use this program for ACADEMIC and PERSONAL purposes ONLY. // // // The use of this program in a commercial product requires EXPLICITLY // written permission from the author. The author is NOT responsible or // liable for damage or loss that may be caused by the use of this program. // // Copyright (c) 2005. Frank Nielsen. All rights reserved. // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // File: matchsegments.cpp // // Description: Compute the scaled rigid transformation in 2D that match a // pair of segments // ------------------------------------------------------------------------ #include "stdafx.h" #include using namespace std; #define M_PI 3.14159265358979323846 inline double drand() { return rand()/(double)RAND_MAX; } typedef double transformation[3][3]; class point2d{public: double x,y,w; // homogeneous coordinates point2d::point2d() {x=drand();y=drand();w=1.0;} point2d::point2d(double xx, double yy, double ww) {x=xx;y=yy;w=ww;} point2d Transformation(transformation t) {double xp,yp,wp; xp=t[0][0]*x+t[0][1]*y+t[0][2]*w; yp=t[1][0]*x+t[1][1]*y+t[1][2]*w; wp=t[2][0]*x+t[2][1]*y+t[2][2]*w; return point2d(xp/wp,yp/wp,1); } friend ostream& operator << (ostream & os, point2d p) { os << "["<=p1.y)) theta1=M_PI-theta1; if ((p2.x>=p1.x)&&(p2.y=q1.y)) theta2=M_PI-theta2; if ((q2.x>=q1.x)&&(q2.y