00001 /* 00002 Copyright (C) 1997,1998,1999 00003 Kenji Hiranabe, Eiwa System Management, Inc. 00004 00005 This program is free software. 00006 Implemented by Kenji Hiranabe(hiranabe@esm.co.jp), 00007 conforming to the Java(TM) 3D API specification by Sun Microsystems. 00008 00009 Permission to use, copy, modify, distribute and sell this software 00010 and its documentation for any purpose is hereby granted without fee, 00011 provided that the above copyright notice appear in all copies and 00012 that both that copyright notice and this permission notice appear 00013 in supporting documentation. Kenji Hiranabe and Eiwa System Management,Inc. 00014 makes no representations about the suitability of this software for any 00015 purpose. It is provided "AS IS" with NO WARRANTY. 00016 00017 Copyright (C) 2004 00018 Rune Myrland, Skalden Studio AS 00019 SagaEngine adaptions. Kenji Hiranabe's license apply. 00020 */ 00021 #ifndef base_vecmath_Vector2_hpp 00022 #define base_vecmath_Vector2_hpp 00023 00024 #include "Tuple2.hpp" 00025 #include "../math/CoorT.hpp" 00026 00027 namespace se_core { 00036 class _SeCoreExport Vector2 : public Tuple2 { 00037 public: 00043 Vector2(coor_t x, coor_t y) : Tuple2(x, y) { } 00044 00049 Vector2(const coor_t v[]) : Tuple2(v) { } 00050 00055 Vector2(const Tuple2& t1) : Tuple2(t1) { } 00056 00060 Vector2(): Tuple2() { } 00061 00066 coor_t dot(const Vector2& v1) const { 00067 return CoorT::fromd( CoorT::muld(x_, v1.x_) + CoorT::muld(y_, v1.y_) ); 00068 } 00069 00074 coor_double_t lengthSquared() const { 00075 return CoorT::muld(x_, x_) + CoorT::muld(y_, y_); 00076 } 00077 00082 coor_t length() const; 00083 00084 00088 void normalize() { 00089 coor_t d = length(); 00090 00091 // zero-div may occur. 00092 x_ = CoorT::div(x_, d); 00093 y_ = CoorT::div(y_, d); 00094 } 00095 00100 void normalize(const Vector2& v1) { 00101 set(v1); 00102 normalize(); 00103 } 00104 00112 bray_t angle(const Vector2& v1) const; 00113 00114 // copy constructor and operator = is made by complier 00115 00116 Vector2& operator=(const Tuple2& t) { 00117 Tuple2::operator=(t); 00118 return *this; 00119 } 00120 }; 00121 } // Namespace 00122 00123 inline 00124 se_core::Vector2 operator*(scale_t s, const se_core::Vector2& t1) { 00125 return operator*(s, (const se_core::Tuple2&)t1); 00126 } 00127 00128 #endif /* VECTOR2_H */
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:13 2007 by Doxygen version 1.3.9.1.