// Copyright (c) 1996-2001 by Autodesk, Inc. // // By using this code, you are agreeing to the terms and conditions of // the License Agreement included in the documentation for this code. // // AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS // OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK // PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY // LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS, // OMISSIONS, AND OTHER PROBLEMS IN THE CODE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer Software // Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical // Data and Computer Software), as applicable. // // $Header: /NewRoot/DWF Toolkit/v6/develop/global/src/dwf/whiptk/logical_point.cpp 1 9/12/04 8:54p Evansg $ #include "whiptk/pch.h" /////////////////////////////////////////////////////////////////////////// WT_Boolean WT_Logical_Point::operator== (WT_Logical_Point_16 const & lp) const { if (m_x == (WT_Integer32)lp.m_x && m_y == (WT_Integer32)lp.m_y) return WD_True; else return WD_False; } /////////////////////////////////////////////////////////////////////////// WT_Logical_Point const & WT_Logical_Point::operator= (WT_Logical_Point_16 const & in) { m_x = (WT_Integer32) in.m_x; m_y = (WT_Integer32) in.m_y; return *this; } /////////////////////////////////////////////////////////////////////////// const double myPI = 3.14159265358979323846; ///////////////////////// WT_Logical_Point const WT_Logical_Point::operator* (WT_Transform const & trans) const { WT_Logical_Point new_point; // new_point.m_x = (WT_Integer32) ( ((double)m_x + trans.m_translate.m_x) * trans.m_x_scale ); // new_point.m_y = (WT_Integer32) ( ((double)m_y + trans.m_translate.m_y) * trans.m_y_scale ); switch (trans.rotation()) { case 0: new_point.m_x = (WT_Integer32) (((double)m_x * trans.m_x_scale) + trans.m_translate.m_x); new_point.m_y = (WT_Integer32) (((double)m_y * trans.m_y_scale) + trans.m_translate.m_y); break; case 90: new_point.m_x = 0x7FFFFFFF - ((WT_Integer32) (((double)m_y * trans.m_y_scale) + trans.m_translate.m_y)); new_point.m_y = (WT_Integer32) (((double)m_x * trans.m_x_scale) + trans.m_translate.m_x); break; case 180: new_point.m_x = 0x7FFFFFFF - ((WT_Integer32) (((double)m_x * trans.m_x_scale) + trans.m_translate.m_x)); new_point.m_y = 0x7FFFFFFF - ((WT_Integer32) (((double)m_y * trans.m_y_scale) + trans.m_translate.m_y)); break; case 270: new_point.m_x = (WT_Integer32) (((double)m_y * trans.m_y_scale) + trans.m_translate.m_y); new_point.m_y = 0x7FFFFFFF - ((WT_Integer32) (((double)m_x * trans.m_x_scale) + trans.m_translate.m_x)); break; default: { // Merk op: de code hierboven roteert om (INT_MAX/2, INT_MAX/2) // Bij 90 graden rotaties heb je dan geen kans op overflow. // Bij andere hoeken kan het wel mis gaan. Wij roteren hieronder // daarom om 0,0. Dat blijkt in de praktijk goed te gaan? double sinAngle = sin((double)trans.rotation() / 180.0 * myPI); double cosAngle = cos((double)trans.rotation() / 180.0 * myPI); double transx = (double)m_x * trans.m_x_scale + trans.m_translate.m_x; double transy = (double)m_y * trans.m_y_scale + trans.m_translate.m_y; double newx = transx * cosAngle - transy * sinAngle; double newy = transy * cosAngle + transx * sinAngle; // if (newx>INT_MAX || newy>INT_MAX || newx