00001 /* 00002 * Copyright (c) 2001 The AUTHORS 00003 * Romeu Andre' Pieritz, Ph.D. - romeu_pieritz@hotmail.com 00004 * Rafael Mendes, Eng. – mendes_rafael@yahoo.com 00005 * Rodrigo Ferraz de Andrade, Eng. – rferraz@iname.com 00006 * All rights reserved. 00007 * 00008 * Permission to use, copy and distribute this software and its 00009 * documentation for educational and personal use, without fee is hereby granted, 00010 * provided that the above copyright notice and the following 00011 * two paragraphs appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE AUTHORS SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HERE UNDER IS 00021 * ON AN "AS IS" BASIS, AND THE AUTHORS HAVE NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00023 * 00024 * SINMEC Lab. - CFD Sinflow Project - http://www.sinmec.ufsc.br/cfd 00025 */ 00026 00027 00028 // File Define 00029 #ifndef __CSFL_SYS_GEOM_DPOINT_H__ 00030 #define __CSFL_SYS_GEOM_DPOINT_H__ 00031 00032 // Include 00033 #include <csfl/sys/core/sflobject.h> 00034 00035 00036 // Namespace 00037 namespace csfl { 00038 00039 00040 class IDPoint 00041 00046 00047 { 00048 00049 public: 00050 00052 static const IDPoint zero; 00053 00057 IDPoint( double _x = 0.0, double _y = 0.0 ) 00058 : x(_x), y(_y) {} 00059 ~IDPoint(){} 00060 00064 inline IDPoint operator + ( const IDPoint & _p ) const 00065 { return IDPoint( x + _p.x, y + _p.y ); } 00066 00070 inline IDPoint operator - ( const IDPoint & _p ) const 00071 { return IDPoint( x - _p.x, y - _p.y ); } 00072 00076 inline IDPoint operator * ( double n ) const 00077 { return IDPoint( x * n, y * n ); } 00078 00082 inline IDPoint operator * ( int n ) const 00083 { return IDPoint( x * n, y * n ); } 00084 00088 inline IDPoint operator / ( double n ) const 00089 { return IDPoint( x / n, y / n ); } 00090 00094 inline bool operator != ( const IDPoint & _p ) const 00095 { return ( x != _p.x || y != _p.y ) ? true : false ; } 00096 00100 inline bool operator == ( const IDPoint & _p ) const 00101 { return ( x == _p.x && y == _p.y ) ? true : false ; } 00102 00103 00104 public: 00106 double x, y; 00107 00108 }; 00109 00110 // Inline 00111 00112 inline double LineLength( const IDPoint & _p1, const IDPoint & _p2 ) 00113 { 00114 return sqrt( ( _p1.x - _p2.x )*( _p1.x - _p2.x ) + 00115 ( _p1.y - _p2.y )*( _p1.y - _p2.y ) ); 00116 } 00117 00118 inline IDPoint LineCenter( const IDPoint & _p1, const IDPoint &_p2 ) 00119 { 00120 return IDPoint( ( ( _p1.x + _p2.x ) / 2.0 ), 00121 ( ( _p1.y + _p2.y ) / 2.0) ); 00122 } 00123 00124 inline IDPoint Rotate( const IDPoint & _p, const double & _angle ) 00125 { 00126 return IDPoint( ( _p.x * cos( _angle ) + _p.y * sin( _angle ) ), 00127 ( _p.x * (-sin( _angle )) + _p.y * cos( _angle ) )); 00128 } 00129 00130 } // csfl namespace 00131 00132 #endif // __CSFL_SYS_GEOM_DPOINT_H__
CFD Project
|
Documents |
Downloads |
Contact us |
Use Terms |
|
|||
© SINMEC/EMC/UFSC,
2001. |
All rights
reserved. |
Last Update: Jan. 18, 2002 |
|