[]Jimmy's World.org
Because you all make me very, very tired.
[]
Jimmy's World Games
Not a Member? - Login or Create an Account
[] Tuesday the 6th of January 2009 @ 01:09am
News Journal Creative Writing Projects Your JW About

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cBezier33.h

Go to the documentation of this file.
00001 /************************************************************************
00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library
00003 Copyright (C) 2002  Aaron Cameron
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018 
00019 A copy of the GNU Lesser General Public License has been provided with
00020 this library in the file 'COPYING'.
00021 
00022 Contact information for the author of this library has been provided
00023 with this library in the file 'AUTHOR'.
00024 ************************************************************************/
00025 
00026 /************************************************************************
00027 NOTICE #1
00028 Code in this class was taken from from the web.  I was unable to find
00029 any license information, so I've included the author and the source here:
00030 
00031 Bezier curves
00032 Written by Paul Bourke
00033 Original: April 1989, Updated: December 1996
00034 http://astronomy.swin.edu.au/~pbourke/curves/bezier/
00035 ************************************************************************/
00036 
00037 
00038 #ifndef _n2l4_cBezier33_h
00039 #define _n2l4_cBezier33_h
00040 
00041 namespace n2l
00042 {
00043 
00048     template <class TComponent, class TTime>
00049     class cBezier33
00050     {
00051     public:
00052         typedef cBezier33<TComponent,TTime>                 tThisCurve;
00053         typedef TComponent                                  tComponent;
00054         typedef cVector3<TComponent,TComponent,TComponent>  tVector;
00055         typedef TTime                                       tTime;
00056 
00057         // Constructors
00058         /* ************************************************************ */
00059         cBezier33()
00060         {
00061             mPoint[0].set(0,0,0);
00062             mPoint[1].set(0,0,0);
00063             mPoint[2].set(0,0,0);
00064         }
00065 
00066         /* ************************************************************ */
00067         cBezier33(  const tVector & iP0,
00068                     const tVector & iP1,
00069                     const tVector & iP2 )
00070         {
00071             mPoint[0] = iP0;
00072             mPoint[1] = iP1;
00073             mPoint[2] = iP2;
00074         }
00075 
00076         /* ************************************************************ */
00077         cBezier33( const tThisCurve & iCurve )
00078         {
00079             mPoint[0] = iCurve.mPoint[0];
00080             mPoint[1] = iCurve.mPoint[1];
00081             mPoint[2] = iCurve.mPoint[2];
00082         }
00083 
00084         /* ************************************************************ */
00085         const tVector pointAt( const tTime & iTime )
00086         {
00087             // See NOTICE #1 above
00088             tComponent mum1,mum12,mu2;
00089             tVector p;
00090 
00091             mu2 = iTime * iTime;
00092             mum1 = 1 - iTime;
00093             mum12 = mum1 * mum1;
00094             p.x( mPoint[0].x() * mum12 + 2 * mPoint[1].x() * mum1 * iTime + mPoint[2].x() * mu2 );
00095             p.y( mPoint[0].y() * mum12 + 2 * mPoint[1].y() * mum1 * iTime + mPoint[2].y() * mu2 );
00096             p.z( mPoint[0].z() * mum12 + 2 * mPoint[1].z() * mum1 * iTime + mPoint[2].z() * mu2 );
00097 
00098             return p;
00099         }
00100 
00101     private:
00102         tVector mPoint[3];
00103 
00104     }; // class
00105 
00106 } // namespace n2l
00107 
00108 
00109 
00110 #endif
©2009 Aaron Cameron
Benchmarks