Point4.hpp

Go to the documentation of this file.
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 #ifndef base_vecmath_Point4_hpp
00018 #define base_vecmath_Point4_hpp
00019 
00020 #include "Vector4.hpp"
00021 #include "Tuple3.hpp"
00022 
00023 namespace se_core {
00024 
00030     class _SeCoreExport Point4 : public Vector4 {
00031     public:
00039         Point4(coor_t x, coor_t y, coor_t z, coor_t w): Vector4(x, y, z, w) { }
00040 
00045         Point4(const coor_t p[]): Vector4(p) { }
00046 
00051         Point4(const Tuple4& t1): Vector4(t1) { }
00052 
00056         Point4(): Vector4() { }
00057 
00067         Point4(const Tuple3& t1): Vector4(t1.x_, t1.y_, t1.z_, 1) { }
00068 
00081         void set3(const Tuple3& t1) {
00082             x_ = t1.x_;
00083             y_ = t1.y_;
00084             z_ = t1.z_;
00085             w_ = 1;
00086         }
00087 
00093         coor_double_t distanceSquared(const Point4& p1) const {
00094             coor_double_t dx = x_ - p1.x_;
00095             coor_double_t dy = y_ - p1.y_;
00096             coor_double_t dz = z_ - p1.z_;
00097             coor_double_t dw = w_ - p1.w_;
00098             return dx*dx + dy*dy + dz*dz + dw*dw;
00099         }
00100 
00106         coor_t distance(const Point4& p1) const;
00107 
00108 
00116         coor_t distanceL1(const Point4& p1) const;
00117 
00118 
00125         coor_t distanceLinf(const Point4& p1) const;
00126 
00127 
00134         void project(const Point4& p1) {
00135             // zero div may occur.
00136             x_ = CoorT::div(p1.x_, p1.w_);
00137             y_ = CoorT::div(p1.y_, p1.w_);
00138             z_ = CoorT::div(p1.z_, p1.w_);
00139             w_ = 1;
00140         }
00141 
00142         // copy constructor and operator = is made by complier
00143 
00144         Point4& operator=(const Tuple4& t) {
00145             Tuple4::operator=(t);
00146             return *this;
00147         }
00148     };
00149 
00150 } // Namespace
00151 
00152 inline
00153 se_core::Point4 operator*(scale_t s, const se_core::Point4& t1) {
00154     return operator*(s, (const se_core::Tuple4&)t1);
00155 }
00156 
00157 
00158 #endif /* POINT4_H */
00159 

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:13 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo