interval_vector.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2011, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00038 #ifndef FCL_CCD_INTERVAL_VECTOR_H
00039 #define FCL_CCD_INTERVAL_VECTOR_H
00040 
00041 #include "fcl/ccd/interval.h"
00042 #include "fcl/math/vec_3f.h"
00043 
00044 namespace fcl
00045 {
00046 
00047 struct IVector3
00048 {
00049   Interval i_[3];
00050 
00051   IVector3();
00052   IVector3(FCL_REAL v);
00053   IVector3(FCL_REAL x, FCL_REAL y, FCL_REAL z);
00054   IVector3(FCL_REAL xl, FCL_REAL xu, FCL_REAL yl, FCL_REAL yu, FCL_REAL zl, FCL_REAL zu);
00055   IVector3(Interval v[3]);
00056   IVector3(FCL_REAL v[3][2]);
00057   IVector3(const Interval& v1, const Interval& v2, const Interval& v3);
00058   IVector3(const Vec3f& v);
00059 
00060   inline void setValue(FCL_REAL v)
00061   {
00062     i_[0].setValue(v);
00063     i_[1].setValue(v);
00064     i_[2].setValue(v);
00065   }
00066 
00067   inline void setValue(FCL_REAL x, FCL_REAL y, FCL_REAL z)
00068   {
00069     i_[0].setValue(x);
00070     i_[1].setValue(y);
00071     i_[2].setValue(z);
00072   }
00073 
00074   inline void setValue(FCL_REAL xl, FCL_REAL xu, FCL_REAL yl, FCL_REAL yu, FCL_REAL zl, FCL_REAL zu)
00075   {
00076     i_[0].setValue(xl, xu);
00077     i_[1].setValue(yl, yu);
00078     i_[2].setValue(zl, zu);
00079   }
00080 
00081   inline void setValue(FCL_REAL v[3][2])
00082   {
00083     i_[0].setValue(v[0][0], v[0][1]);
00084     i_[1].setValue(v[1][0], v[1][1]);
00085     i_[2].setValue(v[2][0], v[2][1]);
00086   }
00087 
00088   inline void setValue(Interval v[3])
00089   {
00090     i_[0] = v[0];
00091     i_[1] = v[1];
00092     i_[2] = v[2];
00093   }
00094 
00095   inline void setValue(const Interval& v1, const Interval& v2, const Interval& v3)
00096   {
00097     i_[0] = v1;
00098     i_[1] = v2;
00099     i_[2] = v3;
00100   }
00101 
00102   inline void setValue(const Vec3f& v)
00103   {
00104     i_[0].setValue(v[0]);
00105     i_[1].setValue(v[1]);
00106     i_[2].setValue(v[2]);
00107   }
00108 
00109   inline void setValue(FCL_REAL v[3])
00110   {
00111     i_[0].setValue(v[0]);
00112     i_[1].setValue(v[1]);
00113     i_[2].setValue(v[2]);
00114   }
00115   
00116   IVector3 operator + (const IVector3& other) const;
00117   IVector3& operator += (const IVector3& other);
00118 
00119   IVector3 operator - (const IVector3& other) const;
00120   IVector3& operator -= (const IVector3& other);
00121 
00122   Interval dot(const IVector3& other) const;
00123   IVector3 cross(const IVector3& other) const;
00124 
00125   Interval dot(const Vec3f& other) const;
00126   IVector3 cross(const Vec3f& other) const;
00127 
00128   inline const Interval& operator [] (size_t i) const
00129   {
00130     return i_[i];
00131   }
00132 
00133   inline Interval& operator [] (size_t i)
00134   {
00135     return i_[i];
00136   }
00137 
00138   inline Vec3f getLow() const 
00139   {
00140     return Vec3f(i_[0][0], i_[1][0], i_[2][0]);
00141   }
00142   
00143   inline Vec3f getHigh() const
00144   {
00145     return Vec3f(i_[0][1], i_[1][1], i_[2][1]);
00146   }
00147 
00148   void print() const;
00149   Vec3f center() const;
00150   FCL_REAL volumn() const;
00151   void setZero();
00152 
00153   void bound(const Vec3f& v);
00154   void bound(const IVector3& v);
00155 
00156   bool overlap(const IVector3& v) const;
00157   bool contain(const IVector3& v) const;
00158 };
00159 
00160 IVector3 bound(const IVector3& i, const Vec3f& v);
00161 
00162 IVector3 bound(const IVector3& i, const IVector3& v);
00163 
00164 }
00165 
00166 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


fcl
Author(s): Jia Pan
autogenerated on Tue Jan 15 2013 16:05:30