IceHPoint.h
Go to the documentation of this file.
00001 
00002 
00008 
00009 
00011 // Include Guard
00012 #ifndef __ICEHPOINT_H__
00013 #define __ICEHPOINT_H__
00014 
00015         class ICEMATHS_API HPoint : public Point
00016         {
00017                 public:
00018 
00020                 inline_                         HPoint()                                                                                                                                                {}
00022                 inline_                         HPoint(float _x, float _y, float _z, float _w=0.0f) : Point(_x, _y, _z), w(_w)  {}
00024                 inline_                         HPoint(const float f[4]) : Point(f), w(f[3])                                                                    {}
00026                 inline_                         HPoint(const Point& p, float _w=0.0f) : Point(p), w(_w)                                                 {}
00028                 inline_                         ~HPoint()                                                                                                                                               {}
00029 
00031                 inline_ HPoint&         Zero()                                                                                  { x =                   y =                     z =                     w = 0.0f;               return *this;   }
00032 
00034                 inline_ HPoint&         Set(float _x, float _y, float _z, float _w )    { x  = _x;              y  = _y;        z  = _z;        w  = _w;                return *this;   }
00036                 inline_ HPoint&         Set(const float f[4])                                                   { x  = f[_X];   y  = f[_Y];     z  = f[_Z];     w  = f[_W];             return *this;   }
00038                 inline_ HPoint&         Set(const HPoint& src)                                                  { x  = src.x;   y  = src.y;     z  = src.z;     w = src.w;              return *this;   }
00039 
00041                 inline_ HPoint&         Add(float _x, float _y, float _z, float _w )    { x += _x;              y += _y;        z += _z;        w += _w;                return *this;   }
00043                 inline_ HPoint&         Add(const float f[4])                                                   { x += f[_X];   y += f[_Y];     z += f[_Z];     w += f[_W];             return *this;   }
00044 
00046                 inline_ HPoint&         Sub(float _x, float _y, float _z, float _w )    { x -= _x;              y -= _y;        z -= _z;        w -= _w;                return *this;   }
00048                 inline_ HPoint&         Sub(const float f[4])                                                   { x -= f[_X];   y -= f[_Y];     z -= f[_Z];     w -= f[_W];             return *this;   }
00049                 
00051                 inline_ HPoint&         Mul(float s)                                                                    { x *= s;               y *= s;         z *= s;         w *= s;                 return *this;   }
00052 
00054                                 float           Min()                                                           const           { return MIN(x, MIN(y, MIN(z, w)));                                                                             }
00056                                 float           Max()                                                           const           { return MAX(x, MAX(y, MAX(z, w)));                                                                             }
00058                                 HPoint&         Min(const HPoint& p)                                                    { x = MIN(x, p.x); y = MIN(y, p.y); z = MIN(z, p.z); w = MIN(w, p.w);   return *this;   }
00060                                 HPoint&         Max(const HPoint& p)                                                    { x = MAX(x, p.x); y = MAX(y, p.y); z = MAX(z, p.z); w = MAX(w, p.w);   return *this;   }
00061 
00063                 inline_ float           SquareMagnitude()                                       const           { return x*x + y*y + z*z + w*w;                                                                                 }
00065                 inline_ float           Magnitude()                                                     const           { return sqrtf(x*x + y*y + z*z + w*w);                                                                  }
00066 
00068                 inline_ HPoint&         Normalize()
00069                                                         {
00070                                                                 float M = Magnitude();
00071                                                                 if(M)
00072                                                                 {
00073                                                                         M = 1.0f / M;
00074                                                                         x *= M;
00075                                                                         y *= M;
00076                                                                         z *= M;
00077                                                                         w *= M;
00078                                                                 }
00079                                                                 return *this;
00080                                                         }
00081 
00082                 // Arithmetic operators
00084                 inline_ HPoint          operator-()                                                     const           { return HPoint(-x, -y, -z, -w);                                                        }
00085 
00087                 inline_ HPoint          operator+(const HPoint& p)                      const           { return HPoint(x + p.x, y + p.y, z + p.z, w + p.w);            }
00089                 inline_ HPoint          operator-(const HPoint& p)                      const           { return HPoint(x - p.x, y - p.y, z - p.z, w - p.w);            }
00090 
00092                 inline_ HPoint          operator*(const HPoint& p)                      const           { return HPoint(x * p.x, y * p.y, z * p.z, w * p.w);            }
00094                 inline_ HPoint          operator*(float s)                                      const           { return HPoint(x * s, y * s, z * s, w * s);                            }
00096                 inline_ friend  HPoint  operator*(float s, const HPoint& p)                     { return HPoint(s * p.x, s * p.y, s * p.z, s * p.w);            }
00097 
00099                 inline_ HPoint          operator/(const HPoint& p)                      const           { return HPoint(x / p.x, y / p.y, z / p.z, w / p.w);            }
00101                 inline_ HPoint          operator/(float s)                                      const           { s = 1.0f / s; return HPoint(x * s, y * s, z * s, w * s);      }
00103                 inline_ friend  HPoint  operator/(float s, const HPoint& p)                     { return HPoint(s / p.x, s / p.y, s / p.z, s / p.w);            }
00104 
00106                 inline_ float           operator|(const HPoint& p)                      const           { return x*p.x + y*p.y + z*p.z + w*p.w;                                         }
00107                 // No cross-product in 4D
00108 
00110                 inline_ HPoint&         operator+=(const HPoint& p)                                             { x += p.x; y += p.y; z += p.z; w += p.w;       return *this;   }
00112                 inline_ HPoint&         operator+=(float s)                                                             { x += s;   y += s;   z += s;   w += s;         return *this;   }
00113 
00115                 inline_ HPoint&         operator-=(const HPoint& p)                                             { x -= p.x; y -= p.y; z -= p.z; w -= p.w;       return *this;   }
00117                 inline_ HPoint&         operator-=(float s)                                                             { x -= s;   y -= s;   z -= s;   w -= s;         return *this;   }
00118 
00120                 inline_ HPoint&         operator*=(const HPoint& p)                                             { x *= p.x; y *= p.y; z *= p.z; w *= p.w;       return *this;   }
00122                 inline_ HPoint&         operator*=(float s)                                                             { x*=s; y*=s; z*=s; w*=s;                                       return *this;   }
00123 
00125                 inline_ HPoint&         operator/=(const HPoint& p)                                             { x /= p.x; y /= p.y; z /= p.z; w /= p.w;       return *this;   }
00127                 inline_ HPoint&         operator/=(float s)                                                             { s = 1.0f / s; x*=s; y*=s; z*=s; w*=s;         return *this;   }
00128 
00129                 // Arithmetic operators
00130 
00132                                 Point           operator*(const Matrix3x3& mat)         const;
00134                                 HPoint          operator*(const Matrix4x4& mat)         const;
00135 
00136                 // HPoint *= Matrix3x3 doesn't exist, the matrix is first casted to a 4x4
00138                                 HPoint&         operator*=(const Matrix4x4& mat);
00139 
00140                 // Logical operators
00141 
00143                 inline_ bool            operator==(const HPoint& p)                     const           { return ( (x==p.x)&&(y==p.y)&&(z==p.z)&&(w==p.w));                     }
00145                 inline_ bool            operator!=(const HPoint& p)                     const           { return ( (x!=p.x)||(y!=p.y)||(z!=p.z)||(w!=p.w));                     }
00146 
00147                 // Cast operators
00148 
00150 #ifdef _MSC_VER
00151                 inline_                         operator        Point()                                 const           { return Point(x, y, z);                                                                        }
00152                 // gcc complains that conversion to a base class will never use a type conversion operator
00153 #endif
00154 
00155                 public:
00156                                 float           w;
00157         };
00158 
00159 #endif // __ICEHPOINT_H__
00160 


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:16