Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 /*======================================================================== 00003 path.h : Template for building spline paths 00004 ------------------------------------------------------------------------ 00005 Copyright (C) 1999-2002 James R. Bruce 00006 School of Computer Science, Carnegie Mellon University 00007 ------------------------------------------------------------------------ 00008 This software is distributed under the GNU General Public License, 00009 version 2. If you do not have a copy of this licence, visit 00010 www.gnu.org, or write: Free Software Foundation, 59 Temple Place, 00011 Suite 330 Boston, MA 02111-1307 USA. This program is distributed 00012 in the hope that it will be useful, but WITHOUT ANY WARRANTY, 00013 including MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00014 ========================================================================*/ 00015 00016 #ifndef __SPLINE_PATH_H__ 00017 #define __SPLINE_PATH_H__ 00018 00019 #include "Shared/Util.h" 00020 #include "Spline.h" 00021 00022 #define SPATH SplinePath<point,fnum> 00023 #define SPATH_TEM template <class point,class fnum> 00024 00025 SPATH_TEM 00026 class SplinePath{ 00027 NonUniformHermiteSplineSegment<point,fnum> s; 00028 double t0,t1; 00029 point x0,x1,dx0,dx1; 00030 public: 00031 SplinePath() : s(), t0(), t1(), x0(),x1(),dx0(),dx1() {} 00032 void init(point x,point dx); 00033 void add(point x,point dx,double length,double t); 00034 00035 point eval(double t); 00036 point eval_deriv(double t); 00037 }; 00038 00039 00040 //==== Spline Path Queue Implementation ====// 00041 00042 SPATH_TEM 00043 void SPATH::init(point x,point dx) 00044 { 00045 x0 = x1 = x; 00046 dx0 = dx1 = dx; 00047 t0 = t1 = 0; 00048 } 00049 00050 SPATH_TEM 00051 void SPATH::add(point x,point dx,double length,double t) 00052 { 00053 x0 = eval(t); 00054 dx0 = eval_deriv(t); 00055 00056 x1 = x; 00057 dx1 = dx; 00058 00059 t0 = t; 00060 t1 = t + length; 00061 00062 s.create(x0,x1,dx0,dx1,length); 00063 } 00064 00065 SPATH_TEM 00066 point SPATH::eval(double t) 00067 { 00068 if(t < t0){ 00069 return(x0 + dx0*(t-t0)); 00070 }else if(t >= t1){ 00071 return(x1 + dx1*(t-t1)); 00072 }else{ 00073 return(s.eval(t - t0)); 00074 } 00075 } 00076 00077 SPATH_TEM 00078 point SPATH::eval_deriv(double t) 00079 { 00080 if(t < t0){ 00081 return(dx0); 00082 }else if(t >= t1){ 00083 return(dx1); 00084 }else{ 00085 return(s.eval_deriv(t - t0)); 00086 } 00087 } 00088 00089 /*! @file 00090 * @brief Performs calculations regarding splines for path execution 00091 * @author James R. Bruce (Creator) 00092 * 00093 * @verbatim 00094 ======================================================================== 00095 path.h : Template for building spline paths 00096 ------------------------------------------------------------------------ 00097 Copyright (C) 1999-2002 James R. Bruce 00098 School of Computer Science, Carnegie Mellon University 00099 ------------------------------------------------------------------------ 00100 This software is distributed under the GNU General Public License, 00101 version 2. If you do not have a copy of this licence, visit 00102 www.gnu.org, or write: Free Software Foundation, 59 Temple Place, 00103 Suite 330 Boston, MA 02111-1307 USA. This program is distributed 00104 in the hope that it will be useful, but WITHOUT ANY WARRANTY, 00105 including MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00106 ======================================================================== 00107 * @endverbatim 00108 * 00109 * $Author: ejt $ 00110 * $Name: tekkotsu-1_4_1 $ 00111 * $Revision: 1.4 $ 00112 * $State: Exp $ 00113 * $Date: 2003/01/23 18:14:04 $ 00114 */ 00115 00116 #endif 00117 // __SPLINE_PATH_H__
Tekkotsu v1.4 |
Generated Sat Jul 19 00:06:31 2003 by Doxygen 1.3.2 |