opal-commits Mailing List for Open Physics Abstraction Layer (Page 6)
Status: Inactive
Brought to you by:
tylerstreeter
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
(162) |
Mar
(134) |
Apr
(113) |
May
(13) |
Jun
(60) |
Jul
(18) |
Aug
(25) |
Sep
|
Oct
(2) |
Nov
(35) |
Dec
(76) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(3) |
Apr
(8) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
(1) |
Mar
(12) |
Apr
(16) |
May
(2) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
|
Nov
|
Dec
(3) |
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(15) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Olex <ole...@us...> - 2005-12-07 00:44:57
|
Update of /cvsroot/opal/opal/kdevelop In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19716/kdevelop Modified Files: opal.kdevelop Log Message: Fixed some warnings. Index: opal.kdevelop =================================================================== RCS file: /cvsroot/opal/opal/kdevelop/opal.kdevelop,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** opal.kdevelop 2 Dec 2005 05:47:20 -0000 1.5 --- opal.kdevelop 7 Dec 2005 00:44:49 -0000 1.6 *************** *** 14,18 **** <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description></description> <versioncontrol/> </general> --- 14,18 ---- <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description/> <versioncontrol/> </general> *************** *** 48,63 **** <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> ! <cxxflags>-O0 -g3 -Wall</cxxflags> <envvars> <envvar value="ccache g++" name="CXX" /> </envvars> ! <topsourcedir></topsourcedir> ! <cppflags></cppflags> <ldflags>-lode</ldflags> ! <ccompilerbinary></ccompilerbinary> ! <cxxcompilerbinary></cxxcompilerbinary> ! <f77compilerbinary></f77compilerbinary> ! <cflags></cflags> ! <f77flags></f77flags> </debug> </configurations> --- 48,63 ---- <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> ! <cxxflags>-O0 -g3 -Wall --pedantic</cxxflags> <envvars> <envvar value="ccache g++" name="CXX" /> </envvars> ! <topsourcedir/> ! <cppflags/> <ldflags>-lode</ldflags> ! <ccompilerbinary/> ! <cxxcompilerbinary/> ! <f77compilerbinary/> ! <cflags/> ! <f77flags/> </debug> </configurations> *************** *** 173,177 **** </codecompletion> <creategettersetter> ! <prefixGet></prefixGet> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> --- 173,177 ---- </codecompletion> <creategettersetter> ! <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> *************** *** 194,203 **** <kdevdebugger> <general> ! <programargs></programargs> ! <gdbpath></gdbpath> ! <dbgshell></dbgshell> ! <configGdbScript></configGdbScript> ! <runShellScript></runShellScript> ! <runGdbScript></runGdbScript> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> --- 194,203 ---- <kdevdebugger> <general> ! <programargs/> ! <gdbpath/> ! <dbgshell/> ! <configGdbScript/> ! <runShellScript/> ! <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> |
|
From: Olex <ole...@us...> - 2005-12-07 00:44:57
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19716/src Modified Files: Defines.h Log Message: Fixed some warnings. Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** Defines.h 1 Dec 2005 02:04:54 -0000 1.79 --- Defines.h 7 Dec 2005 00:44:49 -0000 1.80 *************** *** 243,247 **** /// The highest value that can be used for the Simulator's /// max contacts parameter. ! const unsigned int maxMaxContacts=(int)128; // Pre-defined material settings --- 243,247 ---- /// The highest value that can be used for the Simulator's /// max contacts parameter. ! const unsigned int maxMaxContacts = 128; // Pre-defined material settings |
|
From: Olex <ole...@us...> - 2005-12-07 00:44:57
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19716 Modified Files: changelog.txt Log Message: Fixed some warnings. Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** changelog.txt 2 Dec 2005 05:47:20 -0000 1.57 --- changelog.txt 7 Dec 2005 00:44:49 -0000 1.58 *************** *** 15,18 **** --- 15,20 ---- ------------------------------------------ + * 12-6-05: Fixed some warnings. (Oleksandr Lozitskiy) + * 12-2-05: Fixes in ServoMotor, Vec3r to handle float point errors. Updated unit test framework. (Oleksandr Lozitskiy) |
|
From: Olex <ole...@us...> - 2005-12-04 16:41:06
|
Update of /cvsroot/opal/opal/vc8 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22357/vc8 Modified Files: opal-ode.vcproj Log Message: Removed user-specific directories. Index: opal-ode.vcproj =================================================================== RCS file: /cvsroot/opal/opal/vc8/opal-ode.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** opal-ode.vcproj 4 Dec 2005 03:27:11 -0000 1.3 --- opal-ode.vcproj 4 Dec 2005 16:40:55 -0000 1.4 *************** *** 45,50 **** EnableIntrinsicFunctions="false" FavorSizeOrSpeed="0" ! AdditionalIncludeDirectories=""C:\Olex\work\ode-0.5\include"" ! PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPAL_DLL_EXPORTING" MinimalRebuild="true" BasicRuntimeChecks="0" --- 45,50 ---- EnableIntrinsicFunctions="false" FavorSizeOrSpeed="0" ! AdditionalIncludeDirectories="" ! PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPAL_DLL_EXPORTING;OPAL_USE_DOUBLE" MinimalRebuild="true" BasicRuntimeChecks="0" *************** *** 125,130 **** EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" ! AdditionalIncludeDirectories=""C:\Olex\work\ode-0.5\include"" ! PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPAL_DLL_EXPORTING" RuntimeLibrary="2" UsePrecompiledHeader="0" --- 125,130 ---- EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" ! AdditionalIncludeDirectories="" ! PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPAL_DLL_EXPORTING;OPAL_USE_DOUBLE" RuntimeLibrary="2" UsePrecompiledHeader="0" |
|
From: Olex <ole...@us...> - 2005-12-04 03:27:20
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31572/src Modified Files: Mass.h Point3r.h Quaternion.h Vec3r.cpp Vec3r.h testQuaternion.cpp testVec3r.cpp Log Message: Updated vc8 project files. MSVC fixes. Index: Vec3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Vec3r.h 30 Nov 2005 06:28:12 -0000 1.18 --- Vec3r.h 4 Dec 2005 03:27:11 -0000 1.19 *************** *** 31,34 **** --- 31,35 ---- // project headers #include "OpalMath.h" + #include "Portability.h" // system headers *************** *** 63,67 **** /// Returns true if the two vectors are roughly collinear. ! bool areCollinear( const Vec3r& u, const Vec3r& v ); /// Prints the Vec3r to the given output stream. --- 64,68 ---- /// Returns true if the two vectors are roughly collinear. ! inline bool areCollinear( const Vec3r& u, const Vec3r& v ); /// Prints the Vec3r to the given output stream. *************** *** 81,125 **** /// default - (0,0,0) ! Vec3r(); ! Vec3r( const Vec3r & src ); ! Vec3r( real xx, real yy, real zz ); ! Vec3r( const real * data ); ! void set( real xx, real yy, real zz ); ! void set( real * data ); ! real & operator[] ( unsigned int i ); ! const real & operator[] ( unsigned int i ) const; ! real lengthSquared() const; ! real length() const; ! void normalize(); ! Vec3r unit() const; ! void operator+=( const Vec3r & v ); ! void operator-=( const Vec3r & v ); ! void operator*=( const Vec3r & v ); ! void operator*=( real scalar ); ! void operator/=( real scalar ); ! void operator/=( const Vec3r & v ); ! bool operator==( const Vec3r & v ); ! bool operator!=( const Vec3r & v ); ! void operator=( const Vec3r & v ); }; --- 82,126 ---- /// default - (0,0,0) ! OPAL_DECL Vec3r(); ! OPAL_DECL Vec3r( const Vec3r & src ); ! OPAL_DECL Vec3r( real xx, real yy, real zz ); ! OPAL_DECL Vec3r( const real * data ); ! OPAL_DECL void OPAL_CALL set( real xx, real yy, real zz ); ! OPAL_DECL void OPAL_CALL set( real * data ); ! OPAL_DECL real & OPAL_CALL operator[] ( unsigned int i ); ! OPAL_DECL const real & OPAL_CALL operator[] ( unsigned int i ) const; ! OPAL_DECL real OPAL_CALL lengthSquared() const; ! OPAL_DECL real OPAL_CALL length() const; ! OPAL_DECL void OPAL_CALL normalize(); ! OPAL_DECL Vec3r OPAL_CALL unit() const; ! OPAL_DECL void OPAL_CALL operator+=( const Vec3r & v ); ! OPAL_DECL void OPAL_CALL operator-=( const Vec3r & v ); ! OPAL_DECL void OPAL_CALL operator*=( const Vec3r & v ); ! OPAL_DECL void OPAL_CALL operator*=( real scalar ); ! OPAL_DECL void OPAL_CALL operator/=( real scalar ); ! OPAL_DECL void OPAL_CALL operator/=( const Vec3r & v ); ! OPAL_DECL bool OPAL_CALL operator==( const Vec3r & v ); ! OPAL_DECL bool OPAL_CALL operator!=( const Vec3r & v ); ! OPAL_DECL void OPAL_CALL operator=( const Vec3r & v ); }; *************** *** 212,215 **** --- 213,230 ---- { return o << "[" << v.x << " " << v.y << " " << v.z << "]"; + } + + bool areCollinear( const Vec3r & u, const Vec3r & v ) + { + Vec3r a = u, b = v; + a.normalize(); + b.normalize(); + + if ( areEqual( a.x, b.x ) && areEqual( a.y, b.y ) && areEqual( a.z, b.z ) ) + return true; + if ( areEqual( a.x, -b.x ) && areEqual( a.y, -b.y ) && areEqual( a.z, -b.z ) ) + return true; + + return false; } } Index: Vec3r.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Vec3r.cpp 2 Dec 2005 05:47:21 -0000 1.3 --- Vec3r.cpp 4 Dec 2005 03:27:11 -0000 1.4 *************** *** 191,207 **** return ( !areEqual( x, v.x ) || !areEqual( y , v.y ) || !areEqual( z , v.z ) ); } - - bool areCollinear( const Vec3r & u, const Vec3r & v ) - { - Vec3r a = u, b = v; - a.normalize(); - b.normalize(); - - if ( areEqual( a.x, b.x ) && areEqual( a.y, b.y ) && areEqual( a.z, b.z ) ) - return true; - if ( areEqual( a.x, -b.x ) && areEqual( a.y, -b.y ) && areEqual( a.z, -b.z ) ) - return true; - - return false; - } } --- 191,193 ---- Index: testQuaternion.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testQuaternion.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testQuaternion.cpp 1 Dec 2005 23:55:21 -0000 1.3 --- testQuaternion.cpp 4 Dec 2005 03:27:11 -0000 1.4 *************** *** 148,154 **** QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).length(), 0 ); QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).length(), 1 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).length(), sqrt( 5 ) ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).length(), sqrt( 14 ) ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).length(), sqrt( 30 ) ); } --- 148,154 ---- QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).length(), 0 ); QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).length(), 1 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).length(), sqrt( 5.0 ) ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).length(), sqrt( 14.0 ) ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).length(), sqrt( 30.0 ) ); } *************** *** 169,173 **** q.set( 1, 0, 0, 1 ); q.normalize(); ! QT_CHECK_EQUAL( q, Quaternion( sqrt( 2 ) / 2.0, 0, 0, sqrt( 2 ) / 2.0 ) ); } --- 169,173 ---- q.set( 1, 0, 0, 1 ); q.normalize(); ! QT_CHECK_EQUAL( q, Quaternion( sqrt( 2.0 ) / 2.0, 0, 0, sqrt( 2.0 ) / 2.0 ) ); } Index: Mass.h =================================================================== RCS file: /cvsroot/opal/opal/src/Mass.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Mass.h 1 Dec 2005 02:04:54 -0000 1.1 --- Mass.h 4 Dec 2005 03:27:11 -0000 1.2 *************** *** 46,52 **** center = Vec3r( 0, 0, 0 ); inertia.makeIdentity(); ! inertia[ 0 ] = 1 / 6.0; ! inertia[ 5 ] = 1 / 6.0; ! inertia[ 10 ] = 1 / 6.0; } --- 46,52 ---- center = Vec3r( 0, 0, 0 ); inertia.makeIdentity(); ! inertia[ 0 ] = static_cast<real>( 1 / 6.0 ); ! inertia[ 5 ] = static_cast<real>( 1 / 6.0 ); ! inertia[ 10 ] = static_cast<real>( 1 / 6.0 ); } Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Quaternion.h 1 Dec 2005 23:55:21 -0000 1.12 --- Quaternion.h 4 Dec 2005 03:27:11 -0000 1.13 *************** *** 31,34 **** --- 31,35 ---- // project headers #include "OpalMath.h" + #include "Portability.h" // system headers *************** *** 47,86 **** real z; ! Quaternion(); ! Quaternion( real ww, real xx, real yy, real zz ); ! Quaternion( const Quaternion& src ); ! void set( real ww, real xx, real yy, real zz ); ! real lengthSquared() const; ! real length() const; ! void normalize(); ! void getAngleAxis( real& angle, Vec3r& axis ) const; ! real getRoll() const; ! real getPitch() const; ! real getYaw() const ; ! real & operator[] ( unsigned int i ); ! const real & operator[] ( unsigned int i ) const; }; ! Quaternion operator+( const Quaternion &q1, const Quaternion &q2 ); ! Quaternion operator-( const Quaternion &q1, const Quaternion &q2 ); ! Quaternion operator*( const Quaternion& q, real scalar ); ! Quaternion operator*( real scalar, const Quaternion& q ); ! bool operator==( const Quaternion &q1, const Quaternion &q2 ); ! bool operator!=( const Quaternion &q1, const Quaternion &q2 ); /// Prints the Quaternion to the given output stream. ! std::ostream & operator<<( std::ostream& o, const Quaternion& q ); } --- 48,87 ---- real z; ! OPAL_DECL Quaternion(); ! OPAL_DECL Quaternion( real ww, real xx, real yy, real zz ); ! OPAL_DECL Quaternion( const Quaternion& src ); ! OPAL_DECL void OPAL_CALL set( real ww, real xx, real yy, real zz ); ! OPAL_DECL real OPAL_CALL lengthSquared() const; ! OPAL_DECL real OPAL_CALL length() const; ! OPAL_DECL void OPAL_CALL normalize(); ! OPAL_DECL void OPAL_CALL getAngleAxis( real& angle, Vec3r& axis ) const; ! OPAL_DECL real OPAL_CALL getRoll() const; ! OPAL_DECL real OPAL_CALL getPitch() const; ! OPAL_DECL real OPAL_CALL getYaw() const; ! OPAL_DECL real & OPAL_CALL operator[] ( unsigned int i ); ! OPAL_DECL const real & OPAL_CALL operator[] ( unsigned int i ) const; }; ! OPAL_DECL Quaternion operator+( const Quaternion &q1, const Quaternion &q2 ); ! OPAL_DECL Quaternion operator-( const Quaternion &q1, const Quaternion &q2 ); ! OPAL_DECL Quaternion operator*( const Quaternion& q, real scalar ); ! OPAL_DECL Quaternion operator*( real scalar, const Quaternion& q ); ! OPAL_DECL bool operator==( const Quaternion &q1, const Quaternion &q2 ); ! OPAL_DECL bool operator!=( const Quaternion &q1, const Quaternion &q2 ); /// Prints the Quaternion to the given output stream. ! OPAL_DECL std::ostream & operator<<( std::ostream& o, const Quaternion& q ); } Index: Point3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Point3r.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Point3r.h 1 Dec 2005 02:04:54 -0000 1.15 --- Point3r.h 4 Dec 2005 03:27:11 -0000 1.16 *************** *** 29,35 **** --- 29,39 ---- #define OPAL_POINT3R_H + // project headers #include "OpalMath.h" #include "Vec3r.h" + // systeam headers + #include <cassert> + namespace opal { Index: testVec3r.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testVec3r.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testVec3r.cpp 2 Dec 2005 05:47:21 -0000 1.3 --- testVec3r.cpp 4 Dec 2005 03:27:11 -0000 1.4 *************** *** 123,127 **** { Vec3r v( 1, 2, 3 ); ! QT_CHECK_CLOSE( v.length(), sqrt( 1 + 4 + 9 ) ); } --- 123,127 ---- { Vec3r v( 1, 2, 3 ); ! QT_CHECK_CLOSE( v.length(), sqrt( 1 + 4 + 9.0 ) ); } *************** *** 129,133 **** { Vec3r v( -1, -2, -3 ); ! QT_CHECK_CLOSE( v.length(), sqrt( 1 + 4 + 9 ) ); } --- 129,133 ---- { Vec3r v( -1, -2, -3 ); ! QT_CHECK_CLOSE( v.length(), sqrt( 1 + 4 + 9.0 ) ); } |
|
From: Olex <ole...@us...> - 2005-12-04 03:27:19
|
Update of /cvsroot/opal/opal/src/external/quicktest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31572/src/external/quicktest Modified Files: quicktest.h Log Message: Updated vc8 project files. MSVC fixes. Index: quicktest.h =================================================================== RCS file: /cvsroot/opal/opal/src/external/quicktest/quicktest.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** quicktest.h 2 Dec 2005 05:47:21 -0000 1.6 --- quicktest.h 4 Dec 2005 03:27:11 -0000 1.7 *************** *** 1,386 **** ! /************************************************************************* ! * * ! * QuickTest * ! * Copyright (C) 2005 * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: quicktest.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * [...996 lines suppressed...] ! ! #define QT_FAIL(message)\ ! {\ ! recordFailure(_result, __FILE__, __LINE__, (message));\ ! return;\ ! }\ ! ! ! ! /// Prints the given message, followed by a carriage return. ! ! #define QT_PRINT(message)\ ! {\ ! *(quicktest::TestManager::instance().getOutputStream()) << (message)\ ! << std::endl;\ ! }\ ! ! ! #endif ! |
|
From: Olex <ole...@us...> - 2005-12-04 03:27:19
|
Update of /cvsroot/opal/opal/vc8 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31572/vc8 Modified Files: opal-ode.vcproj opal.sln Log Message: Updated vc8 project files. MSVC fixes. Index: opal-ode.vcproj =================================================================== RCS file: /cvsroot/opal/opal/vc8/opal-ode.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** opal-ode.vcproj 19 Oct 2005 22:16:58 -0000 1.2 --- opal-ode.vcproj 4 Dec 2005 03:27:11 -0000 1.3 *************** *** 7,11 **** RootNamespace="opal-ode" Keyword="Win32Proj" - SignManifests="true" > <Platforms> --- 7,10 ---- *************** *** 46,50 **** EnableIntrinsicFunctions="false" FavorSizeOrSpeed="0" ! AdditionalIncludeDirectories="" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPAL_DLL_EXPORTING" MinimalRebuild="true" --- 45,49 ---- EnableIntrinsicFunctions="false" FavorSizeOrSpeed="0" ! AdditionalIncludeDirectories=""C:\Olex\work\ode-0.5\include"" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPAL_DLL_EXPORTING" MinimalRebuild="true" *************** *** 67,72 **** <Tool Name="VCLinkerTool" ! AdditionalDependencies="ode_d.lib" OutputFile="$(OutDir)/opal-ode_d.dll" IgnoreDefaultLibraryNames="libcmt" GenerateDebugInformation="true" --- 66,72 ---- <Tool Name="VCLinkerTool" ! AdditionalDependencies="oded.lib OPCODE_d.lib" OutputFile="$(OutDir)/opal-ode_d.dll" + AdditionalLibraryDirectories="C:\Olex\work\ode-0.5\lib" IgnoreDefaultLibraryNames="libcmt" GenerateDebugInformation="true" *************** *** 125,129 **** EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" ! AdditionalIncludeDirectories="" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPAL_DLL_EXPORTING" RuntimeLibrary="2" --- 125,129 ---- EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" ! AdditionalIncludeDirectories=""C:\Olex\work\ode-0.5\include"" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPAL_DLL_EXPORTING" RuntimeLibrary="2" *************** *** 144,149 **** <Tool Name="VCLinkerTool" ! AdditionalDependencies="ode.lib" OutputFile="$(OutDir)/opal-ode.dll" IgnoreDefaultLibraryNames="libcmt" OptimizeReferences="2" --- 144,150 ---- <Tool Name="VCLinkerTool" ! AdditionalDependencies="ode.lib OPCODE.lib" OutputFile="$(OutDir)/opal-ode.dll" + AdditionalLibraryDirectories=""C:\Olex\work\ode-0.5\lib"" IgnoreDefaultLibraryNames="libcmt" OptimizeReferences="2" *************** *** 227,230 **** --- 228,239 ---- </File> <File + RelativePath="..\src\Point3r.cpp" + > + </File> + <File + RelativePath="..\src\Quaternion.cpp" + > + </File> + <File RelativePath="..\src\RaycastSensor.cpp" > *************** *** 263,266 **** --- 272,279 ---- </File> <File + RelativePath="..\src\Vec3r.cpp" + > + </File> + <File RelativePath="..\src\VolumeSensor.cpp" > *************** *** 351,354 **** --- 364,371 ---- </File> <File + RelativePath="..\src\Mass.h" + > + </File> + <File RelativePath="..\src\MeshShapeData.h" > Index: opal.sln =================================================================== RCS file: /cvsroot/opal/opal/vc8/opal.sln,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** opal.sln 16 Aug 2005 08:28:21 -0000 1.1 --- opal.sln 4 Dec 2005 03:27:11 -0000 1.2 *************** *** 3,6 **** --- 3,11 ---- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opal-ode", "opal-ode.vcproj", "{312196D4-105B-4444-A33A-2ECE3C7D6D64}" EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittests", "..\unittests\unittests.vcproj", "{A211B4F7-11A8-4392-9934-ABAE5B31BDA8}" + ProjectSection(ProjectDependencies) = postProject + {312196D4-105B-4444-A33A-2ECE3C7D6D64} = {312196D4-105B-4444-A33A-2ECE3C7D6D64} + EndProjectSection + EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution *************** *** 13,16 **** --- 18,25 ---- {312196D4-105B-4444-A33A-2ECE3C7D6D64}.Release|Win32.ActiveCfg = Release|Win32 {312196D4-105B-4444-A33A-2ECE3C7D6D64}.Release|Win32.Build.0 = Release|Win32 + {A211B4F7-11A8-4392-9934-ABAE5B31BDA8}.Debug|Win32.ActiveCfg = Debug|Win32 + {A211B4F7-11A8-4392-9934-ABAE5B31BDA8}.Debug|Win32.Build.0 = Debug|Win32 + {A211B4F7-11A8-4392-9934-ABAE5B31BDA8}.Release|Win32.ActiveCfg = Release|Win32 + {A211B4F7-11A8-4392-9934-ABAE5B31BDA8}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution |
|
From: Olex <ole...@us...> - 2005-12-02 05:47:29
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26719/src Modified Files: ServoMotor.cpp ServoMotor.h Vec3r.cpp testMatrix44r.cpp testVec3r.cpp Log Message: Fixes in ServoMotor, Vec3r to handle float point errors. Updated unit test framework. Index: ServoMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotor.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ServoMotor.cpp 26 Jun 2005 16:57:35 -0000 1.18 --- ServoMotor.cpp 2 Dec 2005 05:47:21 -0000 1.19 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "ServoMotor.h" --- 1,28 ---- /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "ServoMotor.h" *************** *** 30,231 **** namespace opal { ! ServoMotor::ServoMotor() ! : Motor() ! { ! // "mData" will be initialized in its own constructor. ! } ! ServoMotor::~ServoMotor() ! { ! // We must set the Joint's desired vel and max force to 0 since ! // this Motor won't apply to it anymore. This is only necessary ! // if this Motor is enabled. ! if (mData.enabled && mData.joint) ! { ! mData.joint->internal_setDesiredVel(mData.jointAxisNum, 0); ! mData.joint->internal_setMaxTorque(mData.jointAxisNum, 0); ! } ! } ! void ServoMotor::init(const ServoMotorData& data) ! { ! if (mInitCalled) ! { ! // If the Servo is already in operation, we first need to ! // set the old Joint's desired vel and max force to 0. The ! // following function call will automatically handle this ! // when set to false. ! setEnabled(false); ! } ! assert(data.joint); ! assert(data.jointAxisNum >= 0 && ! data.jointAxisNum < data.joint->getNumAxes()); ! Motor::init(); ! assert(data.joint->isRotational(data.jointAxisNum)); ! mData = data; ! setEnabled(mData.enabled); ! } ! const ServoMotorData& ServoMotor::getData()const ! { ! return mData; ! } ! MotorType ServoMotor::getType()const ! { ! return mData.getType(); ! } ! void ServoMotor::setName(const std::string& name) ! { ! mData.name = name; ! } ! const std::string& ServoMotor::getName()const ! { ! return mData.name; ! } ! bool ServoMotor::isEnabled()const ! { ! return mData.enabled; ! } ! void ServoMotor::setEnabled(bool e) ! { ! //if (!mInitCalled) ! //{ ! // return; ! //} ! mData.enabled = e; ! if (mData.joint) ! { ! if (e) ! { ! mData.joint->internal_setDesiredVel(mData.jointAxisNum, ! mData.desiredVel); ! mData.joint->internal_setMaxTorque(mData.jointAxisNum, ! mData.maxTorque); ! } ! else ! { ! mData.joint->internal_setDesiredVel(mData.jointAxisNum, 0); ! mData.joint->internal_setMaxTorque(mData.jointAxisNum, 0); ! } ! } ! } ! void ServoMotor::internal_update() ! { ! if (mData.enabled && mData.joint) ! { ! // Make sure both Solids are awake at this point. ! mData.joint->wakeSolids(); ! if (DESIRED_ANGLE_MODE == mData.mode) ! { ! // No longer support linear degrees of freedom. ! //if (true == mData.joint->isRotational(mData.jointAxisNum)) ! //{ ! real velocity = mData.desiredAngle - ! mData.joint->getAngle(mData.jointAxisNum); ! if ( velocity > 180.0 ) ! velocity = -360 + velocity; ! if ( velocity < -180.0 ) ! velocity = 360 + velocity; ! mData.joint->internal_setDesiredVel(mData.jointAxisNum, ! mData.restoreSpeed * velocity); ! //} ! //else ! //{ ! // // This axis must be a linear degree of freedom. ! // real velocity = mData.desiredPos - ! // mData.joint->getState(mData.jointAxisNum); ! // mData.joint->internal_setDesiredVel(mData.jointAxisNum, ! // mData.restoreSpeed * velocity); ! //} ! } ! else ! { ! // Nothing to do for desired velocity mode; the Joint's ! // desired velocity should already handle this. ! } ! } ! } ! void ServoMotor::setDesiredAngle(real a) ! { ! assert(a >= mData.joint->getLowLimit(mData.jointAxisNum) ! && a <= mData.joint->getHighLimit(mData.jointAxisNum)); ! mData.desiredAngle = a; ! } ! void ServoMotor::setDesiredAngleNorm(real a) ! { ! assert(a >= 0.0 && a <= 1.0); ! real lowLimit = mData.joint->getLowLimit(mData.jointAxisNum); ! real highLimit = mData.joint->getHighLimit(mData.jointAxisNum); ! // map the pos value onto the joint limits ! mData.desiredAngle = a * (highLimit - lowLimit) + lowLimit; ! // Keep desired angle slightly away from the limit to avoid jitter. ! // TODO: fix this; this should just keep the thing away from the ! // limit when it's close, not all the time. ! mData.desiredAngle *= (real)0.99; ! } ! real ServoMotor::getDesiredAngle()const ! { ! return mData.desiredAngle; ! } ! void ServoMotor::setDesiredVel(real vel) ! { ! mData.desiredVel = vel; ! mData.joint->internal_setDesiredVel(mData.jointAxisNum, vel); ! } ! real ServoMotor::getDesiredVel()const ! { ! return mData.desiredVel; ! } ! void ServoMotor::setMaxTorque(real max) ! { ! mData.maxTorque = max; ! mData.joint->internal_setMaxTorque(mData.jointAxisNum, max); ! } ! real ServoMotor::getMaxTorque()const ! { ! return mData.maxTorque; ! } ! void ServoMotor::setRestoreSpeed(real speed) ! { ! mData.restoreSpeed = speed; ! } ! real ServoMotor::getRestoreSpeed()const ! { ! return mData.restoreSpeed; ! } ! bool ServoMotor::internal_dependsOnJoint(Joint* j) ! { ! if (j == mData.joint) ! { ! return true; ! } ! else ! { ! return false; ! } ! } } --- 30,244 ---- namespace opal { ! ServoMotor::ServoMotor() ! : Motor() ! { ! // "mData" will be initialized in its own constructor. ! } ! ServoMotor::~ServoMotor() ! { ! // We must set the Joint's desired vel and max force to 0 since ! // this Motor won't apply to it anymore. This is only necessary ! // if this Motor is enabled. ! if ( mData.enabled && mData.joint ) ! { ! mData.joint->internal_setDesiredVel( mData.jointAxisNum, 0 ); ! mData.joint->internal_setMaxTorque( mData.jointAxisNum, 0 ); ! } ! } ! void ServoMotor::init( const ServoMotorData& data ) ! { ! if ( mInitCalled ) ! { ! // If the Servo is already in operation, we first need to ! // set the old Joint's desired vel and max force to 0. The ! // following function call will automatically handle this ! // when set to false. ! setEnabled( false ); ! } ! assert( data.joint ); ! assert( data.jointAxisNum >= 0 && ! data.jointAxisNum < data.joint->getNumAxes() ); ! Motor::init(); ! assert( data.joint->isRotational( data.jointAxisNum ) ); ! mData = data; ! setEnabled( mData.enabled ); ! } ! const ServoMotorData& ServoMotor::getData() const ! { ! return mData; ! } ! MotorType ServoMotor::getType() const ! { ! return mData.getType(); ! } ! void ServoMotor::setName( const std::string& name ) ! { ! mData.name = name; ! } ! const std::string& ServoMotor::getName() const ! { ! return mData.name; ! } ! bool ServoMotor::isEnabled() const ! { ! return mData.enabled; ! } ! void ServoMotor::setEnabled( bool e ) ! { ! //if (!mInitCalled) ! //{ ! // return; ! //} ! mData.enabled = e; ! if ( mData.joint ) ! { ! if ( e ) ! { ! mData.joint->internal_setDesiredVel( mData.jointAxisNum, ! mData.desiredVel ); ! mData.joint->internal_setMaxTorque( mData.jointAxisNum, ! mData.maxTorque ); ! } ! else ! { ! mData.joint->internal_setDesiredVel( mData.jointAxisNum, 0 ); ! mData.joint->internal_setMaxTorque( mData.jointAxisNum, 0 ); ! } ! } ! } ! void ServoMotor::internal_update() ! { ! if ( mData.enabled && mData.joint ) ! { ! // Make sure both Solids are awake at this point. ! mData.joint->wakeSolids(); ! if ( DESIRED_ANGLE_MODE == mData.mode ) ! { ! // No longer support linear degrees of freedom. ! //if (true == mData.joint->isRotational(mData.jointAxisNum)) ! //{ ! real velocity = mData.desiredAngle - ! mData.joint->getAngle( mData.jointAxisNum ); ! if ( velocity > 180.0 ) ! velocity = -360 + velocity; ! if ( velocity < -180.0 ) ! velocity = 360 + velocity; ! mData.joint->internal_setDesiredVel( mData.jointAxisNum, ! mData.restoreSpeed * velocity ); ! //} ! //else ! //{ ! // // This axis must be a linear degree of freedom. ! // real velocity = mData.desiredPos - ! // mData.joint->getState(mData.jointAxisNum); ! // mData.joint->internal_setDesiredVel(mData.jointAxisNum, ! // mData.restoreSpeed * velocity); ! //} ! } ! else ! { ! // Nothing to do for desired velocity mode; the Joint's ! // desired velocity should already handle this. ! } ! } ! } ! void ServoMotor::setDesiredAngle( real a ) ! { ! // this clamping is needed since there are sometimes float point errors ! real low = mData.joint->getLowLimit( mData.jointAxisNum ); ! if ( a < low ) ! { ! a = low; ! } ! real high = mData.joint->getHighLimit( mData.jointAxisNum ); ! if ( a > high ) ! { ! a = high; ! } ! mData.desiredAngle = a; ! } ! void ServoMotor::setDesiredAngleNorm( real a ) ! { ! if ( a < 0 ) ! a = 0; ! if ( a > 1 ) ! a = 1; ! real lowLimit = mData.joint->getLowLimit( mData.jointAxisNum ); ! real highLimit = mData.joint->getHighLimit( mData.jointAxisNum ); ! // map the pos value onto the joint limits ! mData.desiredAngle = a * ( highLimit - lowLimit ) + lowLimit; ! // Keep desired angle slightly away from the limit to avoid jitter. ! // @todo: fix this; this should just keep the thing away from the ! // limit when it's close, not all the time. ! mData.desiredAngle *= ( real ) 0.99; ! } ! real ServoMotor::getDesiredAngle() const ! { ! return mData.desiredAngle; ! } ! void ServoMotor::setDesiredVel( real vel ) ! { ! mData.desiredVel = vel; ! mData.joint->internal_setDesiredVel( mData.jointAxisNum, vel ); ! } ! real ServoMotor::getDesiredVel() const ! { ! return mData.desiredVel; ! } ! void ServoMotor::setMaxTorque( real max ) ! { ! mData.maxTorque = max; ! mData.joint->internal_setMaxTorque( mData.jointAxisNum, max ); ! } ! real ServoMotor::getMaxTorque() const ! { ! return mData.maxTorque; ! } ! void ServoMotor::setRestoreSpeed( real speed ) ! { ! mData.restoreSpeed = speed; ! } ! real ServoMotor::getRestoreSpeed() const ! { ! return mData.restoreSpeed; ! } ! ! bool ServoMotor::internal_dependsOnJoint( Joint* j ) ! { ! if ( j == mData.joint ) ! { ! return true; ! } ! else ! { ! return false; ! } ! } } Index: testMatrix44r.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testMatrix44r.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testMatrix44r.cpp 1 Dec 2005 23:55:21 -0000 1.1 --- testMatrix44r.cpp 2 Dec 2005 05:47:21 -0000 1.2 *************** *** 41,45 **** Matrix44r m; m.setQuaternion( 0, 0, 0, 1 ); ! QT_CHECK_EQUAL( m.getEulerXYZ(), Vec3r( 0, 0, 180 ) ); } --- 41,45 ---- Matrix44r m; m.setQuaternion( 0, 0, 0, 1 ); ! QT_CHECK_EQUAL( m.getEulerXYZ(), Vec3r( 0, 0, -180 ) ); } *************** *** 48,52 **** Matrix44r m; m.setQuaternion( Quaternion( 0, 0, 0, 1 ) ); ! QT_CHECK_EQUAL( m.getEulerXYZ(), Vec3r( 0, 0, 180 ) ); } } --- 48,52 ---- Matrix44r m; m.setQuaternion( Quaternion( 0, 0, 0, 1 ) ); ! QT_CHECK_EQUAL( m.getEulerXYZ(), Vec3r( 0, 0, -180 ) ); } } Index: ServoMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotor.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ServoMotor.h 23 Mar 2005 04:04:30 -0000 1.25 --- ServoMotor.h 2 Dec 2005 05:47:21 -0000 1.26 *************** *** 73,80 **** --- 73,82 ---- /// Sets the desired angle to a value between the Joint axis' /// limits. + /// Clamps given angle into allowed range for the joint. virtual void OPAL_CALL setDesiredAngle(real a); /// Sets the desired angle to a value between 0.0 and 1.0 which /// will be mapped to the Joint axis' limits. + /// Clamps given angle into [0,1] range. virtual void OPAL_CALL setDesiredAngleNorm(real a); Index: testVec3r.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testVec3r.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testVec3r.cpp 1 Dec 2005 23:55:21 -0000 1.2 --- testVec3r.cpp 2 Dec 2005 05:47:21 -0000 1.3 *************** *** 41,47 **** { Vec3r v; ! QT_CHECK_EQUAL( v.x, 0 ); ! QT_CHECK_EQUAL( v.y, 0 ); ! QT_CHECK_EQUAL( v.z, 0 ); } --- 41,47 ---- { Vec3r v; ! QT_CHECK_CLOSE( v.x, 0 ); ! QT_CHECK_CLOSE( v.y, 0 ); ! QT_CHECK_CLOSE( v.z, 0 ); } *************** *** 50,56 **** Vec3r copy( 1, 2, 3 ); Vec3r v( copy ); ! QT_CHECK_EQUAL( v.x, 1 ); ! QT_CHECK_EQUAL( v.y, 2 ); ! QT_CHECK_EQUAL( v.z, 3 ); } --- 50,56 ---- Vec3r copy( 1, 2, 3 ); Vec3r v( copy ); ! QT_CHECK_CLOSE( v.x, 1 ); ! QT_CHECK_CLOSE( v.y, 2 ); ! QT_CHECK_CLOSE( v.z, 3 ); } *************** *** 58,64 **** { Vec3r v( 1, 2, 3 ); ! QT_CHECK_EQUAL( v.x, 1 ); ! QT_CHECK_EQUAL( v.y, 2 ); ! QT_CHECK_EQUAL( v.z, 3 ); } --- 58,64 ---- { Vec3r v( 1, 2, 3 ); ! QT_CHECK_CLOSE( v.x, 1 ); ! QT_CHECK_CLOSE( v.y, 2 ); ! QT_CHECK_CLOSE( v.z, 3 ); } *************** *** 66,72 **** { Vec3r v = Vec3r( 1, 2, 3 ); ! QT_CHECK_EQUAL( v.x, 1 ); ! QT_CHECK_EQUAL( v.y, 2 ); ! QT_CHECK_EQUAL( v.z, 3 ); } --- 66,72 ---- { Vec3r v = Vec3r( 1, 2, 3 ); ! QT_CHECK_CLOSE( v.x, 1 ); ! QT_CHECK_CLOSE( v.y, 2 ); ! QT_CHECK_CLOSE( v.z, 3 ); } *************** *** 75,81 **** real d[] = {1, 2, 3}; Vec3r v( d ); ! QT_CHECK_EQUAL( v.x, 1 ); ! QT_CHECK_EQUAL( v.y, 2 ); ! QT_CHECK_EQUAL( v.z, 3 ); } --- 75,81 ---- real d[] = {1, 2, 3}; Vec3r v( d ); ! QT_CHECK_CLOSE( v.x, 1 ); ! QT_CHECK_CLOSE( v.y, 2 ); ! QT_CHECK_CLOSE( v.z, 3 ); } *************** *** 84,90 **** Vec3r v; v.set( 1, 2, 3 ); ! QT_CHECK_EQUAL( v.x, 1 ); ! QT_CHECK_EQUAL( v.y, 2 ); ! QT_CHECK_EQUAL( v.z, 3 ); } --- 84,90 ---- Vec3r v; v.set( 1, 2, 3 ); ! QT_CHECK_CLOSE( v.x, 1 ); ! QT_CHECK_CLOSE( v.y, 2 ); ! QT_CHECK_CLOSE( v.z, 3 ); } *************** *** 94,100 **** Vec3r v; v.set( d ); ! QT_CHECK_EQUAL( v.x, 1 ); ! QT_CHECK_EQUAL( v.y, 2 ); ! QT_CHECK_EQUAL( v.z, 3 ); } --- 94,100 ---- Vec3r v; v.set( d ); ! QT_CHECK_CLOSE( v.x, 1 ); ! QT_CHECK_CLOSE( v.y, 2 ); ! QT_CHECK_CLOSE( v.z, 3 ); } *************** *** 103,109 **** Vec3r v( 1, 2, 3 ); ! QT_CHECK_EQUAL( v[ 0 ], 1 ); ! QT_CHECK_EQUAL( v[ 1 ], 2 ); ! QT_CHECK_EQUAL( v[ 2 ], 3 ); } --- 103,109 ---- Vec3r v( 1, 2, 3 ); ! QT_CHECK_CLOSE( v[ 0 ], 1 ); ! QT_CHECK_CLOSE( v[ 1 ], 2 ); ! QT_CHECK_CLOSE( v[ 2 ], 3 ); } *************** *** 111,115 **** { Vec3r v( 1, 2, 3 ); ! QT_CHECK_EQUAL( v.lengthSquared(), 1 + 4 + 9 ); } --- 111,115 ---- { Vec3r v( 1, 2, 3 ); ! QT_CHECK_CLOSE( v.lengthSquared(), 1 + 4 + 9 ); } *************** *** 117,121 **** { Vec3r v( -1, -2, -3 ); ! QT_CHECK_EQUAL( v.lengthSquared(), 1 + 4 + 9 ); } --- 117,121 ---- { Vec3r v( -1, -2, -3 ); ! QT_CHECK_CLOSE( v.lengthSquared(), 1 + 4 + 9 ); } *************** *** 123,127 **** { Vec3r v( 1, 2, 3 ); ! QT_CHECK_EQUAL( v.length(), sqrt( 1 + 4 + 9 ) ); } --- 123,127 ---- { Vec3r v( 1, 2, 3 ); ! QT_CHECK_CLOSE( v.length(), sqrt( 1 + 4 + 9 ) ); } *************** *** 129,133 **** { Vec3r v( -1, -2, -3 ); ! QT_CHECK_EQUAL( v.length(), sqrt( 1 + 4 + 9 ) ); } --- 129,133 ---- { Vec3r v( -1, -2, -3 ); ! QT_CHECK_CLOSE( v.length(), sqrt( 1 + 4 + 9 ) ); } Index: Vec3r.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Vec3r.cpp 1 Dec 2005 02:04:54 -0000 1.2 --- Vec3r.cpp 2 Dec 2005 05:47:21 -0000 1.3 *************** *** 28,32 **** // class header ! #include "Vec3r.h" //#pragma implementation --- 28,32 ---- // class header ! #include "Vec3r.h" //#pragma implementation *************** *** 83,94 **** { case 0: ! return x; case 1: ! return y; case 2: ! return z; default: ! assert( i < 3 ); ! return z; } } --- 83,94 ---- { case 0: ! return x; case 1: ! return y; case 2: ! return z; default: ! assert( i < 3 ); ! return z; } } *************** *** 99,110 **** { case 0: ! return x; case 1: ! return y; case 2: ! return z; default: ! assert( i < 3 ); ! return z; } } --- 99,110 ---- { case 0: ! return x; case 1: ! return y; case 2: ! return z; default: ! assert( i < 3 ); ! return z; } } *************** *** 177,181 **** bool Vec3r::operator==( const Vec3r & v ) { ! return ( x == v.x && y == v.y && z == v.z ); } --- 177,181 ---- bool Vec3r::operator==( const Vec3r & v ) { ! return ( areEqual( x, v.x ) && areEqual( y , v.y ) && areEqual( z , v.z ) ); } *************** *** 189,193 **** bool Vec3r::operator!=( const Vec3r & v ) { ! return ( x != v.x || y != v.y || z != v.z ); } --- 189,193 ---- bool Vec3r::operator!=( const Vec3r & v ) { ! return ( !areEqual( x, v.x ) || !areEqual( y , v.y ) || !areEqual( z , v.z ) ); } |
|
From: Olex <ole...@us...> - 2005-12-02 05:47:29
|
Update of /cvsroot/opal/opal/kdevelop In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26719/kdevelop Modified Files: opal.kdevelop Log Message: Fixes in ServoMotor, Vec3r to handle float point errors. Updated unit test framework. Index: opal.kdevelop =================================================================== RCS file: /cvsroot/opal/opal/kdevelop/opal.kdevelop,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** opal.kdevelop 1 Dec 2005 23:55:21 -0000 1.4 --- opal.kdevelop 2 Dec 2005 05:47:20 -0000 1.5 *************** *** 14,18 **** <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description/> <versioncontrol/> </general> --- 14,18 ---- <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description></description> <versioncontrol/> </general> *************** *** 52,63 **** <envvar value="ccache g++" name="CXX" /> </envvars> ! <topsourcedir/> ! <cppflags>-DOPAL_USE_DOUBLE</cppflags> <ldflags>-lode</ldflags> ! <ccompilerbinary/> ! <cxxcompilerbinary/> ! <f77compilerbinary/> ! <cflags/> ! <f77flags/> </debug> </configurations> --- 52,63 ---- <envvar value="ccache g++" name="CXX" /> </envvars> ! <topsourcedir></topsourcedir> ! <cppflags></cppflags> <ldflags>-lode</ldflags> ! <ccompilerbinary></ccompilerbinary> ! <cxxcompilerbinary></cxxcompilerbinary> ! <f77compilerbinary></f77compilerbinary> ! <cflags></cflags> ! <f77flags></f77flags> </debug> </configurations> *************** *** 173,177 **** </codecompletion> <creategettersetter> ! <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> --- 173,177 ---- </codecompletion> <creategettersetter> ! <prefixGet></prefixGet> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> *************** *** 194,203 **** <kdevdebugger> <general> ! <programargs/> ! <gdbpath/> ! <dbgshell/> ! <configGdbScript/> ! <runShellScript/> ! <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> --- 194,203 ---- <kdevdebugger> <general> ! <programargs></programargs> ! <gdbpath></gdbpath> ! <dbgshell></dbgshell> ! <configGdbScript></configGdbScript> ! <runShellScript></runShellScript> ! <runGdbScript></runGdbScript> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> |
|
From: Olex <ole...@us...> - 2005-12-02 05:47:28
|
Update of /cvsroot/opal/opal/src/external/quicktest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26719/src/external/quicktest Modified Files: quicktest.h Log Message: Fixes in ServoMotor, Vec3r to handle float point errors. Updated unit test framework. Index: quicktest.h =================================================================== RCS file: /cvsroot/opal/opal/src/external/quicktest/quicktest.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** quicktest.h 1 Dec 2005 23:55:21 -0000 1.5 --- quicktest.h 2 Dec 2005 05:47:21 -0000 1.6 *************** *** 102,106 **** static bool areEqual(double x, double y) { ! const double EPSILON = 0.000001; double maxVal = 1; --- 102,106 ---- static bool areEqual(double x, double y) { ! const double EPSILON = 0.00001; double maxVal = 1; |
|
From: Olex <ole...@us...> - 2005-12-02 05:47:28
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26719 Modified Files: changelog.txt Log Message: Fixes in ServoMotor, Vec3r to handle float point errors. Updated unit test framework. Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** changelog.txt 2 Dec 2005 01:47:16 -0000 1.56 --- changelog.txt 2 Dec 2005 05:47:20 -0000 1.57 *************** *** 15,18 **** --- 15,21 ---- ------------------------------------------ + * 12-2-05: Fixes in ServoMotor, Vec3r to handle float point errors. + Updated unit test framework. (Oleksandr Lozitskiy) + * 12-1-05: Updated Scons script. (Oleksandr Lozitskiy) |
|
From: Olex <ole...@us...> - 2005-12-02 01:47:30
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18025/src Modified Files: SConscript Log Message: Updated Scons script. Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SConscript 30 Nov 2005 06:28:12 -0000 1.22 --- SConscript 2 Dec 2005 01:47:16 -0000 1.23 *************** *** 79,82 **** --- 79,83 ---- Space.cpp SpringMotor.cpp + Quaternion.cpp ThrusterMotor.cpp VolumeSensor.cpp |
|
From: Olex <ole...@us...> - 2005-12-02 01:47:30
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18025 Modified Files: changelog.txt Log Message: Updated Scons script. Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** changelog.txt 1 Dec 2005 23:55:21 -0000 1.55 --- changelog.txt 2 Dec 2005 01:47:16 -0000 1.56 *************** *** 15,18 **** --- 15,20 ---- ------------------------------------------ + * 12-1-05: Updated Scons script. (Oleksandr Lozitskiy) + * 12-1-05: More Unit tests. Finished opal::Quaternion. (Oleksandr Lozitskiy) |
|
From: Olex <ole...@us...> - 2005-12-01 23:55:31
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13924/src Modified Files: Makefile.am Makefile.in Matrix44r.h Quaternion.cpp Quaternion.h testAccelerationSensor.cpp testQuaternion.cpp testVec3r.cpp testsolid.cpp Added Files: testMatrix44r.cpp Log Message: More Unit tests. Finished opal::Quaternion tests. Index: Makefile.in =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.in,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.in 1 Dec 2005 19:34:03 -0000 1.7 --- Makefile.in 1 Dec 2005 23:55:21 -0000 1.8 *************** *** 71,75 **** testAccelerationSensor.$(OBJEXT) testRaycastSensor.$(OBJEXT) \ testSimulator.$(OBJEXT) testVec3r.$(OBJEXT) \ ! testPoint3r.$(OBJEXT) testQuaternion.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ --- 71,76 ---- testAccelerationSensor.$(OBJEXT) testRaycastSensor.$(OBJEXT) \ testSimulator.$(OBJEXT) testVec3r.$(OBJEXT) \ ! testPoint3r.$(OBJEXT) testQuaternion.$(OBJEXT) \ ! testMatrix44r.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ *************** *** 213,217 **** test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ --- 214,219 ---- test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ *************** *** 321,324 **** --- 323,327 ---- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VolumeSensor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testAccelerationSensor.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMatrix44r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testPoint3r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testQuaternion.Po@am__quote@ Index: testAccelerationSensor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testAccelerationSensor.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testAccelerationSensor.cpp 13 Nov 2005 18:51:20 -0000 1.1 --- testAccelerationSensor.cpp 1 Dec 2005 23:55:21 -0000 1.2 *************** *** 98,102 **** f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.sensor->getGlobalLinearAccel() [ 1 ] , 0, 0.001 ); } } --- 98,102 ---- f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.sensor->getGlobalLinearAccel() [ 1 ] , 0 ); } } Index: testQuaternion.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testQuaternion.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testQuaternion.cpp 1 Dec 2005 19:34:03 -0000 1.2 --- testQuaternion.cpp 1 Dec 2005 23:55:21 -0000 1.3 *************** *** 29,32 **** --- 29,33 ---- // system headers #include <quicktest.h> + #include <sstream> // project headers *************** *** 99,118 **** } QT_TEST( lengthSquared ) { ! QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).lengthSquared(), 0, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).lengthSquared(), 1, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).lengthSquared(), 5, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).lengthSquared(), 14, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).lengthSquared(), 30, 0.001 ); } QT_TEST( length ) { ! QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).length(), 0, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).length(), 1, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).length(), sqrt( 5 ), 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).length(), sqrt( 14 ), 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).length(), sqrt( 30 ), 0.001 ); } --- 100,154 ---- } + QT_TEST( operator_summation ) + { + QT_CHECK_EQUAL( Quaternion( 1, 0, 0, 0 ) + Quaternion( 0, 1, 0, 0 ), + Quaternion( 1, 1, 0, 0 ) ); + QT_CHECK_EQUAL( Quaternion( 1, 2, 3, 4 ) + Quaternion( 4, 3, 2, 1 ), + Quaternion( 5, 5, 5, 5 ) ); + } + + QT_TEST( operator_substraction ) + { + QT_CHECK_EQUAL( Quaternion( 1, 0, 0, 0 ) - Quaternion( 0, 1, 0, 0 ), + Quaternion( 1, -1, 0, 0 ) ); + QT_CHECK_EQUAL( Quaternion( 1, 2, 3, 4 ) - Quaternion( 4, 3, 2, 1 ), + Quaternion( -3, -1, 1, 3 ) ); + } + + QT_TEST( operator_multiply_before_scalar ) + { + QT_CHECK_EQUAL( Quaternion( 1, 0, 0, 0 ) * 5, Quaternion( 5, 0, 0, 0 ) ); + QT_CHECK_EQUAL( Quaternion( 1, 2, -3, 4 ) * -1, Quaternion( -1, -2, 3, -4 ) ); + } + + QT_TEST( operator_multiply_after_scalar ) + { + QT_CHECK_EQUAL( 5 * Quaternion( 1, 0, 0, 0 ), Quaternion( 5, 0, 0, 0 ) ); + QT_CHECK_EQUAL( -1 * Quaternion( 1, 2, -3, 4 ), Quaternion( -1, -2, 3, -4 ) ); + } + + QT_TEST( operator_string ) + { + std::ostringstream ss; + ss << Quaternion( 1, 2, 3, 4 ); + QT_CHECK_EQUAL( ss.str(), "[1 2 3 4]" ); + } + QT_TEST( lengthSquared ) { ! QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).lengthSquared(), 0 ); ! QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).lengthSquared(), 1 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).lengthSquared(), 5 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).lengthSquared(), 14 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).lengthSquared(), 30 ); } QT_TEST( length ) { ! QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).length(), 0 ); ! QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).length(), 1 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).length(), sqrt( 5 ) ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).length(), sqrt( 14 ) ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).length(), sqrt( 30 ) ); } *************** *** 121,125 **** Quaternion q( 0, 0, 0, 0 ); q.normalize(); ! QT_CHECK_NOT_EQUAL( q, Quaternion( 0, 0, 0, 0 ) ); } } --- 157,212 ---- Quaternion q( 0, 0, 0, 0 ); q.normalize(); ! QT_CHECK_EQUAL( q, Quaternion( 0, 0, 0, 0 ) ); ! ! q.set( 0, 0, 0, 1 ); ! q.normalize(); ! QT_CHECK_EQUAL( q, Quaternion( 0, 0, 0, 1 ) ); ! ! q.set( 1, 0, 0, 0 ); ! q.normalize(); ! QT_CHECK_EQUAL( q, Quaternion( 1, 0, 0, 0 ) ); ! ! q.set( 1, 0, 0, 1 ); ! q.normalize(); ! QT_CHECK_EQUAL( q, Quaternion( sqrt( 2 ) / 2.0, 0, 0, sqrt( 2 ) / 2.0 ) ); ! } ! ! QT_TEST( getAngleAxis ) ! { ! Quaternion q( 0, 1, 0, 0 ); ! real angle; ! Vec3r axis; ! q.getAngleAxis( angle, axis ); ! QT_CHECK_EQUAL( angle, 180 ); ! QT_CHECK_EQUAL( axis, Vec3r( 1, 0, 0 ) ); ! ! q.set( 0, 0, 1, 0 ); ! q.getAngleAxis( angle, axis ); ! QT_CHECK_EQUAL( angle, 180 ); ! QT_CHECK_EQUAL( axis, Vec3r( 0, 1, 0 ) ); ! ! q.set( 1, 0, 1, 0 ); ! q.normalize(); ! q.getAngleAxis( angle, axis ); ! QT_CHECK_CLOSE( angle, 90 ); ! QT_CHECK_EQUAL( axis, Vec3r( 0, 1, 0 ) ); ! } ! ! QT_TEST( getRoll_Pitch_Yaw ) ! { ! Quaternion q( 0, 0, 1, 0 ); ! QT_CHECK_CLOSE( q.getRoll(), 180 ); ! QT_CHECK_CLOSE( q.getPitch(), 0 ); ! QT_CHECK_CLOSE( q.getYaw(), 180 ); ! ! q.set( 0, 1, 0, 0 ); ! QT_CHECK_CLOSE( q.getRoll(), 180 ); ! QT_CHECK_CLOSE( q.getPitch(), 0 ); ! QT_CHECK_CLOSE( q.getYaw(), 0 ); ! ! q.set( 0, 0, 0, 1 ); ! QT_CHECK_CLOSE( q.getRoll(), 0 ); ! QT_CHECK_CLOSE( q.getPitch(), 0 ); ! QT_CHECK_CLOSE( q.getYaw(), 180 ); } } Index: testsolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testsolid.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** testsolid.cpp 1 Dec 2005 19:34:03 -0000 1.6 --- testsolid.cpp 1 Dec 2005 23:55:21 -0000 1.7 *************** *** 106,110 **** f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.s->getPosition() [ 1 ], p[ 1 ], 0.001 ); } --- 106,110 ---- f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.s->getPosition() [ 1 ], p[ 1 ] ); } *************** *** 118,122 **** f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.s->getPosition() [ 1 ], p[ 1 ], 0.001 ); } --- 118,122 ---- f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.s->getPosition() [ 1 ], p[ 1 ] ); } *************** *** 142,146 **** f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.s->getPosition() [ 1 ], p[ 1 ], 0.001 ); } --- 142,146 ---- f.sim->simulate( 1 ); ! QT_CHECK_CLOSE( f.s->getPosition() [ 1 ], p[ 1 ] ); } *************** *** 216,225 **** Matrix44r m_set = f.s->getInertiaTensor(); QT_CHECK_EQUAL( m, m_set ); ! QT_CHECK_CLOSE( f.s->getMass(), mass.mass, 0.001 ); mass.mass = 2; f.s->setMass( mass, Matrix44r() ); ! QT_CHECK_CLOSE( f.s->getMass(), mass.mass, 0.001 ); } --- 216,225 ---- Matrix44r m_set = f.s->getInertiaTensor(); QT_CHECK_EQUAL( m, m_set ); ! QT_CHECK_CLOSE( f.s->getMass(), mass.mass ); mass.mass = 2; f.s->setMass( mass, Matrix44r() ); ! QT_CHECK_CLOSE( f.s->getMass(), mass.mass ); } Index: Makefile.am =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.am 1 Dec 2005 19:34:03 -0000 1.7 --- Makefile.am 1 Dec 2005 23:55:21 -0000 1.8 *************** *** 15,19 **** bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode --- 15,20 ---- bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Quaternion.h 1 Dec 2005 19:34:03 -0000 1.11 --- Quaternion.h 1 Dec 2005 23:55:21 -0000 1.12 *************** *** 61,65 **** void normalize(); ! void getAngleAxis( real& angle, Vec3r& axis ); real getRoll() const; --- 61,65 ---- void normalize(); ! void getAngleAxis( real& angle, Vec3r& axis ) const; real getRoll() const; Index: Quaternion.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Quaternion.cpp 1 Dec 2005 19:34:03 -0000 1.1 --- Quaternion.cpp 1 Dec 2005 23:55:21 -0000 1.2 *************** *** 83,92 **** { real len = length(); ! assert( 0 != len ); ! real factor = 1 / len; ! ( *this ) = ( *this ) * factor; } ! void Quaternion::getAngleAxis( real& angle, Vec3r& axis ) { real sqrLen = x * x + y * y + z * z; --- 83,94 ---- { real len = length(); ! if ( len > 0 ) ! { ! real factor = 1 / len; ! ( *this ) = ( *this ) * factor; ! } } ! void Quaternion::getAngleAxis( real& angle, Vec3r& axis ) const { real sqrLen = x * x + y * y + z * z; *************** *** 146,158 **** const real & Quaternion::operator[] ( unsigned int i ) const { ! switch ( i ) ! { ! case 0: return w; ! case 1: return x; ! case 2: return y; ! case 3: return z; ! } ! assert( i < 4 ); ! return w; } --- 148,160 ---- const real & Quaternion::operator[] ( unsigned int i ) const { ! switch ( i ) ! { ! case 0: return w; ! case 1: return x; ! case 2: return y; ! case 3: return z; ! } ! assert( i < 4 ); ! return w; } --- NEW FILE: testMatrix44r.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // system headers #include <quicktest.h> // project headers #include "opal.h" using namespace opal; namespace testMatrix44r { QT_TEST( setQuaternion_values ) { Matrix44r m; m.setQuaternion( 0, 0, 0, 1 ); QT_CHECK_EQUAL( m.getEulerXYZ(), Vec3r( 0, 0, 180 ) ); } QT_TEST( setQuaternion_object ) { Matrix44r m; m.setQuaternion( Quaternion( 0, 0, 0, 1 ) ); QT_CHECK_EQUAL( m.getEulerXYZ(), Vec3r( 0, 0, 180 ) ); } } Index: testVec3r.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testVec3r.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testVec3r.cpp 30 Nov 2005 06:28:12 -0000 1.1 --- testVec3r.cpp 1 Dec 2005 23:55:21 -0000 1.2 *************** *** 289,301 **** { QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 1, 0, 0 ) ), ! 90, 0.0001 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0.5, 0.5, 0 ) ), ! 90, 0.0001 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, 0.5, 0.5 ) ), ! 45, 0.0001 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, 0.5, 0.5 ) ), ! 45, 0.0001 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, 0.5, -0.5 ) ), ! 90 + 45, 0.0001 ); } --- 289,301 ---- { QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 1, 0, 0 ) ), ! 90 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0.5, 0.5, 0 ) ), ! 90 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, 0.5, 0.5 ) ), ! 45 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, 0.5, 0.5 ) ), ! 45 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, 0.5, -0.5 ) ), ! 90 + 45 ); } *************** *** 303,316 **** { QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 1, 0, 0 ) ), ! 90, 0.0001 ); real s = sqrt( 0.5 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( s, s, 0 ) ), ! 90, 0.0001 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, s, s ) ), ! 45, 0.0001 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, s, s ) ), ! 45, 0.0001 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, s, -s ) ), ! 90 + 45, 0.0001 ); } --- 303,316 ---- { QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 1, 0, 0 ) ), ! 90 ); real s = sqrt( 0.5 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( s, s, 0 ) ), ! 90 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, s, s ) ), ! 45 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, s, s ) ), ! 45 ); QT_CHECK_CLOSE( angleBetween( Vec3r( 0, 0, 1 ) , Vec3r( 0, s, -s ) ), ! 90 + 45 ); } Index: Matrix44r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Matrix44r.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Matrix44r.h 1 Dec 2005 19:34:03 -0000 1.39 --- Matrix44r.h 1 Dec 2005 23:55:21 -0000 1.40 *************** *** 69,72 **** --- 69,73 ---- inline friend Matrix44r operator*( real scalar, Matrix44r m ); + /// identity by default Matrix44r() { *************** *** 255,258 **** --- 256,268 ---- } + inline void setQuaternion( const Quaternion & q ) + { + real angle; + Vec3r axis; + q.getAngleAxis( angle, axis ); + + setRotation( angle, axis.x, axis.y, axis.z ); + } + inline void setRotation( real theta, real x, real y, real z ) { |
|
From: Olex <ole...@us...> - 2005-12-01 23:55:31
|
Update of /cvsroot/opal/opal/kdevelop In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13924/kdevelop Modified Files: opal.kdevelop Log Message: More Unit tests. Finished opal::Quaternion tests. Index: opal.kdevelop =================================================================== RCS file: /cvsroot/opal/opal/kdevelop/opal.kdevelop,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** opal.kdevelop 1 Dec 2005 02:04:54 -0000 1.3 --- opal.kdevelop 1 Dec 2005 23:55:21 -0000 1.4 *************** *** 14,18 **** <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description></description> <versioncontrol/> </general> --- 14,18 ---- <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description/> <versioncontrol/> </general> *************** *** 173,177 **** </codecompletion> <creategettersetter> ! <prefixGet></prefixGet> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> --- 173,177 ---- </codecompletion> <creategettersetter> ! <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> *************** *** 194,203 **** <kdevdebugger> <general> ! <programargs></programargs> ! <gdbpath></gdbpath> ! <dbgshell></dbgshell> ! <configGdbScript></configGdbScript> ! <runShellScript></runShellScript> ! <runGdbScript></runGdbScript> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> --- 194,203 ---- <kdevdebugger> <general> ! <programargs/> ! <gdbpath/> ! <dbgshell/> ! <configGdbScript/> ! <runShellScript/> ! <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> *************** *** 211,216 **** </kdevdebugger> <ctagspart> ! <customArguments></customArguments> ! <customTagfilePath></customTagfilePath> </ctagspart> </kdevelop> --- 211,216 ---- </kdevdebugger> <ctagspart> ! <customArguments/> ! <customTagfilePath/> </ctagspart> </kdevelop> |
|
From: Olex <ole...@us...> - 2005-12-01 23:55:31
|
Update of /cvsroot/opal/opal/src/external/quicktest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13924/src/external/quicktest Modified Files: quicktest.h Log Message: More Unit tests. Finished opal::Quaternion tests. Index: quicktest.h =================================================================== RCS file: /cvsroot/opal/opal/src/external/quicktest/quicktest.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** quicktest.h 1 Dec 2005 02:04:54 -0000 1.4 --- quicktest.h 1 Dec 2005 23:55:21 -0000 1.5 *************** *** 98,101 **** --- 98,127 ---- /// The group name of this test std::string mTestGroup; + + /// helper method + static bool areEqual(double x, double y) + { + const double EPSILON = 0.000001; + double maxVal = 1; + + if (fabs(static_cast<double>(x)) > maxVal) + { + maxVal = fabs(x); + } + + if (fabs(static_cast<double>(y)) > maxVal) + { + maxVal = fabs(static_cast<double>(y)); + } + + if (fabs(static_cast<double>(x - y)) <= EPSILON * maxVal) + { + return true; + } + else + { + return false; + } + } }; *************** *** 245,248 **** --- 271,275 ---- {\ recordFailure(_result, __FILE__, __LINE__, #condition);\ + return;\ }\ } *************** *** 258,261 **** --- 285,289 ---- << std::endl << "(" << (value2) << ")";\ recordFailure(_result, __FILE__, __LINE__, oss.str());\ + return;\ }\ } *************** *** 270,273 **** --- 298,302 ---- << "value2 (" << (value2) << ")";\ recordFailure(_result, __FILE__, __LINE__, oss.str());\ + return;\ }\ } *************** *** 276,282 **** /// the second parameter. This is useful for comparing floating point /// values. ! #define QT_CHECK_CLOSE(value1, value2, tolerance)\ {\ ! if (abs((value1)-(value2)) > tolerance)\ {\ std::ostringstream oss;\ --- 305,311 ---- /// the second parameter. This is useful for comparing floating point /// values. ! #define QT_CHECK_CLOSE(value1, value2)\ {\ ! if (areEqual((value1),(value2)) == false )\ {\ std::ostringstream oss;\ *************** *** 284,287 **** --- 313,317 ---- << "value2 (" << (value2) << ")";\ recordFailure(_result, __FILE__, __LINE__, oss.str());\ + return;\ }\ } *************** *** 296,299 **** --- 326,330 ---- << "value2 (" << (value2) << ")";\ recordFailure(_result, __FILE__, __LINE__, oss.str());\ + return;\ }\ } *************** *** 308,311 **** --- 339,343 ---- << "equal to " << "value2 (" << (value2) << ")";\ recordFailure(_result, __FILE__, __LINE__, oss.str());\ + return;\ }\ } *************** *** 320,323 **** --- 352,356 ---- << "value2 (" << (value2) << ")";\ recordFailure(_result, __FILE__, __LINE__, oss.str());\ + return;\ }\ } *************** *** 333,336 **** --- 366,370 ---- << "equal to " << "value2 (" << (value2) << ")";\ recordFailure(_result, __FILE__, __LINE__, oss.str());\ + return;\ }\ } *************** *** 340,343 **** --- 374,378 ---- {\ recordFailure(_result, __FILE__, __LINE__, (message));\ + return;\ }\ |
|
From: Olex <ole...@us...> - 2005-12-01 23:55:31
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13924 Modified Files: changelog.txt Log Message: More Unit tests. Finished opal::Quaternion tests. Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** changelog.txt 1 Dec 2005 19:34:03 -0000 1.54 --- changelog.txt 1 Dec 2005 23:55:21 -0000 1.55 *************** *** 15,18 **** --- 15,20 ---- ------------------------------------------ + * 12-1-05: More Unit tests. Finished opal::Quaternion. (Oleksandr Lozitskiy) + * 12-1-05: Fixed Matrix44r::setQuaternion(). Refactored Quaternion. More unit tests. (Oleksandr Lozitskiy) |
|
From: Olex <ole...@us...> - 2005-12-01 19:34:27
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19201/src Modified Files: Makefile.am Makefile.in Matrix44r.h Quaternion.h testQuaternion.cpp testsolid.cpp Added Files: Quaternion.cpp Log Message: Fixed Matrix44r::setQuaternion(). Refactored Quaternion. More unit tests. Index: Makefile.in =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.in 1 Dec 2005 04:54:44 -0000 1.6 --- Makefile.in 1 Dec 2005 19:34:03 -0000 1.7 *************** *** 62,66 **** ServoMotor.$(OBJEXT) Simulator.$(OBJEXT) Solid.$(OBJEXT) \ SolidData.$(OBJEXT) Space.$(OBJEXT) SpringMotor.$(OBJEXT) \ ! ThrusterMotor.$(OBJEXT) VolumeSensor.$(OBJEXT) Vec3r.$(OBJEXT) libopalode_a_OBJECTS = $(am_libopalode_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" --- 62,67 ---- ServoMotor.$(OBJEXT) Simulator.$(OBJEXT) Solid.$(OBJEXT) \ SolidData.$(OBJEXT) Space.$(OBJEXT) SpringMotor.$(OBJEXT) \ ! ThrusterMotor.$(OBJEXT) VolumeSensor.$(OBJEXT) Vec3r.$(OBJEXT) \ ! Quaternion.$(OBJEXT) libopalode_a_OBJECTS = $(am_libopalode_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" *************** *** 206,213 **** noinst_LIBRARIES = libopalode.a libopalode_a_SOURCES = AccelerationSensor.cpp AttractorMotor.cpp Blueprint.cpp \ ! BlueprintInstance.cpp BlueprintManager.cpp CollisionEventHandler.cpp GearedMotor.cpp \ ! InclineSensor.cpp Joint.cpp Logger.cpp Motor.cpp RaycastSensor.cpp Sensor.cpp \ ! ServoMotor.cpp Simulator.cpp Solid.cpp SolidData.cpp Space.cpp SpringMotor.cpp \ ! ThrusterMotor.cpp VolumeSensor.cpp Vec3r.cpp test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ --- 207,214 ---- noinst_LIBRARIES = libopalode.a libopalode_a_SOURCES = AccelerationSensor.cpp AttractorMotor.cpp Blueprint.cpp \ ! BlueprintInstance.cpp BlueprintManager.cpp CollisionEventHandler.cpp GearedMotor.cpp \ ! InclineSensor.cpp Joint.cpp Logger.cpp Motor.cpp RaycastSensor.cpp Sensor.cpp \ ! ServoMotor.cpp Simulator.cpp Solid.cpp SolidData.cpp Space.cpp SpringMotor.cpp \ ! ThrusterMotor.cpp VolumeSensor.cpp Vec3r.cpp Quaternion.cpp test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ *************** *** 307,310 **** --- 308,312 ---- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Logger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Motor.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Quaternion.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RaycastSensor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sensor.Po@am__quote@ Index: testQuaternion.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testQuaternion.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testQuaternion.cpp 1 Dec 2005 04:54:44 -0000 1.1 --- testQuaternion.cpp 1 Dec 2005 19:34:03 -0000 1.2 *************** *** 55,72 **** } QT_TEST( operator_equal ) { QT_CHECK_EQUAL( Quaternion( 0, 0, 0, 0 ), Quaternion( 0, 0, 0, 0 ) ); ! QT_CHECK_EQUAL( Quaternion( 0, 0, 0, 1 ), Quaternion( 0, 0, 0, 1 ) ); ! QT_CHECK_EQUAL( Quaternion( 0, 0, 1, 2 ), Quaternion( 0, 0, 1, 2 ) ); ! QT_CHECK_EQUAL( Quaternion( 1, 2, 0, 3 ), Quaternion( 1, 2, 0, 3 ) ); } ! QT_TEST( operator_not_equal ) ! { ! QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 0, 0 ), Quaternion( 1, 0, 0, 0 ) ); ! QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 0, 1 ), Quaternion( 0, 1, 0, 0 ) ); ! QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 1, 2 ), Quaternion( 4, 5, 0, 2 ) ); ! QT_CHECK_NOT_EQUAL( Quaternion( 1, 2, 0, 3 ), Quaternion( 1, 0, 2, 3 ) ); ! } } --- 55,125 ---- } + QT_TEST( set ) + { + Quaternion q; + q.set( 1, 2, 3, 4 ); + QT_CHECK_EQUAL( q[ 0 ], 1 ); + QT_CHECK_EQUAL( q[ 1 ], 2 ); + QT_CHECK_EQUAL( q[ 2 ], 3 ); + QT_CHECK_EQUAL( q[ 3 ], 4 ); + } + + QT_TEST( operator_square_brackets ) + { + Quaternion q( 1, 2, 3, 4 ); + QT_CHECK_EQUAL( q[ 0 ], 1 ); + QT_CHECK_EQUAL( q[ 1 ], 2 ); + QT_CHECK_EQUAL( q[ 2 ], 3 ); + QT_CHECK_EQUAL( q[ 3 ], 4 ); + } + + QT_TEST( copy_constructor ) + { + Quaternion q( Quaternion( 1, 2, 3, 4 ) ); + QT_CHECK_EQUAL( q[ 0 ], 1 ); + QT_CHECK_EQUAL( q[ 1 ], 2 ); + QT_CHECK_EQUAL( q[ 2 ], 3 ); + QT_CHECK_EQUAL( q[ 3 ], 4 ); + } + QT_TEST( operator_equal ) { QT_CHECK_EQUAL( Quaternion( 0, 0, 0, 0 ), Quaternion( 0, 0, 0, 0 ) ); ! QT_CHECK_EQUAL( Quaternion( 0, 0, 0, 1 ), Quaternion( 0, 0, 0, 1 ) ); ! QT_CHECK_EQUAL( Quaternion( 0, 0, 1, 2 ), Quaternion( 0, 0, 1, 2 ) ); ! QT_CHECK_EQUAL( Quaternion( 1, 2, 0, 3 ), Quaternion( 1, 2, 0, 3 ) ); } ! QT_TEST( operator_not_equal ) ! { ! QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 0, 0 ), Quaternion( 1, 0, 0, 0 ) ); ! QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 0, 1 ), Quaternion( 0, 1, 0, 0 ) ); ! QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 1, 2 ), Quaternion( 4, 5, 0, 2 ) ); ! QT_CHECK_NOT_EQUAL( Quaternion( 1, 2, 0, 3 ), Quaternion( 1, 0, 2, 3 ) ); ! } ! ! QT_TEST( lengthSquared ) ! { ! QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).lengthSquared(), 0, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).lengthSquared(), 1, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).lengthSquared(), 5, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).lengthSquared(), 14, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).lengthSquared(), 30, 0.001 ); ! } ! ! QT_TEST( length ) ! { ! QT_CHECK_CLOSE( Quaternion( 0, 0, 0, 0 ).length(), 0, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 0, 0, 0 ).length(), 1, 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 0, 0 ).length(), sqrt( 5 ), 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 0 ).length(), sqrt( 14 ), 0.001 ); ! QT_CHECK_CLOSE( Quaternion( 1, 2, 3, 4 ).length(), sqrt( 30 ), 0.001 ); ! } ! ! QT_TEST( normalize ) ! { ! Quaternion q( 0, 0, 0, 0 ); ! q.normalize(); ! QT_CHECK_NOT_EQUAL( q, Quaternion( 0, 0, 0, 0 ) ); ! } } Index: testsolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testsolid.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testsolid.cpp 1 Dec 2005 04:54:44 -0000 1.5 --- testsolid.cpp 1 Dec 2005 19:34:03 -0000 1.6 *************** *** 234,237 **** --- 234,241 ---- f.s->setQuaternion( q ); QT_CHECK_EQUAL( q, f.s->getQuaternion() ); + + q.set( 0, 0, 0, 1 ); + f.s->setQuaternion( q ); + QT_CHECK_EQUAL( q, f.s->getQuaternion() ); } } Index: Makefile.am =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.am 1 Dec 2005 04:54:44 -0000 1.6 --- Makefile.am 1 Dec 2005 19:34:03 -0000 1.7 *************** *** 9,16 **** noinst_LIBRARIES = libopalode.a libopalode_a_SOURCES = AccelerationSensor.cpp AttractorMotor.cpp Blueprint.cpp \ ! BlueprintInstance.cpp BlueprintManager.cpp CollisionEventHandler.cpp GearedMotor.cpp \ ! InclineSensor.cpp Joint.cpp Logger.cpp Motor.cpp RaycastSensor.cpp Sensor.cpp \ ! ServoMotor.cpp Simulator.cpp Solid.cpp SolidData.cpp Space.cpp SpringMotor.cpp \ ! ThrusterMotor.cpp VolumeSensor.cpp Vec3r.cpp bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ --- 9,16 ---- noinst_LIBRARIES = libopalode.a libopalode_a_SOURCES = AccelerationSensor.cpp AttractorMotor.cpp Blueprint.cpp \ ! BlueprintInstance.cpp BlueprintManager.cpp CollisionEventHandler.cpp GearedMotor.cpp \ ! InclineSensor.cpp Joint.cpp Logger.cpp Motor.cpp RaycastSensor.cpp Sensor.cpp \ ! ServoMotor.cpp Simulator.cpp Solid.cpp SolidData.cpp Space.cpp SpringMotor.cpp \ ! ThrusterMotor.cpp VolumeSensor.cpp Vec3r.cpp Quaternion.cpp bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Quaternion.h 1 Dec 2005 04:54:44 -0000 1.10 --- Quaternion.h 1 Dec 2005 19:34:03 -0000 1.11 *************** *** 32,206 **** #include "OpalMath.h" namespace opal { ! class Quaternion; ! inline Quaternion operator+( const Quaternion &q1, const Quaternion &q2 ); ! inline Quaternion operator-( const Quaternion &q1, const Quaternion &q2 ); ! inline Quaternion operator*( const Quaternion& q, real scalar ); ! inline Quaternion operator*( real scalar, const Quaternion& q ); ! inline bool operator==( const Quaternion &q1, const Quaternion &q2 ); ! inline bool operator!=( const Quaternion &q1, const Quaternion &q2 ); ! ! /// Prints the Quaternion to the given output stream. ! inline std::ostream& operator<<( std::ostream& o, const Quaternion& q ); ! class Quaternion { - private: - real mData[ 4 ]; - public: ! Quaternion() ! { ! mData[ 0 ] = 0; ! mData[ 1 ] = 0; ! mData[ 2 ] = 0; ! mData[ 3 ] = 0; ! } ! ! Quaternion( real w, real x, real y, real z ) ! { ! mData[ 0 ] = w; ! mData[ 1 ] = x; ! mData[ 2 ] = y; ! mData[ 3 ] = z; ! } ! Quaternion( const Quaternion& src ) ! { ! memcpy( mData, src.mData, 4 * sizeof( real ) ); ! } ! inline void set( real w, real x, real y, real z ) ! { ! mData[ 0 ] = w; ! mData[ 1 ] = x; ! mData[ 2 ] = y; ! mData[ 3 ] = z; ! } ! inline real lengthSquared() const ! { ! return mData[ 0 ] * mData[ 0 ] + mData[ 1 ] * mData[ 1 ] + mData[ 2 ] * mData[ 2 ] + ! mData[ 3 ] * mData[ 3 ]; ! } ! inline real length() const ! { ! return sqrt( lengthSquared() ); ! } ! inline void normalize() ! { ! real len = length(); ! assert( 0 != len ); ! real factor = 1 / len; ! ( *this ) = ( *this ) * factor; ! } ! void getAngleAxis( real& angle, Vec3r& axis ) ! { ! real sqrLen = mData[ 1 ] * mData[ 1 ] + mData[ 2 ] * mData[ 2 ] + ! mData[ 3 ] * mData[ 3 ]; ! if ( sqrLen > 0 ) ! { ! angle = 2 * acos( mData[ 0 ] ); ! real invLen = 1 / sqrt( sqrLen ); ! axis[ 0 ] = mData[ 1 ] * invLen; ! axis[ 1 ] = mData[ 2 ] * invLen; ! axis[ 2 ] = mData[ 3 ] * invLen; ! } ! else ! { ! angle = 0; ! axis[ 0 ] = 1; ! axis[ 1 ] = 0; ! axis[ 2 ] = 0; ! } ! // convert to degrees ! angle = radToDeg( angle ); ! } ! real getRoll() const ! { ! return radToDeg( atan2( 2 * ( mData[ 2 ] * mData[ 3 ] + mData[ 0 ] * mData[ 1 ] ), ! mData[ 0 ] * mData[ 0 ] - mData[ 1 ] * mData[ 1 ] - mData[ 2 ] * mData[ 2 ] + ! mData[ 3 ] * mData[ 3 ] ) ); ! } ! real getPitch() const ! { ! return radToDeg( asin( -2 * ( mData[ 1 ] * mData[ 3 ] - mData[ 0 ] * mData[ 2 ] ) ) ); ! } ! real getYaw() const ! { ! return radToDeg( atan2( 2 * ( mData[ 1 ] * mData[ 2 ] + mData[ 0 ] * mData[ 3 ] ), ! mData[ 0 ] * mData[ 0 ] + mData[ 1 ] * mData[ 1 ] - mData[ 2 ] * mData[ 2 ] - ! mData[ 3 ] * mData[ 3 ] ) ); ! } ! inline real & operator[] ( unsigned int i ) ! { ! assert( i < 4 ); ! return mData[ i ]; ! } ! inline const real & operator[] ( unsigned int i ) const ! { ! assert( i < 4 ); ! return mData[ i ]; ! } }; ! inline Quaternion operator+( const Quaternion &q1, const Quaternion &q2 ) ! { ! return Quaternion( q1[ 0 ] + q2[ 0 ], q1[ 1 ] + q2[ 1 ], q1[ 2 ] + q2[ 2 ], q1[ 3 ] + ! q2[ 3 ] ); ! } ! ! inline Quaternion operator-( const Quaternion &q1, const Quaternion &q2 ) ! { ! return Quaternion( q1[ 0 ] - q2[ 0 ], q1[ 1 ] - q2[ 1 ], q1[ 2 ] - q2[ 2 ], q1[ 3 ] - ! q2[ 3 ] ); ! } ! ! inline bool operator==( const Quaternion &q1, const Quaternion &q2 ) ! { ! if ( !areEqual( q1[ 0 ], q2[ 0 ] ) || !areEqual( q1[ 1 ] , q2[ 1 ] ) || ! !areEqual( q1[ 2 ] , q2[ 2 ] ) || !areEqual( q1[ 3 ] , q2[ 3 ] ) ) ! return false; ! else ! return true; ! } ! ! inline bool operator!=( const Quaternion &q1, const Quaternion &q2 ) ! { ! if ( !areEqual( q1[ 0 ], q2[ 0 ] ) || !areEqual( q1[ 1 ] , q2[ 1 ] ) || ! !areEqual( q1[ 2 ] , q2[ 2 ] ) || !areEqual( q1[ 3 ] , q2[ 3 ] ) ) ! return true; ! else ! return false; ! } ! ! inline Quaternion operator*( const Quaternion& q, real scalar ) ! { ! return Quaternion( scalar * q[ 0 ], scalar * q[ 1 ], scalar * q[ 2 ], ! scalar * q[ 3 ] ); ! } ! inline Quaternion operator*( real scalar, const Quaternion& q ) ! { ! return Quaternion( scalar * q[ 0 ], scalar * q[ 1 ], scalar * q[ 2 ], ! scalar * q[ 3 ] ); ! } - inline std::ostream& operator<<( std::ostream& o, const Quaternion& q ) - { - return o << "[" << q[ 0 ] << " " << q[ 1 ] << " " << q[ 2 ] << " " - << q[ 3 ] << "]"; - } } --- 32,87 ---- #include "OpalMath.h" + // system headers + #include <iostream> + namespace opal { ! class Vec3r; ! class Quaternion { public: ! real w; ! real x; ! real y; ! real z; ! Quaternion(); ! Quaternion( real ww, real xx, real yy, real zz ); ! Quaternion( const Quaternion& src ); ! void set( real ww, real xx, real yy, real zz ); ! real lengthSquared() const; ! real length() const; ! void normalize(); ! void getAngleAxis( real& angle, Vec3r& axis ); ! real getRoll() const; ! real getPitch() const; ! real getYaw() const ; ! real & operator[] ( unsigned int i ); ! const real & operator[] ( unsigned int i ) const; }; ! Quaternion operator+( const Quaternion &q1, const Quaternion &q2 ); ! Quaternion operator-( const Quaternion &q1, const Quaternion &q2 ); ! Quaternion operator*( const Quaternion& q, real scalar ); ! Quaternion operator*( real scalar, const Quaternion& q ); ! bool operator==( const Quaternion &q1, const Quaternion &q2 ); ! bool operator!=( const Quaternion &q1, const Quaternion &q2 ); ! /// Prints the Quaternion to the given output stream. ! std::ostream & operator<<( std::ostream& o, const Quaternion& q ); } --- NEW FILE: Quaternion.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // class headers #include "Quaternion.h" // system headers #include <cassert> // project headers #include "Vec3r.h" namespace opal { Quaternion::Quaternion() { w = 0; x = 0; y = 0; z = 0; } Quaternion::Quaternion( real ww, real xx, real yy, real zz ) { w = ww; x = xx; y = yy; z = zz; } Quaternion::Quaternion( const Quaternion& src ) { w = src.w; x = src.x; y = src.y; z = src.z; } void Quaternion::set( real ww, real xx, real yy, real zz ) { w = ww; x = xx; y = yy; z = zz; } real Quaternion::lengthSquared() const { return w * w + x * x + y * y + z * z; } real Quaternion::length() const { return sqrt( lengthSquared() ); } void Quaternion::normalize() { real len = length(); assert( 0 != len ); real factor = 1 / len; ( *this ) = ( *this ) * factor; } void Quaternion::getAngleAxis( real& angle, Vec3r& axis ) { real sqrLen = x * x + y * y + z * z; if ( sqrLen > 0 ) { angle = 2 * acos( w ); real invLen = 1 / sqrt( sqrLen ); axis.x = x * invLen; axis.y = y * invLen; axis.z = z * invLen; } else { angle = 0; axis.x = 1; axis.y = 0; axis.z = 0; } // convert to degrees angle = radToDeg( angle ); } real Quaternion::getRoll() const { return radToDeg( atan2( 2 * ( y * z + w * x ), w * w - x * x - y * y + z * z ) ); } real Quaternion::getPitch() const { return radToDeg( asin( -2 * ( x * z - w * y ) ) ); } real Quaternion::getYaw() const { return radToDeg( atan2( 2 * ( x * y + w * z ), w * w + x * x - y * y - z * z ) ); } real & Quaternion::operator[] ( unsigned int i ) { switch ( i ) { case 0: return w; case 1: return x; case 2: return y; case 3: return z; } assert( i < 4 ); return w; } const real & Quaternion::operator[] ( unsigned int i ) const { switch ( i ) { case 0: return w; case 1: return x; case 2: return y; case 3: return z; } assert( i < 4 ); return w; } Quaternion operator+( const Quaternion &q1, const Quaternion &q2 ) { return Quaternion( q1.w + q2.w, q1.x + q2.x, q1.y + q2.y, q1.z + q2.z ); } Quaternion operator-( const Quaternion &q1, const Quaternion &q2 ) { return Quaternion( q1.w - q2.w, q1.x - q2.x, q1.y - q2.y, q1.z - q2.z ); } bool operator==( const Quaternion &q1, const Quaternion &q2 ) { if ( !areEqual( q1.w, q2.w ) || !areEqual( q1.x , q2.x ) || !areEqual( q1.y , q2.y ) || !areEqual( q1.z , q2.z ) ) return false; else return true; } bool operator!=( const Quaternion &q1, const Quaternion &q2 ) { if ( !areEqual( q1.w, q2.w ) || !areEqual( q1.x , q2.x ) || !areEqual( q1.y , q2.y ) || !areEqual( q1.z , q2.z ) ) return true; else return false; } Quaternion operator*( const Quaternion& q, real scalar ) { return Quaternion( scalar * q.w, scalar * q.x, scalar * q.y, scalar * q.z ); } Quaternion operator*( real scalar, const Quaternion& q ) { return Quaternion( scalar * q.w, scalar * q.x, scalar * q.y, scalar * q.z ); } std::ostream& operator<<( std::ostream& o, const Quaternion& q ) { return o << "[" << q.w << " " << q.x << " " << q.y << " " << q.z << "]"; } } Index: Matrix44r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Matrix44r.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Matrix44r.h 1 Dec 2005 04:54:44 -0000 1.38 --- Matrix44r.h 1 Dec 2005 19:34:03 -0000 1.39 *************** *** 247,252 **** inline void setQuaternion( real w, real x, real y, real z ) { ! if ( !( x == 0 && y == 0 && z == 0 ) ) ! setRotation( radToDeg( w ), x, y, z ); } --- 247,256 ---- inline void setQuaternion( real w, real x, real y, real z ) { ! real angle; ! Vec3r axis; ! Quaternion q( w, x, y, z ); ! q.getAngleAxis( angle, axis ); ! ! setRotation( angle, axis.x, axis.y, axis.z ); } |
|
From: Olex <ole...@us...> - 2005-12-01 19:34:14
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19201 Modified Files: changelog.txt Log Message: Fixed Matrix44r::setQuaternion(). Refactored Quaternion. More unit tests. Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** changelog.txt 1 Dec 2005 04:54:44 -0000 1.53 --- changelog.txt 1 Dec 2005 19:34:03 -0000 1.54 *************** *** 15,18 **** --- 15,21 ---- ------------------------------------------ + * 12-1-05: Fixed Matrix44r::setQuaternion(). Refactored Quaternion. + More unit tests. (Oleksandr Lozitskiy) + * 12-1-05: Added Solid::setQuaternion and Matrix44r::setQuaternion as well as a few unit tests. (Oleksandr Lozitskiy) |
|
From: Olex <ole...@us...> - 2005-12-01 04:54:53
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6648 Modified Files: changelog.txt Log Message: Solid::setQuaternion and Matrix44r:setQuaternion initial draft. Added unit tests for Quaternion. Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** changelog.txt 1 Dec 2005 02:04:54 -0000 1.52 --- changelog.txt 1 Dec 2005 04:54:44 -0000 1.53 *************** *** 11,18 **** ! Version 0.3.2 (possibly 0.4.0 ?) (not yet released) ------------------------------------------ * 11-30-05: Implemented Solid::setMass, added unit tests to test it. (Oleksandr Lozitskiy) --- 11,21 ---- ! Version 0.4.0 (not yet released) ------------------------------------------ + * 12-1-05: Added Solid::setQuaternion and Matrix44r::setQuaternion as + well as a few unit tests. (Oleksandr Lozitskiy) + * 11-30-05: Implemented Solid::setMass, added unit tests to test it. (Oleksandr Lozitskiy) *************** *** 29,36 **** QuickTest header. (Oleksandr Lozitskiy) ! * 11-6-06: Added KDevelop project files. Added skeleton for unit tests. Added quicktest to external headers. (Oleksandr Lozitskiy) ! * 11-6-06: Refactoring Solid interface. Made a few method const. (Oleksandr Lozitskiy) --- 32,39 ---- QuickTest header. (Oleksandr Lozitskiy) ! * 11-6-05: Added KDevelop project files. Added skeleton for unit tests. Added quicktest to external headers. (Oleksandr Lozitskiy) ! * 11-6-05: Refactoring Solid interface. Made a few method const. (Oleksandr Lozitskiy) |
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6648/src Modified Files: Makefile.am Makefile.in Matrix44r.h Quaternion.h Solid.cpp Solid.h testsolid.cpp Added Files: testQuaternion.cpp Log Message: Solid::setQuaternion and Matrix44r:setQuaternion initial draft. Added unit tests for Quaternion. Index: Solid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Solid.cpp 6 Nov 2005 05:12:21 -0000 1.39 --- Solid.cpp 1 Dec 2005 04:54:44 -0000 1.40 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "Solid.h" --- 1,28 ---- /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "Solid.h" *************** *** 30,318 **** namespace opal { ! Solid::Solid() ! { ! // "mData" is initialized in its own constructor. ! setCollisionEventHandler(NULL); ! setUserData(NULL); ! resetAABB(); ! } ! Solid::~Solid() ! { ! mForceList.clear(); ! } ! void Solid::internal_destroy() ! { ! delete this; ! } ! const SolidData& Solid::getData() ! { ! // Update parameters that don't get updated automatically. ! mData.sleeping = isSleeping(); ! return mData; ! } ! void Solid::setName(const std::string& name) ! { ! mData.name = name; ! } ! const std::string& Solid::getName()const ! { ! return mData.name; ! } ! bool Solid::isEnabled()const ! { ! return mData.enabled; ! } ! void Solid::setEnabled(bool e) ! { ! mData.enabled = e; ! } ! bool Solid::isStatic()const ! { ! return mData.isStatic; ! } ! void Solid::setSleepiness(real s) ! { ! assert(s >= 0.0 && s <= 1.0); ! mData.sleepiness = s; ! } ! real Solid::getSleepiness()const ! { ! return mData.sleepiness; ! } ! void Solid::setLinearDamping(real ld) ! { ! assert(ld >= 0.0); ! mData.linearDamping = ld; ! } ! real Solid::getLinearDamping()const ! { ! return mData.linearDamping; ! } ! void Solid::setAngularDamping(real ad) ! { ! assert(ad >= 0.0); ! mData.angularDamping = ad; ! } ! real Solid::getAngularDamping()const ! { ! return mData.angularDamping; ! } ! void Solid::setUserData(void* data) ! { ! mUserData = data; ! } ! void* Solid::getUserData()const ! { ! return mUserData; ! } ! void Solid::setTransform(const Matrix44r& t) ! { ! mData.transform = t; ! internal_updateEngineTransform(); ! } ! const Matrix44r& Solid::getTransform()const ! { ! return mData.transform; ! } ! void Solid::setPosition(real x, real y, real z) ! { ! mData.transform.setPosition(x, y, z); ! internal_updateEngineTransform(); ! } ! void Solid::setPosition(const Point3r & p) ! { ! setPosition(p[0], p[1], p[2]); ! } ! Point3r Solid::getPosition()const ! { ! return mData.transform.getPosition(); ! } ! Vec3r Solid::getEulerXYZ()const ! { ! return mData.transform.getEulerXYZ(); ! } ! Quaternion Solid::getQuaternion()const ! { ! return mData.transform.getQuaternion(); ! } ! void Solid::getLocalAABB(real aabb[6])const { ! for (unsigned int i = 0; i < 6; ++i) ! { ! aabb[i] = mLocalAABB[i]; ! } } ! void Solid::getGlobalAABB(real aabb[6])const ! { ! Point3r minExtents(mLocalAABB[0], mLocalAABB[2], mLocalAABB[4]); ! Point3r maxExtents(mLocalAABB[1], mLocalAABB[3], mLocalAABB[5]); ! // Transform the AABB extents to global coordinates. ! minExtents = mData.transform * minExtents; ! maxExtents = mData.transform * maxExtents; ! aabb[0] = minExtents[0]; ! aabb[1] = maxExtents[0]; ! aabb[2] = minExtents[1]; ! aabb[3] = maxExtents[1]; ! aabb[4] = minExtents[2]; ! aabb[5] = maxExtents[2]; ! } ! //void Solid::addPlane(const Point3r& point, const Vec3r& normal, const Material& m) ! //{ ! // Point3r origin(0, 0, 0); ! // Vec3r n = normal; ! // n.normalize(); ! // Vec3r v = point - origin; ! // ! // real angle = 0; ! // if (0 != v.length()) ! // { ! // v.normalize(); ! // angle = acos(dot(n,v)); // note: this only works when the two vectors are normalized ! // } ! // ! // real length = distance(point, origin); ! // real D = length * cos(angle); ! // real abcd[4] = {n[0], n[1], n[2], D}; ! // addPlane(abcd, m); ! //} ! void Solid::addForce(const Force& f) ! { ! if (mData.enabled && !mData.isStatic && ! !areEqual(f.vec.lengthSquared(), 0)) ! { ! mForceList.push_back(f); ! } ! } ! void Solid::internal_applyForces(real stepSize) ! { ! if (mData.isStatic) ! { ! return; ! } ! // If there are Forces to apply and the Solid is asleep, wake it up. ! if(!mForceList.empty() && isSleeping()) ! { ! setSleeping(false); ! } ! real invStepSize = 1 / stepSize; ! for (unsigned int i = 0; i < mForceList.size();) ! { ! if (true == mForceList[i].singleStep) ! { ! mForceList[i].duration = stepSize; ! } ! else if (mForceList[i].duration < stepSize) ! { ! // Scale the size of the force/torque. ! mForceList[i].vec *= (mForceList[i].duration * invStepSize); ! } ! // Apply the actual force/torque. ! applyForce(mForceList[i]); ! // The following is ok for all cases (even when duration is ! // < mStepSize). ! mForceList[i].duration -= stepSize; ! if (mForceList[i].duration <= 0) ! { ! // Delete this force. ! mForceList[i] = mForceList.back(); ! mForceList.pop_back(); ! } ! else ! { ! ++i; ! } ! } ! } ! void Solid::setCollisionEventHandler(CollisionEventHandler* eventHandler) ! { ! mCollisionEventHandler = eventHandler; ! } ! CollisionEventHandler* Solid::getCollisionEventHandler()const ! { ! return mCollisionEventHandler; ! } ! void Solid::addToLocalAABB(const real aabb[6]) ! { ! // Loop over the 3 dimensions of the AABB's extents. ! for (unsigned int i = 0; i < 3; ++i) ! { ! if (aabb[i * 2] < mLocalAABB[i * 2]) ! { ! mLocalAABB[i * 2] = aabb[i * 2]; ! } ! if (aabb[i * 2 + 1] > mLocalAABB[i * 2 + 1]) ! { ! mLocalAABB[i * 2 + 1] = aabb[i * 2 + 1]; ! } ! } ! } ! void Solid::resetAABB() ! { ! for (unsigned int i = 0; i < 6; ++i) ! { ! mLocalAABB[i] = 0; ! } ! } ! //void Solid::internal_updateSleeping() ! //{ ! // mData.sleeping = isSleeping(); ! //} ! //// TODO: Quickly spinning solids should be set as fast rotating solids to ! //// improve simulation accuracy. ! //void Solid::setFastRotation(bool fast) ! //{ ! //} ! //bool Solid::getFastRotation()const ! //{ ! // return false; ! //} ! //void Solid::setFastRotationAxis(Vec3r axis) ! //{ ! //} } --- 30,330 ---- namespace opal { ! Solid::Solid() ! { ! // "mData" is initialized in its own constructor. ! setCollisionEventHandler( NULL ); ! setUserData( NULL ); ! resetAABB(); ! } ! Solid::~Solid() ! { ! mForceList.clear(); ! } ! void Solid::internal_destroy() ! { ! delete this; ! } ! const SolidData& Solid::getData() ! { ! // Update parameters that don't get updated automatically. ! mData.sleeping = isSleeping(); ! return mData; ! } ! void Solid::setName( const std::string& name ) ! { ! mData.name = name; ! } ! const std::string& Solid::getName() const ! { ! return mData.name; ! } ! bool Solid::isEnabled() const ! { ! return mData.enabled; ! } ! void Solid::setEnabled( bool e ) ! { ! mData.enabled = e; ! } ! bool Solid::isStatic() const ! { ! return mData.isStatic; ! } ! void Solid::setSleepiness( real s ) ! { ! assert( s >= 0.0 && s <= 1.0 ); ! mData.sleepiness = s; ! } ! real Solid::getSleepiness() const ! { ! return mData.sleepiness; ! } ! void Solid::setLinearDamping( real ld ) ! { ! assert( ld >= 0.0 ); ! mData.linearDamping = ld; ! } ! real Solid::getLinearDamping() const ! { ! return mData.linearDamping; ! } ! void Solid::setAngularDamping( real ad ) ! { ! assert( ad >= 0.0 ); ! mData.angularDamping = ad; ! } ! real Solid::getAngularDamping() const ! { ! return mData.angularDamping; ! } ! void Solid::setUserData( void* data ) ! { ! mUserData = data; ! } ! void* Solid::getUserData() const ! { ! return mUserData; ! } ! void Solid::setTransform( const Matrix44r& t ) ! { ! mData.transform = t; ! internal_updateEngineTransform(); ! } ! const Matrix44r& Solid::getTransform() const ! { ! return mData.transform; ! } ! void Solid::setPosition( real x, real y, real z ) ! { ! mData.transform.setPosition( x, y, z ); ! internal_updateEngineTransform(); ! } ! void Solid::setPosition( const Point3r & p ) ! { ! setPosition( p[ 0 ], p[ 1 ], p[ 2 ] ); ! } ! Point3r Solid::getPosition() const ! { ! return mData.transform.getPosition(); ! } ! Vec3r Solid::getEulerXYZ() const ! { ! return mData.transform.getEulerXYZ(); ! } ! Quaternion Solid::getQuaternion() const ! { ! return mData.transform.getQuaternion(); ! } ! void Solid::setQuaternion( const Quaternion & q ) ! { ! mData.transform.setQuaternion( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] ); ! internal_updateEngineTransform(); ! } ! ! void Solid::setQuaternion( real w, real x, real y, real z ) { ! mData.transform.setQuaternion( w, x, y, z ); ! internal_updateEngineTransform(); } ! void Solid::getLocalAABB( real aabb[ 6 ] ) const ! { ! for ( unsigned int i = 0; i < 6; ++i ) ! { ! aabb[ i ] = mLocalAABB[ i ]; ! } ! } ! void Solid::getGlobalAABB( real aabb[ 6 ] ) const ! { ! Point3r minExtents( mLocalAABB[ 0 ], mLocalAABB[ 2 ], mLocalAABB[ 4 ] ); ! Point3r maxExtents( mLocalAABB[ 1 ], mLocalAABB[ 3 ], mLocalAABB[ 5 ] ); ! // Transform the AABB extents to global coordinates. ! minExtents = mData.transform * minExtents; ! maxExtents = mData.transform * maxExtents; ! aabb[ 0 ] = minExtents[ 0 ]; ! aabb[ 1 ] = maxExtents[ 0 ]; ! aabb[ 2 ] = minExtents[ 1 ]; ! aabb[ 3 ] = maxExtents[ 1 ]; ! aabb[ 4 ] = minExtents[ 2 ]; ! aabb[ 5 ] = maxExtents[ 2 ]; ! } ! //void Solid::addPlane(const Point3r& point, const Vec3r& normal, const Material& m) ! //{ ! // Point3r origin(0, 0, 0); ! // Vec3r n = normal; ! // n.normalize(); ! // Vec3r v = point - origin; ! // ! // real angle = 0; ! // if (0 != v.length()) ! // { ! // v.normalize(); ! // angle = acos(dot(n,v)); // note: this only works when the two vectors are normalized ! // } ! // ! // real length = distance(point, origin); ! // real D = length * cos(angle); ! // real abcd[4] = {n[0], n[1], n[2], D}; ! // addPlane(abcd, m); ! //} ! void Solid::addForce( const Force& f ) ! { ! if ( mData.enabled && !mData.isStatic && ! !areEqual( f.vec.lengthSquared(), 0 ) ) ! { ! mForceList.push_back( f ); ! } ! } ! void Solid::internal_applyForces( real stepSize ) ! { ! if ( mData.isStatic ) ! { ! return ; ! } ! // If there are Forces to apply and the Solid is asleep, wake it up. ! if ( !mForceList.empty() && isSleeping() ) ! { ! setSleeping( false ); ! } ! real invStepSize = 1 / stepSize; ! for ( unsigned int i = 0; i < mForceList.size(); ) ! { ! if ( true == mForceList[ i ].singleStep ) ! { ! mForceList[ i ].duration = stepSize; ! } ! else if ( mForceList[ i ].duration < stepSize ) ! { ! // Scale the size of the force/torque. ! mForceList[ i ].vec *= ( mForceList[ i ].duration * invStepSize ); ! } ! // Apply the actual force/torque. ! applyForce( mForceList[ i ] ); ! // The following is ok for all cases (even when duration is ! // < mStepSize). ! mForceList[ i ].duration -= stepSize; ! if ( mForceList[ i ].duration <= 0 ) ! { ! // Delete this force. ! mForceList[ i ] = mForceList.back(); ! mForceList.pop_back(); ! } ! else ! { ! ++i; ! } ! } ! } ! void Solid::setCollisionEventHandler( CollisionEventHandler* eventHandler ) ! { ! mCollisionEventHandler = eventHandler; ! } ! CollisionEventHandler* Solid::getCollisionEventHandler() const ! { ! return mCollisionEventHandler; ! } ! void Solid::addToLocalAABB( const real aabb[ 6 ] ) ! { ! // Loop over the 3 dimensions of the AABB's extents. ! for ( unsigned int i = 0; i < 3; ++i ) ! { ! if ( aabb[ i * 2 ] < mLocalAABB[ i * 2 ] ) ! { ! mLocalAABB[ i * 2 ] = aabb[ i * 2 ]; ! } ! if ( aabb[ i * 2 + 1 ] > mLocalAABB[ i * 2 + 1 ] ) ! { ! mLocalAABB[ i * 2 + 1 ] = aabb[ i * 2 + 1 ]; ! } ! } ! } ! void Solid::resetAABB() ! { ! for ( unsigned int i = 0; i < 6; ++i ) ! { ! mLocalAABB[ i ] = 0; ! } ! } ! //void Solid::internal_updateSleeping() ! //{ ! // mData.sleeping = isSleeping(); ! //} ! //// TODO: Quickly spinning solids should be set as fast rotating solids to ! //// improve simulation accuracy. ! //void Solid::setFastRotation(bool fast) ! //{ ! //} ! //bool Solid::getFastRotation()const ! //{ ! // return false; ! //} ! ! //void Solid::setFastRotationAxis(Vec3r axis) ! //{ ! //} } Index: Makefile.in =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.in 1 Dec 2005 02:04:54 -0000 1.5 --- Makefile.in 1 Dec 2005 04:54:44 -0000 1.6 *************** *** 70,74 **** testAccelerationSensor.$(OBJEXT) testRaycastSensor.$(OBJEXT) \ testSimulator.$(OBJEXT) testVec3r.$(OBJEXT) \ ! testPoint3r.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ --- 70,74 ---- testAccelerationSensor.$(OBJEXT) testRaycastSensor.$(OBJEXT) \ testSimulator.$(OBJEXT) testVec3r.$(OBJEXT) \ ! testPoint3r.$(OBJEXT) testQuaternion.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ *************** *** 212,216 **** test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ --- 212,216 ---- test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ *************** *** 320,323 **** --- 320,324 ---- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testAccelerationSensor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testPoint3r.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testQuaternion.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testRaycastSensor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testSimulator.Po@am__quote@ --- NEW FILE: testQuaternion.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // system headers #include <quicktest.h> // project headers #include "opal.h" using namespace opal; namespace testQuaternion { QT_TEST( default_constructor ) { Quaternion q; QT_CHECK_EQUAL( q[ 0 ], 0 ); QT_CHECK_EQUAL( q[ 1 ], 0 ); QT_CHECK_EQUAL( q[ 2 ], 0 ); QT_CHECK_EQUAL( q[ 3 ], 0 ); } QT_TEST( constructor ) { Quaternion q( 1, 2, 3, 4 ); QT_CHECK_EQUAL( q[ 0 ], 1 ); QT_CHECK_EQUAL( q[ 1 ], 2 ); QT_CHECK_EQUAL( q[ 2 ], 3 ); QT_CHECK_EQUAL( q[ 3 ], 4 ); } QT_TEST( operator_equal ) { QT_CHECK_EQUAL( Quaternion( 0, 0, 0, 0 ), Quaternion( 0, 0, 0, 0 ) ); QT_CHECK_EQUAL( Quaternion( 0, 0, 0, 1 ), Quaternion( 0, 0, 0, 1 ) ); QT_CHECK_EQUAL( Quaternion( 0, 0, 1, 2 ), Quaternion( 0, 0, 1, 2 ) ); QT_CHECK_EQUAL( Quaternion( 1, 2, 0, 3 ), Quaternion( 1, 2, 0, 3 ) ); } QT_TEST( operator_not_equal ) { QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 0, 0 ), Quaternion( 1, 0, 0, 0 ) ); QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 0, 1 ), Quaternion( 0, 1, 0, 0 ) ); QT_CHECK_NOT_EQUAL( Quaternion( 0, 0, 1, 2 ), Quaternion( 4, 5, 0, 2 ) ); QT_CHECK_NOT_EQUAL( Quaternion( 1, 2, 0, 3 ), Quaternion( 1, 0, 2, 3 ) ); } } Index: testsolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testsolid.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** testsolid.cpp 1 Dec 2005 02:04:54 -0000 1.4 --- testsolid.cpp 1 Dec 2005 04:54:44 -0000 1.5 *************** *** 216,220 **** Matrix44r m_set = f.s->getInertiaTensor(); QT_CHECK_EQUAL( m, m_set ); ! QT_CHECK_CLOSE( f.s->getMass(), mass.mass, 0.001 ); mass.mass = 2; --- 216,220 ---- Matrix44r m_set = f.s->getInertiaTensor(); QT_CHECK_EQUAL( m, m_set ); ! QT_CHECK_CLOSE( f.s->getMass(), mass.mass, 0.001 ); mass.mass = 2; *************** *** 223,225 **** --- 223,237 ---- QT_CHECK_CLOSE( f.s->getMass(), mass.mass, 0.001 ); } + + QT_TEST( setQuaternion_Q ) + { + SolidBoxFixture f; + Quaternion q = f.s->getQuaternion(); + f.s->setQuaternion( q ); + QT_CHECK_EQUAL( q, f.s->getQuaternion() ); + + q.set( 1, 0, 0, 0 ); + f.s->setQuaternion( q ); + QT_CHECK_EQUAL( q, f.s->getQuaternion() ); + } } Index: Makefile.am =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 1 Dec 2005 02:04:54 -0000 1.5 --- Makefile.am 1 Dec 2005 04:54:44 -0000 1.6 *************** *** 15,19 **** bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode --- 15,19 ---- bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** Solid.h 1 Dec 2005 02:04:54 -0000 1.93 --- Solid.h 1 Dec 2005 04:54:44 -0000 1.94 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #ifndef OPAL_SOLID_H --- 1,28 ---- /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #ifndef OPAL_SOLID_H *************** *** 35,281 **** namespace opal { ! class Mass; ! class Simulator; ! class Space; ! class ShapeData; ! /// Solids are the physical objects in a simulation. Solids can be ! /// static or dynamic: basically, dynamic Solids move, and static Solids ! /// don't move. (Static Solids can still be positioned manually.) All ! /// Solids start out enabled, but they don't do much until Shapes are ! /// added. ! class Solid ! { ! public: ! Solid(); ! /// Initializes the Solid with the given data structure. Calling ! /// this more than once will automatically destroy all the old ! /// Shapes before adding new ones. ! virtual void OPAL_CALL init(const SolidData& data) = 0; ! /// Returns all data describing the Solid. ! virtual const SolidData& OPAL_CALL getData(); ! /// Sets the Solid's name. ! virtual void OPAL_CALL setName(const std::string& name); ! /// Returns the Solid's name. ! virtual const std::string& OPAL_CALL getName()const; ! /// Returns true if the Solid is enabled. ! virtual bool OPAL_CALL isEnabled()const; ! /// Sets whether the Solid can collide with other Solids and be ! /// physically simulated. Forces applied to this Solid while ! /// disabled will be ignored. ! virtual void OPAL_CALL setEnabled(bool e); ! /// Returns true if this is a static Solid. ! virtual bool OPAL_CALL isStatic()const; ! /// Sets whether the Solid should be static or dynamic. ! virtual void OPAL_CALL setStatic(bool s) = 0; ! /// Removes the Solid from its current Space and adds it to the new ! /// Space. ! virtual void OPAL_CALL setSpace(Space* newSpace) = 0; ! /// Sets whether the Solid is sleeping (i.e. set this to false to ! /// wake up a sleeping Solid). ! virtual void OPAL_CALL setSleeping(bool sleeping) = 0; ! /// Returns true if the Solid is sleeping. If the Solid is static, ! /// this will always return true. ! virtual bool OPAL_CALL isSleeping()const = 0; ! /// Sets the Solid's sleepiness level. ! virtual void OPAL_CALL setSleepiness(real s); ! /// Returns the Solid's sleepiness level. ! virtual real OPAL_CALL getSleepiness()const; ! /// Sets the amount of linear damping on this Solid. ! virtual void OPAL_CALL setLinearDamping(real ld); ! /// Returns the amount of linear damping on this Solid. ! virtual real OPAL_CALL getLinearDamping()const; ! /// Sets the amount of angular damping on this Solid. ! virtual void OPAL_CALL setAngularDamping(real ad); ! /// Returns the amount of angular damping on this Solid. ! virtual real OPAL_CALL getAngularDamping()const; ! /// Set this Solid's user data pointer to some external data. This ! /// can be used to let the Solid point to some user object (e.g. an ! /// object with a visual mesh). The user data is totally user-managed ! /// (i.e. it is not destroyed when the Solid is destroyed). ! virtual void OPAL_CALL setUserData(void* data); ! /// Returns the user data pointer (NULL if it has not been set). ! virtual void* OPAL_CALL getUserData()const; ! /// Sets this Solid's transform matrix. ! virtual void OPAL_CALL setTransform(const Matrix44r& t); ! /// Returns a constant reference to this Solid's transform. ! virtual const Matrix44r& OPAL_CALL getTransform()const; ! /// Sets the position of this Solid in global coordinates. ! virtual void OPAL_CALL setPosition(real x, real y, real z); ! /// Sets the position of this Solid in global coordinates. ! virtual void OPAL_CALL setPosition(const Point3r & p); ! /// Returns the position of this Solid in global coordinates. ! virtual Point3r OPAL_CALL getPosition()const; ! /// Returns the euler angles of the Solid's orientation. ! virtual Vec3r OPAL_CALL getEulerXYZ()const; ! /// Returns a quaternion representing the Solid's orientation. ! virtual Quaternion OPAL_CALL getQuaternion()const; ! /// Returns the axis-aligned bounding box for all of the Solid's ! /// shapes relative to the Solid. ! virtual void OPAL_CALL getLocalAABB(real aabb[6])const; ! /// Returns the axis-aligned bounding box for all of the Solid's ! /// shapes in global coordinates. ! virtual void OPAL_CALL getGlobalAABB(real aabb[6])const; ! /// Removes all shapes from this Solid. Resets the Solid's ! /// axis-aligned bounding box. ! virtual void OPAL_CALL clearShapes() = 0; ! /// Adds a Shape to this Solid. Updates the Solid's axis-aligned ! /// bounding box. ! virtual void OPAL_CALL addShape(ShapeData& data) = 0; ! /// Applies a force/torque to this Solid. If the Solid is disabled, ! /// the Solid is static, or the magnitude of the force/torque is ! /// zero, this will do nothing. ! virtual void OPAL_CALL addForce(const Force& f); ! /// Removes all forces and torques currently affecting this Solid. ! virtual void OPAL_CALL zeroForces() = 0; ! /// Sets the Solid's linear velocity in local coordinates. ! virtual void OPAL_CALL setLocalLinearVel(const Vec3r& vel) = 0; ! /// Returns the Solid's linear velocity in local coordinates. ! virtual Vec3r OPAL_CALL getLocalLinearVel()const = 0; ! /// Given an offset point relative to the Solid's local origin, ! /// returns the linear velocity of the point in local coordinates. ! virtual Vec3r OPAL_CALL getLocalLinearVelAtLocalPos( ! const Point3r& p)const = 0; ! /// Sets the Solid's angular velocity in local coordinates. ! virtual void OPAL_CALL setLocalAngularVel(const Vec3r& vel) = 0; ! /// Returns the Solid's angular velocity in local coordinates. ! virtual Vec3r OPAL_CALL getLocalAngularVel()const = 0; ! /// Sets the Solid's linear velocity in global coordinates. ! virtual void OPAL_CALL setGlobalLinearVel(const Vec3r& vel) = 0; ! /// Returns the Solid's linear velocity in global coordinates. ! virtual Vec3r OPAL_CALL getGlobalLinearVel()const = 0; ! /// Given an offset point relative to the Solid's local origin, ! /// returns the linear velocity of the point in global coordinates. ! virtual Vec3r OPAL_CALL getGlobalLinearVelAtLocalPos( ! const Point3r& p)const = 0; ! /// Sets the Solid's angular velocity in global coordinates. ! virtual void OPAL_CALL setGlobalAngularVel(const Vec3r& vel) = 0; ! /// Returns the Solid's angular velocity in global coordinates. ! virtual Vec3r OPAL_CALL getGlobalAngularVel()const = 0; ! /// Set a new mass, center, and intertia for the solid. ! virtual void OPAL_CALL setMass( const Mass & newmass, const Matrix44r & offset ) = 0; ! /// Translate the Solid's mass using the given offset vector ! /// specified in global coordinates. ! virtual void OPAL_CALL translateMass(const Vec3r& offset) = 0; ! /// Sets the Solid's collision event handler. ! virtual void OPAL_CALL setCollisionEventHandler( ! CollisionEventHandler* eventHandler); ! /// Returns the Solid's collision event handler. If this returns ! /// NULL, the Solid is not using one. ! virtual CollisionEventHandler* OPAL_CALL ! getCollisionEventHandler()const; ! //// Quickly spinning solids should be set as fast rotating solids to ! //// improve simulation accuracy. ! //virtual void OPAL_CALL setFastRotation(bool fast); ! //virtual bool OPAL_CALL getFastRotation()const; ! //virtual void OPAL_CALL setFastRotationAxis(Vec3r axis); ! /// Returns the Solid's mass. This will return 0 if the Solid ! /// is static. ! virtual real OPAL_CALL getMass()const = 0; ! /// Returns the Solid's inertia tensor as a 4x4 matrix. This will ! /// be the identity matrix if the Solid is static. ! virtual Matrix44r OPAL_CALL getInertiaTensor()const = 0; ! /// Update the OPAL transform using the physics engine transform. ! virtual void OPAL_CALL internal_updateOPALTransform() = 0; ! /// Update the physics engine transform using the OPAL transform. ! virtual void OPAL_CALL internal_updateEngineTransform() = 0; ! /// Loops over the Solid's list of Forces and applies them. ! virtual void OPAL_CALL internal_applyForces(real stepSize); ! /// Updates the SolidData sleeping value from the physics engine. ! void internal_updateSleeping(); ! /// Internal function used to destroy this object. ! virtual void OPAL_CALL internal_destroy(); ! protected: ! virtual ~Solid(); ! /// Physics engine-specific function for applying Forces to ! /// Solids. ! virtual void applyForce(const Force& f) = 0; ! /// Adds the given axis-aligned bounding box to the Solid's AABB. ! void addToLocalAABB(const real aabb[6]); ! /// Resets the Solid's axis-aligned bounding box. ! void resetAABB(); ! /// An internal list of this Solid's pending Forces. ! std::vector<Force> mForceList; ! /// Stores data describing the Solid. ! SolidData mData; ! /// The axis-aligned bounding box of all shapes in local ! /// coordinates. This array stores data in the following order: ! /// min x, max x, min y, max y, min z, max z. This gets updated ! /// whenever a shape is added or removed. ! real mLocalAABB[6]; ! /// Pointer to this Solid's collision event handler. ! CollisionEventHandler* mCollisionEventHandler; ! /// Pointer to user data. This is totally user-managed (i.e. OPAL ! /// will never delete it). ! void* mUserData; ! /// Data used for ! private: ! }; } --- 35,287 ---- namespace opal { ! class Mass; ! class Simulator; ! class Space; ! class ShapeData; ! /// Solids are the physical objects in a simulation. Solids can be ! /// static or dynamic: basically, dynamic Solids move, and static Solids ! /// don't move. (Static Solids can still be positioned manually.) All ! /// Solids start out enabled, but they don't do much until Shapes are ! /// added. ! class Solid ! { ! public: ! Solid(); ! /// Initializes the Solid with the given data structure. Calling ! /// this more than once will automatically destroy all the old ! /// Shapes before adding new ones. ! virtual void OPAL_CALL init( const SolidData& data ) = 0; ! /// Returns all data describing the Solid. ! virtual const SolidData& OPAL_CALL getData(); ! /// Sets the Solid's name. ! virtual void OPAL_CALL setName( const std::string& name ); ! /// Returns the Solid's name. ! virtual const std::string& OPAL_CALL getName() const; ! /// Returns true if the Solid is enabled. ! virtual bool OPAL_CALL isEnabled() const; ! /// Sets whether the Solid can collide with other Solids and be ! /// physically simulated. Forces applied to this Solid while ! /// disabled will be ignored. ! virtual void OPAL_CALL setEnabled( bool e ); ! /// Returns true if this is a static Solid. ! virtual bool OPAL_CALL isStatic() const; ! /// Sets whether the Solid should be static or dynamic. ! virtual void OPAL_CALL setStatic( bool s ) = 0; ! /// Removes the Solid from its current Space and adds it to the new ! /// Space. ! virtual void OPAL_CALL setSpace( Space* newSpace ) = 0; ! /// Sets whether the Solid is sleeping (i.e. set this to false to ! /// wake up a sleeping Solid). ! virtual void OPAL_CALL setSleeping( bool sleeping ) = 0; ! /// Returns true if the Solid is sleeping. If the Solid is static, ! /// this will always return true. ! virtual bool OPAL_CALL isSleeping() const = 0; ! /// Sets the Solid's sleepiness level. ! virtual void OPAL_CALL setSleepiness( real s ); ! /// Returns the Solid's sleepiness level. ! virtual real OPAL_CALL getSleepiness() const; ! /// Sets the amount of linear damping on this Solid. ! virtual void OPAL_CALL setLinearDamping( real ld ); ! /// Returns the amount of linear damping on this Solid. ! virtual real OPAL_CALL getLinearDamping() const; ! /// Sets the amount of angular damping on this Solid. ! virtual void OPAL_CALL setAngularDamping( real ad ); ! /// Returns the amount of angular damping on this Solid. ! virtual real OPAL_CALL getAngularDamping() const; ! /// Set this Solid's user data pointer to some external data. This ! /// can be used to let the Solid point to some user object (e.g. an ! /// object with a visual mesh). The user data is totally user-managed ! /// (i.e. it is not destroyed when the Solid is destroyed). ! virtual void OPAL_CALL setUserData( void* data ); ! /// Returns the user data pointer (NULL if it has not been set). ! virtual void* OPAL_CALL getUserData() const; ! /// Sets this Solid's transform matrix. ! virtual void OPAL_CALL setTransform( const Matrix44r& t ); ! /// Returns a constant reference to this Solid's transform. ! virtual const Matrix44r& OPAL_CALL getTransform() const; ! /// Sets the position of this Solid in global coordinates. ! virtual void OPAL_CALL setPosition( real x, real y, real z ); ! /// Sets the position of this Solid in global coordinates. ! virtual void OPAL_CALL setPosition( const Point3r & p ); ! /// Returns the position of this Solid in global coordinates. ! virtual Point3r OPAL_CALL getPosition() const; ! /// Returns the euler angles of the Solid's orientation. ! virtual Vec3r OPAL_CALL getEulerXYZ() const; ! /// Returns a quaternion representing the Solid's orientation. ! virtual Quaternion OPAL_CALL getQuaternion() const; ! /// Sets a quaternion representing the Solid's orientation. ! virtual void OPAL_CALL setQuaternion( const Quaternion & q ); ! /// Sets a quaternion representing the Solid's orientation. ! virtual void OPAL_CALL setQuaternion( real w, real x, real y, real z ); ! /// Returns the axis-aligned bounding box for all of the Solid's ! /// shapes relative to the Solid. ! virtual void OPAL_CALL getLocalAABB( real aabb[ 6 ] ) const; ! /// Returns the axis-aligned bounding box for all of the Solid's ! /// shapes in global coordinates. ! virtual void OPAL_CALL getGlobalAABB( real aabb[ 6 ] ) const; ! /// Removes all shapes from this Solid. Resets the Solid's ! /// axis-aligned bounding box. ! virtual void OPAL_CALL clearShapes() = 0; ! /// Adds a Shape to this Solid. Updates the Solid's axis-aligned ! /// bounding box. ! virtual void OPAL_CALL addShape( ShapeData& data ) = 0; ! /// Applies a force/torque to this Solid. If the Solid is disabled, ! /// the Solid is static, or the magnitude of the force/torque is ! /// zero, this will do nothing. ! virtual void OPAL_CALL addForce( const Force& f ); ! /// Removes all forces and torques currently affecting this Solid. ! virtual void OPAL_CALL zeroForces() = 0; ! /// Sets the Solid's linear velocity in local coordinates. ! virtual void OPAL_CALL setLocalLinearVel( const Vec3r& vel ) = 0; ! /// Returns the Solid's linear velocity in local coordinates. ! virtual Vec3r OPAL_CALL getLocalLinearVel() const = 0; ! /// Given an offset point relative to the Solid's local origin, ! /// returns the linear velocity of the point in local coordinates. ! virtual Vec3r OPAL_CALL getLocalLinearVelAtLocalPos( ! const Point3r& p ) const = 0; ! /// Sets the Solid's angular velocity in local coordinates. ! virtual void OPAL_CALL setLocalAngularVel( const Vec3r& vel ) = 0; ! /// Returns the Solid's angular velocity in local coordinates. ! virtual Vec3r OPAL_CALL getLocalAngularVel() const = 0; ! /// Sets the Solid's linear velocity in global coordinates. ! virtual void OPAL_CALL setGlobalLinearVel( const Vec3r& vel ) = 0; ! /// Returns the Solid's linear velocity in global coordinates. ! virtual Vec3r OPAL_CALL getGlobalLinearVel() const = 0; ! /// Given an offset point relative to the Solid's local origin, ! /// returns the linear velocity of the point in global coordinates. ! virtual Vec3r OPAL_CALL getGlobalLinearVelAtLocalPos( ! const Point3r& p ) const = 0; ! /// Sets the Solid's angular velocity in global coordinates. ! virtual void OPAL_CALL setGlobalAngularVel( const Vec3r& vel ) = 0; ! /// Returns the Solid's angular velocity in global coordinates. ! virtual Vec3r OPAL_CALL getGlobalAngularVel() const = 0; ! /// Set a new mass, center, and intertia for the solid. ! virtual void OPAL_CALL setMass( const Mass & newmass, const Matrix44r & offset ) = 0; ! /// Translate the Solid's mass using the given offset vector ! /// specified in global coordinates. ! virtual void OPAL_CALL translateMass( const Vec3r& offset ) = 0; ! /// Sets the Solid's collision event handler. ! virtual void OPAL_CALL setCollisionEventHandler( ! CollisionEventHandler* eventHandler ); ! /// Returns the Solid's collision event handler. If this returns ! /// NULL, the Solid is not using one. ! virtual CollisionEventHandler* OPAL_CALL ! getCollisionEventHandler() const; ! //// Quickly spinning solids should be set as fast rotating solids to ! //// improve simulation accuracy. ! //virtual void OPAL_CALL setFastRotation(bool fast); ! //virtual bool OPAL_CALL getFastRotation()const; ! //virtual void OPAL_CALL setFastRotationAxis(Vec3r axis); ! /// Returns the Solid's mass. This will return 0 if the Solid ! /// is static. ! virtual real OPAL_CALL getMass() const = 0; ! /// Returns the Solid's inertia tensor as a 4x4 matrix. This will ! /// be the identity matrix if the Solid is static. ! virtual Matrix44r OPAL_CALL getInertiaTensor() const = 0; ! /// Update the OPAL transform using the physics engine transform. ! virtual void OPAL_CALL internal_updateOPALTransform() = 0; ! /// Update the physics engine transform using the OPAL transform. ! virtual void OPAL_CALL internal_updateEngineTransform() = 0; ! /// Loops over the Solid's list of Forces and applies them. ! virtual void OPAL_CALL internal_applyForces( real stepSize ); ! /// Updates the SolidData sleeping value from the physics engine. ! void internal_updateSleeping(); ! /// Internal function used to destroy this object. ! virtual void OPAL_CALL internal_destroy(); ! protected: ! virtual ~Solid(); ! /// Physics engine-specific function for applying Forces to ! /// Solids. ! virtual void applyForce( const Force& f ) = 0; ! /// Adds the given axis-aligned bounding box to the Solid's AABB. ! void addToLocalAABB( const real aabb[ 6 ] ); ! /// Resets the Solid's axis-aligned bounding box. ! void resetAABB(); ! /// An internal list of this Solid's pending Forces. ! std::vector<Force> mForceList; ! /// Stores data describing the Solid. ! SolidData mData; ! /// The axis-aligned bounding box of all shapes in local ! /// coordinates. This array stores data in the following order: ! /// min x, max x, min y, max y, min z, max z. This gets updated ! /// whenever a shape is added or removed. ! real mLocalAABB[ 6 ]; ! /// Pointer to this Solid's collision event handler. ! CollisionEventHandler* mCollisionEventHandler; ! ! /// Pointer to user data. This is totally user-managed (i.e. OPAL ! /// will never delete it). ! void* mUserData; ! ! /// Data used for ! private: ! }; } Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Quaternion.h 18 Apr 2005 22:21:03 -0000 1.9 --- Quaternion.h 1 Dec 2005 04:54:44 -0000 1.10 *************** *** 1,185 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #ifndef OPAL_QUATERNION_H #define OPAL_QUATERNION_H #include "OpalMath.h" namespace opal { ! class Quaternion; ! inline Quaternion operator+(const Quaternion &q1, const Quaternion &q2); ! inline Quaternion operator-(const Quaternion &q1, const Quaternion &q2); ! inline Quaternion operator*(const Quaternion& q, real scalar); ! inline Quaternion operator*(real scalar, const Quaternion& q); ! /// Prints the Quaternion to the given output stream. ! inline std::ostream& operator<<(std::ostream& o, const Quaternion& q); ! class Quaternion ! { ! private: ! real mData[4]; ! public: ! Quaternion() ! { ! mData[0] = 0; ! mData[1] = 0; ! mData[2] = 0; ! mData[3] = 0; ! } ! Quaternion(real w, real x, real y, real z) ! { ! mData[0] = w; ! mData[1] = x; ! mData[2] = y; ! mData[3] = z; ! } ! Quaternion(const Quaternion& src) ! { ! memcpy(mData, src.mData, 4 * sizeof(real)); ! } ! inline void set(real w, real x, real y, real z ) ! { ! mData[0] = w; ! mData[1] = x; ! mData[2] = y; ! mData[3] = z; ! } ! inline real lengthSquared()const ! { ! return mData[0]*mData[0] + mData[1]*mData[1] + mData[2]*mData[2] + ! mData[3]*mData[3]; ! } ! inline real length()const ! { ! return sqrt(lengthSquared()); ! } ! inline void normalize() ! { ! real len = length(); ! assert(0 != len); ! real factor = 1 / len; ! (*this) = (*this) * factor; ! } ! void getAngleAxis(real& angle, Vec3r& axis) ! { ! real sqrLen = mData[1]*mData[1] + mData[2]*mData[2] + ! mData[3]*mData[3]; ! if(sqrLen > 0) ! { ! angle = 2 * acos(mData[0]); ! real invLen = 1 / sqrt(sqrLen); ! axis[0] = mData[1] * invLen; ! axis[1] = mData[2] * invLen; ! axis[2] = mData[3] * invLen; ! } ! else ! { ! angle = 0; ! axis[0] = 1; ! axis[1] = 0; ! axis[2] = 0; ! } ! // convert to degrees ! angle = radToDeg(angle); ! } ! real getRoll()const ! { ! return radToDeg(atan2(2*(mData[2]*mData[3] + mData[0]*mData[1]), ! mData[0]*mData[0] - mData[1]*mData[1] - mData[2]*mData[2] + ! mData[3]*mData[3])); ! } ! real getPitch()const ! { ! return radToDeg(asin(-2*(mData[1]*mData[3] - mData[0]*mData[2]))); ! } ! real getYaw()const ! { ! return radToDeg(atan2(2*(mData[1]*mData[2] + mData[0]*mData[3]), ! mData[0]*mData[0] + mData[1]*mData[1] - mData[2]*mData[2] - ! mData[3]*mData[3])); ! } ! inline real & operator[](unsigned int i) ! { ! assert(i < 4); ! return mData[i]; ! } ! inline const real & operator[](unsigned int i)const ! { ! assert(i < 4); ! return mData[i]; ! } ! }; ! inline Quaternion operator+(const Quaternion &q1, const Quaternion &q2) ! { ! return Quaternion(q1[0] + q2[0], q1[1] + q2[1], q1[2] + q2[2], q1[3] + ! q2[3]); ! } ! inline Quaternion operator-(const Quaternion &q1, const Quaternion &q2) ! { ! return Quaternion(q1[0] - q2[0], q1[1] - q2[1], q1[2] - q2[2], q1[3] - ! q2[3]); ! } ! inline Quaternion operator*(const Quaternion& q, real scalar) ! { ! return Quaternion(scalar * q[0], scalar * q[1], scalar * q[2], ! scalar * q[3]); ! } ! inline Quaternion operator*(real scalar, const Quaternion& q) ! { ! return Quaternion(scalar * q[0], scalar * q[1], scalar * q[2], ! scalar * q[3]); ! } ! inline std::ostream& operator<<(std::ostream& o, const Quaternion& q) ! { ! return o << "[" << q[0] << " " << q[1] << " " << q[2] << " " ! << q[3] << "]"; ! } } --- 1,206 ---- /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #ifndef OPAL_QUATERNION_H #define OPAL_QUATERNION_H + // project headers #include "OpalMath.h" namespace opal { ! class Quaternion; ! inline Quaternion operator+( const Quaternion &q1, const Quaternion &q2 ); ! inline Quaternion operator-( const Quaternion &q1, const Quaternion &q2 ); ! inline Quaternion operator*( const Quaternion& q, real scalar ); ! inline Quaternion operator*( real scalar, const Quaternion& q ); ! inline bool operator==( const Quaternion &q1, const Quaternion &q2 ); ! inline bool operator!=( const Quaternion &q1, const Quaternion &q2 ); ! /// Prints the Quaternion to the given output stream. ! inline std::ostream& operator<<( std::ostream& o, const Quaternion& q ); ! class Quaternion ! { ! private: ! real mData[ 4 ]; ! public: ! Quaternion() ! { ! mData[ 0 ] = 0; ! mData[ 1 ] = 0; ! mData[ 2 ] = 0; ! mData[ 3 ] = 0; ! } ! Quaternion( real w, real x, real y, real z ) ! { ! mData[ 0 ] = w; ! mData[ 1 ] = x; ! mData[ 2 ] = y; ! mData[ 3 ] = z; ! } ! Quaternion( const Quaternion& src ) ! { ! memcpy( mData, src.mData, 4 * sizeof( real ) ); ! } ! inline void set( real w, real x, real y, real z ) ! { ! mData[ 0 ] = w; ! mData[ 1 ] = x; ! mData[ 2 ] = y; ! mData[ 3 ] = z; ! } ! inline real lengthSquared()... [truncated message content] |
|
From: Olex <ole...@us...> - 2005-12-01 02:05:05
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9152/src Modified Files: BlueprintManager.cpp Defines.h Makefile.am Makefile.in Point3r.h Simulator.cpp Solid.h Vec3r.cpp opal.h testRaycastSensor.cpp testsolid.cpp Added Files: Mass.h Point3r.cpp Log Message: Implemented Solid::setMass, added unit tests to test it. Added missing Point3r implementation file. Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** opal.h 26 Nov 2005 22:40:18 -0000 1.29 --- opal.h 1 Dec 2005 02:04:54 -0000 1.30 *************** *** 37,40 **** --- 37,41 ---- #include "CapsuleShapeData.h" #include "PlaneShapeData.h" + #include "Mass.h" #include "MeshShapeData.h" #include "Motor.h" Index: Makefile.in =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.in 30 Nov 2005 06:28:12 -0000 1.4 --- Makefile.in 1 Dec 2005 02:04:54 -0000 1.5 *************** *** 217,221 **** $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode ! noinst_HEADERS = Mass.h Matrix33r.h all: all-recursive --- 217,221 ---- $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode ! noinst_HEADERS = Mass.h all: all-recursive Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** Defines.h 30 Nov 2005 06:28:12 -0000 1.78 --- Defines.h 1 Dec 2005 02:04:54 -0000 1.79 *************** *** 243,247 **** /// The highest value that can be used for the Simulator's /// max contacts parameter. ! const int maxMaxContacts=(int)128; // Pre-defined material settings --- 243,247 ---- /// The highest value that can be used for the Simulator's /// max contacts parameter. ! const unsigned int maxMaxContacts=(int)128; // Pre-defined material settings Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** Simulator.cpp 26 Nov 2005 22:40:18 -0000 1.67 --- Simulator.cpp 1 Dec 2005 02:04:54 -0000 1.68 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * [...2090 lines suppressed...] --- 1057,1075 ---- } ! void Simulator::destroyGarbage() ! { ! // Destroy garbage Solids. ! while ( !mSolidGarbageList.empty() ) ! { ! destroySolid( mSolidGarbageList.back() ); ! mSolidGarbageList.pop_back(); ! } ! // Destroy garbage Joints. ! while ( !mJointGarbageList.empty() ) ! { ! destroyJoint( mJointGarbageList.back() ); ! mJointGarbageList.pop_back(); ! } ! } } Index: testRaycastSensor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testRaycastSensor.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testRaycastSensor.cpp 26 Nov 2005 22:40:18 -0000 1.2 --- testRaycastSensor.cpp 1 Dec 2005 02:04:54 -0000 1.3 *************** *** 118,122 **** RaycastResult r = f.sensor->fireRay( 500 ); Point3r hitPoint = r.intersection; ! Solid * hit = r.solid; real diff = r.distance; --- 118,122 ---- RaycastResult r = f.sensor->fireRay( 500 ); Point3r hitPoint = r.intersection; ! //Solid * hit = r.solid; real diff = r.distance; Index: Vec3r.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Vec3r.cpp 30 Nov 2005 06:28:12 -0000 1.1 --- Vec3r.cpp 1 Dec 2005 02:04:54 -0000 1.2 *************** *** 89,93 **** return z; default: ! assert( i < 3 && i > -1 ); } } --- 89,94 ---- return z; default: ! assert( i < 3 ); ! return z; } } *************** *** 104,108 **** return z; default: ! assert( i < 3 && i > -1 ); } } --- 105,110 ---- return z; default: ! assert( i < 3 ); ! return z; } } Index: testsolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testsolid.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testsolid.cpp 15 Nov 2005 03:32:43 -0000 1.3 --- testsolid.cpp 1 Dec 2005 02:04:54 -0000 1.4 *************** *** 205,207 **** --- 205,225 ---- QT_CHECK_EQUAL( current, m ); } + + QT_TEST( setMass_default ) + { + SolidBoxFixture f; + Matrix44r m = f.s->getInertiaTensor(); + + Mass mass; + f.s->setMass( mass, Matrix44r() ); + + Matrix44r m_set = f.s->getInertiaTensor(); + QT_CHECK_EQUAL( m, m_set ); + QT_CHECK_CLOSE( f.s->getMass(), mass.mass, 0.001 ); + + mass.mass = 2; + f.s->setMass( mass, Matrix44r() ); + + QT_CHECK_CLOSE( f.s->getMass(), mass.mass, 0.001 ); + } } --- NEW FILE: Point3r.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // project headers #include "Point3r.h" namespace opal { } Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** Solid.h 6 Nov 2005 05:12:21 -0000 1.92 --- Solid.h 1 Dec 2005 02:04:54 -0000 1.93 *************** *** 35,38 **** --- 35,39 ---- namespace opal { + class Mass; class Simulator; class Space; *************** *** 195,198 **** --- 196,202 ---- virtual Vec3r OPAL_CALL getGlobalAngularVel()const = 0; + /// Set a new mass, center, and intertia for the solid. + virtual void OPAL_CALL setMass( const Mass & newmass, const Matrix44r & offset ) = 0; + /// Translate the Solid's mass using the given offset vector /// specified in global coordinates. --- NEW FILE: Mass.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_MASS_H #define OPAL_MASS_H // project headers #include "Matrix44r.h" #include "OpalMath.h" #include "Vec3r.h" namespace opal { class Mass { public: /// Default values are set Mass() { mass = 1; center = Vec3r( 0, 0, 0 ); inertia.makeIdentity(); inertia[ 0 ] = 1 / 6.0; inertia[ 5 ] = 1 / 6.0; inertia[ 10 ] = 1 / 6.0; } /// Total mass of the rigid body /// Default is 1 real mass; /// Center of gravity position in body frame (x,y,z). /// Default is (0,0,0) Vec3r center; /// 3x3 inertia tensor in body frame, about POR /// Default is inertia of a box Matrix44r inertia; }; } #endif Index: Point3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Point3r.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Point3r.h 30 Nov 2005 06:28:12 -0000 1.14 --- Point3r.h 1 Dec 2005 02:04:54 -0000 1.15 *************** *** 114,118 **** return z; default: ! assert( i < 3 && i > -1 ); } } --- 114,119 ---- return z; default: ! assert( i < 3 ); ! return z; } } *************** *** 129,133 **** return z; default: ! assert( i < 3 && i > -1 ); } } --- 130,135 ---- return z; default: ! assert( i < 3 ); ! return z; } } Index: BlueprintManager.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** BlueprintManager.cpp 24 Jun 2005 17:50:48 -0000 1.43 --- BlueprintManager.cpp 1 Dec 2005 02:04:54 -0000 1.44 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * [...3123 lines suppressed...] ! TiXmlElement * elementPtr = ! const_cast<TiXmlNode*>( nodePtr ) ->ToElement(); ! const char* temp = elementPtr->Attribute( name.c_str() ); ! if ( NULL == temp ) ! { ! OPAL_LOGGER( "warning" ) << ! "opal::BlueprintManager::getAttributeString: Element " ! << nodePtr->Value() << " is missing attribute '" ! << name << "'. Parameter will be set to \"\"." ! << std::endl; ! return ""; ! } ! else ! { ! return temp; ! } ! } ! } } Index: Makefile.am =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 30 Nov 2005 06:28:12 -0000 1.4 --- Makefile.am 1 Dec 2005 02:04:54 -0000 1.5 *************** *** 18,20 **** test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode ! noinst_HEADERS = Mass.h Matrix33r.h --- 18,20 ---- test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode ! noinst_HEADERS = Mass.h |
|
From: Olex <ole...@us...> - 2005-12-01 02:05:04
|
Update of /cvsroot/opal/opal/src/external/quicktest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9152/src/external/quicktest Modified Files: quicktest.h Log Message: Implemented Solid::setMass, added unit tests to test it. Added missing Point3r implementation file. Index: quicktest.h =================================================================== RCS file: /cvsroot/opal/opal/src/external/quicktest/quicktest.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** quicktest.h 21 Nov 2005 13:59:16 -0000 1.3 --- quicktest.h 1 Dec 2005 02:04:54 -0000 1.4 *************** *** 1,26 **** /************************************************************************* ! * * ! * QuickTest * ! * Copyright (C) 2005 * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: quicktest.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ // Credits: --- 1,26 ---- /************************************************************************* ! * * ! * QuickTest * ! * Copyright (C) 2005 * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: quicktest.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ // Credits: *************** *** 53,233 **** namespace quicktest { ! typedef std::vector<std::string> TestResult; ! class Test ! { ! public: ! Test(const std::string& testGroup, const std::string& testName) ! { ! mTestName = testName; ! mTestGroup = testGroup; ! } ! const std::string & getGroup() { return mTestGroup; } ! virtual void run(TestResult& result) = 0; ! protected: ! void recordFailure(TestResult& result, const std::string& file, ! unsigned long int line, const std::string& message) ! { ! // If the full filename is too long, only use the last part. ! std::string fileStr = file; ! size_t maxLength = 40; ! size_t fileLength = file.size(); ! if (fileLength > maxLength) ! { ! // Get the last maxLength characters - 3 (leave room for ! // three ellipses at the beginning). ! fileStr = "..."; ! fileStr += file.substr(fileLength - maxLength + 3, ! fileLength - 1); ! } ! std::ostringstream oss; ! oss << fileStr << "(" << line << "): '" << mTestName ! << "' FAILED: " << message; ! result.push_back(oss.str()); ! } ! /// The unique name of this test. ! std::string mTestName; ! /// The group name of this test ! std::string mTestGroup; ! }; ! class TestManager ! { ! public: ! static TestManager& instance() ! { ! static TestManager self; ! return self; ! } ! void addTest(Test* test) ! { ! mTests.push_back(test); ! } ! void setOutputStream(std::ostream* stream) ! { ! mOutputStream = stream; ! } ! std::ostream* getOutputStream() ! { ! return mOutputStream; ! } ! void runTests() ! { ! unsigned int numFailures = 0; ! *getOutputStream() ! << "[---------------- RUNNING TESTS ----------------]" ! << std::endl; ! unsigned int numLocalFailures = 0; ! unsigned int numLocalSuccesses = 0; ! std::string currentGroup; ! std::vector<Test*>::iterator iter; ! for (iter = mTests.begin(); iter != mTests.end(); ++iter) ! { ! if ( currentGroup != (*iter)->getGroup() ) ! { ! if ( !currentGroup.empty() ) ! { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" ! << std::endl; ! } ! currentGroup = (*iter)->getGroup(); ! *getOutputStream() << ! "Group: " << (*iter)->getGroup() ! << std::endl; ! numLocalFailures = 0; ! numLocalSuccesses = 0; ! } ! (*iter)->run(mResult); ! bool testFailed = false; ! size_t size = mResult.size(); ! for (size_t i = 0; i < size; ++i) ! { ! *getOutputStream() << mResult.at(i) << std::endl; ! testFailed = true; ! } ! mResult.clear(); ! if (testFailed) ! { ! ++numFailures; ! ++numLocalFailures; ! } ! else ! { ! ++numLocalSuccesses; ! } ! } ! if ( !currentGroup.empty() ) ! { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" ! << std::endl; ! } ! *getOutputStream() << "Overall results: " << (unsigned int)mTests.size() ! - numFailures << " succeeded, " << numFailures << " failed" ! << std::endl; ! *getOutputStream() ! << "[---------------- TESTS FINISHED ---------------]" ! << std::endl; ! } ! private: ! TestManager() ! { ! mOutputStream = &std::cout; ! } ! ~TestManager() ! { ! } ! /// List of pointers to Tests. All tests are staticly allocated, ! /// so we don't need to destroy them manually. ! std::vector<Test*> mTests; ! std::ostream* mOutputStream; ! TestResult mResult; ! }; } /// Macro to define a single test without using a fixture. #define QT_TEST(testName)\ ! class testName##Test : public quicktest::Test\ ! {\ ! public:\ ! testName##Test()\ ! : Test(__FILE__, #testName)\ ! {\ ! quicktest::TestManager::instance().addTest(this);\ ! }\ ! void run(quicktest::TestResult& _result);\ ! }testName##Instance;\ ! void testName##Test::run(quicktest::TestResult& _result) /// Macro that runs all tests. --- 53,234 ---- namespace quicktest { ! typedef std::vector<std::string> TestResult; ! class Test ! { ! public: ! Test( const std::string& testGroup, const std::string& testName ) ! { ! mTestName = testName; ! mTestGroup = testGroup; ! } ! virtual ~Test() {} ! const std::string & getGroup() { return mTestGroup; } ! virtual void run( TestResult& result ) = 0; ! protected: ! void recordFailure( TestResult& result, const std::string& file, ! unsigned long int line, const std::string& message ) ! { ! // If the full filename is too long, only use the last part. ! std::string fileStr = file; ! size_t maxLength = 40; ! size_t fileLength = file.size(); ! if ( fileLength > maxLength ) ! { ! // Get the last maxLength characters - 3 (leave room for ! // three ellipses at the beginning). ! fileStr = "..."; ! fileStr += file.substr( fileLength - maxLength + 3, ! fileLength - 1 ); ! } ! std::ostringstream oss; ! oss << fileStr << "(" << line << "): '" << mTestName ! << "' FAILED: " << message; ! result.push_back( oss.str() ); ! } ! /// The unique name of this test. ! std::string mTestName; ! /// The group name of this test ! std::string mTestGroup; ! }; ! class TestManager ! { ! public: ! static TestManager& instance() ! { ! static TestManager self; ! return self; ! } ! void addTest( Test* test ) ! { ! mTests.push_back( test ); ! } ! void setOutputStream( std::ostream* stream ) ! { ! mOutputStream = stream; ! } ! std::ostream* getOutputStream() ! { ! return mOutputStream; ! } ! void runTests() ! { ! unsigned int numFailures = 0; ! *getOutputStream() ! << "[---------------- RUNNING TESTS ----------------]" ! << std::endl; ! unsigned int numLocalFailures = 0; ! unsigned int numLocalSuccesses = 0; ! std::string currentGroup; ! std::vector<Test*>::iterator iter; ! for ( iter = mTests.begin(); iter != mTests.end(); ++iter ) ! { ! if ( currentGroup != ( *iter ) ->getGroup() ) ! { ! if ( !currentGroup.empty() ) ! { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" ! << std::endl; ! } ! currentGroup = ( *iter ) ->getGroup(); ! *getOutputStream() << ! "Group: " << ( *iter ) ->getGroup() ! << std::endl; ! numLocalFailures = 0; ! numLocalSuccesses = 0; ! } ! ( *iter ) ->run( mResult ); ! bool testFailed = false; ! size_t size = mResult.size(); ! for ( size_t i = 0; i < size; ++i ) ! { ! *getOutputStream() << mResult.at( i ) << std::endl; ! testFailed = true; ! } ! mResult.clear(); ! if ( testFailed ) ! { ! ++numFailures; ! ++numLocalFailures; ! } ! else ! { ! ++numLocalSuccesses; ! } ! } ! if ( !currentGroup.empty() ) ! { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" ! << std::endl; ! } ! *getOutputStream() << "Overall results: " << ( unsigned int ) mTests.size() ! - numFailures << " succeeded, " << numFailures << " failed" ! << std::endl; ! *getOutputStream() ! << "[---------------- TESTS FINISHED ---------------]" ! << std::endl; ! } ! private: ! TestManager() ! { ! mOutputStream = &std::cout; ! } ! ~TestManager() ! {} ! /// List of pointers to Tests. All tests are staticly allocated, ! /// so we don't need to destroy them manually. ! std::vector<Test*> mTests; ! std::ostream* mOutputStream; ! ! TestResult mResult; ! }; } /// Macro to define a single test without using a fixture. #define QT_TEST(testName)\ ! class testName##Test : public quicktest::Test\ ! {\ ! public:\ ! testName##Test()\ ! : Test(__FILE__, #testName)\ ! {\ ! quicktest::TestManager::instance().addTest(this);\ ! }\ ! void run(quicktest::TestResult& _result);\ ! }testName##Instance;\ ! void testName##Test::run(quicktest::TestResult& _result) /// Macro that runs all tests. *************** *** 236,274 **** /// Macro that sets the output stream to use. #define QT_SET_OUTPUT(stream)\ ! quicktest::TestManager::instance().setOutputStream(stream) /// Checks whether the given condition is true. #define QT_CHECK(condition)\ ! {\ ! if (!(condition))\ ! {\ ! recordFailure(_result, __FILE__, __LINE__, #condition);\ ! }\ ! } /// Checks whether the first parameter is equal to the second. #define QT_CHECK_EQUAL(value1, value2)\ ! {\ ! if ((value1) != (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1:" << std::endl << "(" << (value1) << ")" \ ! << std::endl << "should equal value2:" \ ! << std::endl << "(" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is not equal to the second. #define QT_CHECK_NOT_EQUAL(value1, value2)\ ! {\ ! if ((value1) == (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should not equal "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is within the given tolerance from --- 237,275 ---- /// Macro that sets the output stream to use. #define QT_SET_OUTPUT(stream)\ ! quicktest::TestManager::instance().setOutputStream(stream) /// Checks whether the given condition is true. #define QT_CHECK(condition)\ ! {\ ! if (!(condition))\ ! {\ ! recordFailure(_result, __FILE__, __LINE__, #condition);\ ! }\ ! } /// Checks whether the first parameter is equal to the second. #define QT_CHECK_EQUAL(value1, value2)\ ! {\ ! if ((value1) != (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1:" << std::endl << "(" << (value1) << ")" \ ! << std::endl << "should equal value2:" \ ! << std::endl << "(" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is not equal to the second. #define QT_CHECK_NOT_EQUAL(value1, value2)\ ! {\ ! if ((value1) == (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should not equal "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is within the given tolerance from *************** *** 276,350 **** /// values. #define QT_CHECK_CLOSE(value1, value2, tolerance)\ ! {\ ! if (abs((value1)-(value2)) > tolerance)\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be close to "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is less than the second. #define QT_CHECK_LESS(value1, value2)\ ! {\ ! if ((value1) >= (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be less than "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is less than or equal to the second. #define QT_CHECK_LESS_OR_EQUAL(value1, value2)\ ! {\ ! if ((value1) > (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be less than or "\ ! << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is greater than the second. #define QT_CHECK_GREATER(value1, value2)\ ! {\ ! if ((value1) <= (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be greater than "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is greater than or equal to the /// second. #define QT_CHECK_GREATER_OR_EQUAL(value1, value2)\ ! {\ ! if ((value1) < (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be greater than or "\ ! << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Fails unconditionally and prints the given message. #define QT_FAIL(message)\ ! {\ ! recordFailure(_result, __FILE__, __LINE__, (message));\ ! }\ /// Prints the given message, followed by a carriage return. #define QT_PRINT(message)\ ! {\ ! *(quicktest::TestManager::instance().getOutputStream()) << (message)\ ! << std::endl;\ ! }\ #endif --- 277,351 ---- /// values. #define QT_CHECK_CLOSE(value1, value2, tolerance)\ ! {\ ! if (abs((value1)-(value2)) > tolerance)\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be close to "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is less than the second. #define QT_CHECK_LESS(value1, value2)\ ! {\ ! if ((value1) >= (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be less than "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is less than or equal to the second. #define QT_CHECK_LESS_OR_EQUAL(value1, value2)\ ! {\ ! if ((value1) > (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be less than or "\ ! << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is greater than the second. #define QT_CHECK_GREATER(value1, value2)\ ! {\ ! if ((value1) <= (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be greater than "\ ! << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Checks whether the first parameter is greater than or equal to the /// second. #define QT_CHECK_GREATER_OR_EQUAL(value1, value2)\ ! {\ ! if ((value1) < (value2))\ ! {\ ! std::ostringstream oss;\ ! oss << "value1 (" << (value1) << ") should be greater than or "\ ! << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ ! }\ ! } /// Fails unconditionally and prints the given message. #define QT_FAIL(message)\ ! {\ ! recordFailure(_result, __FILE__, __LINE__, (message));\ ! }\ /// Prints the given message, followed by a carriage return. #define QT_PRINT(message)\ ! {\ ! *(quicktest::TestManager::instance().getOutputStream()) << (message)\ ! << std::endl;\ ! }\ #endif |
|
From: Olex <ole...@us...> - 2005-12-01 02:05:03
|
Update of /cvsroot/opal/opal/kdevelop In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9152/kdevelop Modified Files: opal.kdevelop Log Message: Implemented Solid::setMass, added unit tests to test it. Added missing Point3r implementation file. Index: opal.kdevelop =================================================================== RCS file: /cvsroot/opal/opal/kdevelop/opal.kdevelop,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** opal.kdevelop 13 Nov 2005 18:51:20 -0000 1.2 --- opal.kdevelop 1 Dec 2005 02:04:54 -0000 1.3 *************** *** 14,18 **** <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description/> <versioncontrol/> </general> --- 14,18 ---- <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> ! <description></description> <versioncontrol/> </general> *************** *** 48,52 **** <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> ! <cxxflags>-O0 -g3</cxxflags> <envvars> <envvar value="ccache g++" name="CXX" /> --- 48,52 ---- <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> ! <cxxflags>-O0 -g3 -Wall</cxxflags> <envvars> <envvar value="ccache g++" name="CXX" /> *************** *** 159,170 **** </substmap> <kdevcppsupport> ! <references> ! <pcs>STL</pcs> ! <pcs>ODE physics engine</pcs> ! <pcs>RakNet</pcs> ! <pcs>TrueAxis</pcs> ! <pcs>TinyXML</pcs> ! <pcs>OGRE 3D engine</pcs> ! </references> <codecompletion> <includeGlobalFunctions>true</includeGlobalFunctions> --- 159,163 ---- </substmap> <kdevcppsupport> ! <references/> <codecompletion> <includeGlobalFunctions>true</includeGlobalFunctions> *************** *** 180,184 **** </codecompletion> <creategettersetter> ! <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> --- 173,177 ---- </codecompletion> <creategettersetter> ! <prefixGet></prefixGet> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> *************** *** 187,190 **** --- 180,188 ---- <inlineSet>true</inlineSet> </creategettersetter> + <qt> + <used>false</used> + <version>3</version> + <root>/usr/qt/3</root> + </qt> </kdevcppsupport> <cppsupportpart> *************** *** 196,205 **** <kdevdebugger> <general> ! <programargs/> ! <gdbpath/> ! <dbgshell/> ! <configGdbScript/> ! <runShellScript/> ! <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> --- 194,203 ---- <kdevdebugger> <general> ! <programargs></programargs> ! <gdbpath></gdbpath> ! <dbgshell></dbgshell> ! <configGdbScript></configGdbScript> ! <runShellScript></runShellScript> ! <runGdbScript></runGdbScript> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> *************** *** 213,218 **** </kdevdebugger> <ctagspart> ! <customArguments/> ! <customTagfilePath/> </ctagspart> </kdevelop> --- 211,216 ---- </kdevdebugger> <ctagspart> ! <customArguments></customArguments> ! <customTagfilePath></customTagfilePath> </ctagspart> </kdevelop> |
|
From: Olex <ole...@us...> - 2005-12-01 02:05:03
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9152 Modified Files: changelog.txt Log Message: Implemented Solid::setMass, added unit tests to test it. Added missing Point3r implementation file. Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** changelog.txt 30 Nov 2005 06:28:12 -0000 1.51 --- changelog.txt 1 Dec 2005 02:04:54 -0000 1.52 *************** *** 15,18 **** --- 15,20 ---- ------------------------------------------ + * 11-30-05: Implemented Solid::setMass, added unit tests to test it. (Oleksandr Lozitskiy) + * 11-30-05: Vec3r and Point3r refactored and fixed with unit tests. (Oleksandr Lozitskiy) |