[Opal-commits] opal/src Vec3r.cpp,NONE,1.1 testPoint3r.cpp,NONE,1.1 testVec3r.cpp,NONE,1.1 Defines.h
Status: Inactive
Brought to you by:
tylerstreeter
|
From: Olex <ole...@us...> - 2005-11-30 06:28:20
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18063/src Modified Files: Defines.h Makefile.am Makefile.in Matrix44r.h OpalMath.h Point3r.h SConscript SensorData.h ShapeData.h SpringMotor.h Vec3r.h Added Files: Vec3r.cpp testPoint3r.cpp testVec3r.cpp Log Message: Vec3r and Point3r refactored and fixed with unit tests. Index: ShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/ShapeData.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ShapeData.h 21 Jul 2005 15:59:01 -0000 1.9 --- ShapeData.h 30 Nov 2005 06:28:12 -0000 1.10 *************** *** 29,33 **** --- 29,35 ---- #define OPAL_SHAPE_DATA_H + // project headers #include "Defines.h" + #include "Matrix44r.h" namespace opal *************** *** 44,48 **** }; ! /// A data structure describing a Shape. Note that there is no other /// class associated with Shapes besides this one. class ShapeData --- 46,50 ---- }; ! /// A data structure describing a Shape. Note that there is no other /// class associated with Shapes besides this one. class ShapeData *************** *** 51,55 **** OPAL_DECL ShapeData() { ! // The initial type doesn't matter since the abstract base // class will never be instantiated. mType = SPHERE_SHAPE; --- 53,57 ---- OPAL_DECL ShapeData() { ! // The initial type doesn't matter since the abstract base // class will never be instantiated. mType = SPHERE_SHAPE; *************** *** 69,74 **** } ! /// Returns the axis-aligned bounding box of the ShapeData relative ! /// to its center. The 'aabb' array stores data in the following /// order: min x, max x, min y, max y, min z, max z. OPAL_DECL virtual void OPAL_CALL getLocalAABB(real aabb[6]) = 0; --- 71,76 ---- } ! /// Returns the axis-aligned bounding box of the ShapeData relative ! /// to its center. The 'aabb' array stores data in the following /// order: min x, max x, min y, max y, min z, max z. OPAL_DECL virtual void OPAL_CALL getLocalAABB(real aabb[6]) = 0; *************** *** 80,84 **** Material material; ! /// The Shape's contact group. If this exceeds 31, bad things /// might happen since there are only 32 groups. unsigned int contactGroup; --- 82,86 ---- Material material; ! /// The Shape's contact group. If this exceeds 31, bad things /// might happen since there are only 32 groups. unsigned int contactGroup; Index: SensorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SensorData.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SensorData.h 29 Mar 2005 03:05:46 -0000 1.11 --- SensorData.h 30 Nov 2005 06:28:12 -0000 1.12 *************** *** 29,33 **** --- 29,35 ---- #define OPAL_SENSOR_DATA_H + // project headers #include "Defines.h" + #include "Matrix44r.h" namespace opal *************** *** 48,52 **** OPAL_DECL SensorData() { ! // The initial type doesn't matter since the abstract base // class will never be instantiated. mType = ACCELERATION_SENSOR; --- 50,54 ---- OPAL_DECL SensorData() { ! // The initial type doesn't matter since the abstract base // class will never be instantiated. mType = ACCELERATION_SENSOR; *************** *** 72,80 **** bool enabled; ! /// An identifier for the Sensor. std::string name; ! /// Pointer to the Solid to which this Sensor is attached. This ! /// will be NULL if the Sensor is not attached to a Solid (i.e. /// it is just positioned somewhere within the environment). Solid* solid; --- 74,82 ---- bool enabled; ! /// An identifier for the Sensor. std::string name; ! /// Pointer to the Solid to which this Sensor is attached. This ! /// will be NULL if the Sensor is not attached to a Solid (i.e. /// it is just positioned somewhere within the environment). Solid* solid; *************** *** 86,91 **** std::string solidBlueprintRefName; ! /// If the Sensor is attached to a Solid, this transform is the global ! /// offset from that Solid's transform. Otherwise, it is just the /// Sensor's global transform. Matrix44r transform; --- 88,93 ---- std::string solidBlueprintRefName; ! /// If the Sensor is attached to a Solid, this transform is the global ! /// offset from that Solid's transform. Otherwise, it is just the /// Sensor's global transform. Matrix44r transform; Index: Makefile.am =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.am 21 Nov 2005 13:59:16 -0000 1.3 --- Makefile.am 30 Nov 2005 06:28:12 -0000 1.4 *************** *** 8,20 **** SUBDIRS = external ODE 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 bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode --- 8,20 ---- SUBDIRS = external ODE 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 \ ! 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 + noinst_HEADERS = Mass.h Matrix33r.h Index: Vec3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Vec3r.h 27 Apr 2005 02:28:18 -0000 1.17 --- Vec3r.h 30 Nov 2005 06:28:12 -0000 1.18 *************** *** 1,317 **** /************************************************************************* ! * * ! * 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_VEC3R_H #define OPAL_VEC3R_H #include "OpalMath.h" namespace opal { ! class Vec3r; ! inline Vec3r operator+(const Vec3r &u, const Vec3r &v); ! inline Vec3r operator-(const Vec3r &u, const Vec3r &v); ! inline Vec3r operator*(const Vec3r &v, real scalar); ! inline Vec3r operator*(real scalar, const Vec3r &v); ! inline Vec3r operator/(const Vec3r &v, real scalar); ! inline Vec3r operator%(const Vec3r & a, const Vec3r & b); ! inline Vec3r operator-(const Vec3r &v); ! inline real dot(const Vec3r & u, const Vec3r & v); ! inline Vec3r cross(const Vec3r & u, const Vec3r& v); ! /// Returns the projection of 'v' onto 'u'. ! inline Vec3r project(const Vec3r& u, const Vec3r& v); ! /// Given that the vector 'u' is already a unit vector, returns the ! /// projection of v onto u. ! inline Vec3r projectPreNorm(const Vec3r& u, const Vec3r& v); ! /// Returns a positive angle between 0 and 180 degrees. ! inline real angleBetween(const Vec3r& u, const Vec3r& v); ! /// Given that the vectors 'u' and 'v' are already normalized, returns ! /// a positive angle between 0 and 180 degrees. ! inline real angleBetweenPreNorm(const Vec3r& u, const Vec3r& v); ! /// 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. ! inline std::ostream& operator<<(std::ostream& o, const Vec3r& v); ! class Vec3r ! { ! private: ! real mData[3]; ! public: ! Vec3r() ! { ! mData[0] = 0; ! mData[1] = 0; ! mData[2] = 0; ! } ! Vec3r(const Vec3r & src) ! { ! mData[0] = src.mData[0]; ! mData[1] = src.mData[1]; ! mData[2] = src.mData[2]; ! } ! Vec3r(real x, real y, real z) ! { ! mData[0] = x; ! mData[1] = y; ! mData[2] = z; ! } ! Vec3r(const real * data) ! { ! mData[0] = data[0]; ! mData[1] = data[1]; ! mData[2] = data[2]; ! } ! inline void set(real x, real y, real z) ! { ! mData[0] = x; ! mData[1] = y; ! mData[2] = z; ! } ! ! inline void set(real * data) ! { ! mData[0] = data[0]; ! mData[1] = data[1]; ! mData[2] = data[2]; ! } ! inline real * getData() ! { ! return mData; ! } ! inline const real * getData()const ! { ! return mData; ! } ! inline real & operator[](unsigned int i) ! { ! assert(i < 3); ! return mData[i]; ! } ! inline const real & operator[](unsigned int i)const ! { ! assert(i < 3); ! return mData[i]; ! } ! inline real lengthSquared()const ! { ! return dot(*this, *this); ! } ! inline real length()const ! { ! return sqrt(dot(*this, *this)); ! } ! inline void normalize() ! { ! real len = length(); ! assert(0 != len); ! real factor = (real)1.0 / len; ! (*this) *= factor; ! } ! inline Vec3r unit()const ! { ! return (*this) / length(); ! } ! inline void operator+=(const Vec3r & v) ! { ! mData[0] += v.mData[0]; ! mData[1] += v.mData[1]; ! mData[2] += v.mData[2]; ! } ! inline void operator-=(const Vec3r & v) ! { ! mData[0] -= v.mData[0]; ! mData[1] -= v.mData[1]; ! mData[2] -= v.mData[2]; ! } ! inline void operator*=(const Vec3r & v) ! { ! mData[0] *= v.mData[0]; ! mData[1] *= v.mData[1]; ! mData[2] *= v.mData[2]; ! } ! inline void operator*=(real scalar) ! { ! mData[0] *= scalar; ! mData[1] *= scalar; ! mData[2] *= scalar; ! } ! inline void operator/=(real scalar) ! { ! mData[0] /= scalar; ! mData[1] /= scalar; ! mData[2] /= scalar; ! } ! inline void operator/=(const Vec3r & v) ! { ! mData[0] /= v.mData[0]; ! mData[1] /= v.mData[1]; ! mData[2] /= v.mData[2]; ! } ! inline bool operator==(const Vec3r & v) ! { ! return(mData[0]==v.mData[0] && mData[1]==v.mData[1] && ! v.mData[2]==mData[2]); ! } ! inline bool operator!=(const Vec3r & v) ! { ! return(mData[0]!=v.mData[0] && mData[1]!=v.mData[1] && ! v.mData[2]!=mData[2]); ! } ! }; ! inline Vec3r operator+(const Vec3r &u, const Vec3r &v) ! { ! return Vec3r(u[0] + v[0], u[1] + v[1], u[2] + v[2]); ! } ! inline Vec3r operator-(const Vec3r &u, const Vec3r &v) ! { ! return Vec3r(u[0] - v[0], u[1] - v[1], u[2] - v[2]); ! } ! inline Vec3r operator*(const Vec3r &v, real scalar) ! { ! return Vec3r(scalar * v[0], scalar * v[1], scalar * v[2]); ! } ! inline Vec3r operator*(real scalar, const Vec3r &v) ! { ! return Vec3r(scalar * v[0], scalar * v[1], scalar * v[2]); ! } ! inline Vec3r operator/(const Vec3r &v, real scalar) ! { ! return Vec3r(v[0] / scalar, v[1] / scalar, v[2] / scalar); ! } ! inline Vec3r operator%(const Vec3r & a, const Vec3r & b) ! { ! return Vec3r((a[1]*b[2]) - (a[2]*b[1]), (a[2]*b[0]) - (a[0]*b[2]), ! (a[0]*b[1]) - (a[1]*b[0])); ! } ! inline real dot(const Vec3r & u, const Vec3r & v) ! { ! return u[0] * v[0] + u[1] * v[1] + u[2] * v[2]; ! } ! inline Vec3r cross(const Vec3r & u, const Vec3r & v) ! { ! return u%v; ! } ! inline Vec3r operator-(const Vec3r &v) ! { ! return v * -1; ! } ! inline Vec3r project(const Vec3r& u, const Vec3r& v) ! { ! Vec3r u2 = u; ! u2.normalize(); ! return projectPreNorm(u2, v); ! } ! inline Vec3r projectPreNorm(const Vec3r& u, const Vec3r& v) ! { ! return dot(u, v) * u; ! } ! inline real angleBetween(const Vec3r& u, const Vec3r& v) ! { ! Vec3r u2 = u; ! u2.normalize(); ! Vec3r v2 = v; ! v2.normalize(); ! return angleBetweenPreNorm(u2, v2); ! } ! inline real angleBetweenPreNorm(const Vec3r& u, const Vec3r& v) ! { ! real val = dot(u, v); ! // Clamp to avoid rounding errors; acos will puke with values outside ! // this range. ! if (val < -1) ! { ! val = -1; ! } ! else if (val > 1) ! { ! val = 1; ! } ! return radToDeg(acos(val)); ! } ! inline bool areCollinear(const Vec3r& u, const Vec3r& v) ! { ! real value = 1 - dot(u, v); ! if (areEqual(value, 0)) ! { ! return true; ! } ! else ! { ! return false; ! } ! } ! inline std::ostream& operator<<(std::ostream& o, const Vec3r& v) ! { ! return o << "[" << v[0] << " " << v[1] << " " << v[2] << "]"; ! } } --- 1,216 ---- /************************************************************************* ! * * ! * 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_VEC3R_H #define OPAL_VEC3R_H + // project headers #include "OpalMath.h" + // system headers + #include <iostream> + namespace opal { ! class Vec3r; ! inline Vec3r operator+( const Vec3r &u, const Vec3r &v ); ! inline Vec3r operator-( const Vec3r &u, const Vec3r &v ); ! inline Vec3r operator*( const Vec3r &v, real scalar ); ! inline Vec3r operator*( real scalar, const Vec3r &v ); ! inline Vec3r operator/( const Vec3r &v, real scalar ); ! inline Vec3r operator%( const Vec3r & a, const Vec3r & b ); ! inline Vec3r operator-( const Vec3r &v ); ! inline real dot( const Vec3r & u, const Vec3r & v ); ! inline Vec3r cross( const Vec3r & u, const Vec3r& v ); ! /// Returns the projection of 'v' onto 'u'. ! inline Vec3r project( const Vec3r& u, const Vec3r& v ); ! /// Given that the vector 'u' is already a unit vector, returns the ! /// projection of v onto u. ! inline Vec3r projectPreNorm( const Vec3r& u, const Vec3r& v ); ! /// Returns a positive angle between 0 and 180 degrees. ! inline real angleBetween( const Vec3r& u, const Vec3r& v ); ! /// Given that the vectors 'u' and 'v' are already normalized, returns ! /// a positive angle between 0 and 180 degrees. ! inline real angleBetweenPreNorm( const Vec3r& u, const Vec3r& v ); ! /// 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. ! inline std::ostream& operator<<( std::ostream& o, const Vec3r& v ); ! class Vec3r ! { ! public: ! /// x-coordinate ! real x; ! /// y-coordinate ! real y; ! /// z-coordinate ! real z; ! /// 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 ); ! }; ! inline Vec3r operator+( const Vec3r &u, const Vec3r &v ) ! { ! return Vec3r( u.x + v.x, u.y + v.y, u.z + v.z ); ! } ! inline Vec3r operator-( const Vec3r &u, const Vec3r &v ) ! { ! return Vec3r( u.x - v.x, u.y - v.y, u.z - v.z ); ! } ! inline Vec3r operator*( const Vec3r &v, real scalar ) ! { ! return Vec3r( scalar * v.x, scalar * v.y, scalar * v.z ); ! } ! inline Vec3r operator*( real scalar, const Vec3r &v ) ! { ! return Vec3r( scalar * v.x, scalar * v.y, scalar * v.z ); ! } ! inline Vec3r operator/( const Vec3r &v, real scalar ) ! { ! return Vec3r( v.x / scalar, v.y / scalar, v.z / scalar ); ! } ! inline Vec3r operator%( const Vec3r & a, const Vec3r & b ) ! { ! return Vec3r( ( a.y * b.z ) - ( a.z * b.y ), ( a.z * b.x ) - ( a.x * b.z ), ! ( a.x * b.y ) - ( a.y * b.x ) ); ! } ! inline real dot( const Vec3r & u, const Vec3r & v ) ! { ! return u.x * v.x + u.y * v.y + u.z * v.z; ! } ! inline Vec3r cross( const Vec3r & u, const Vec3r & v ) ! { ! return u % v; ! } ! inline Vec3r operator-( const Vec3r &v ) ! { ! return v * -1; ! } ! inline Vec3r project( const Vec3r& u, const Vec3r& v ) ! { ! Vec3r u2 = u; ! u2.normalize(); ! return projectPreNorm( u2, v ); ! } ! inline Vec3r projectPreNorm( const Vec3r& u, const Vec3r& v ) ! { ! return dot( u, v ) * u; ! } ! inline real angleBetween( const Vec3r& u, const Vec3r& v ) ! { ! Vec3r u2 = u; ! u2.normalize(); ! Vec3r v2 = v; ! v2.normalize(); ! return angleBetweenPreNorm( u2, v2 ); ! } ! inline real angleBetweenPreNorm( const Vec3r& u, const Vec3r& v ) ! { ! real val = dot( u, v ); ! // Clamp to avoid rounding errors; acos will puke with values outside ! // this range. ! if ( val < -1 ) ! { ! val = -1; ! } ! else if ( val > 1 ) ! { ! val = 1; ! } ! return radToDeg( acos( val ) ); ! } ! ! inline std::ostream& operator<<( std::ostream& o, const Vec3r& v ) ! { ! return o << "[" << v.x << " " << v.y << " " << v.z << "]"; ! } } Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Defines.h 19 Apr 2005 14:20:35 -0000 1.77 --- Defines.h 30 Nov 2005 06:28:12 -0000 1.78 *************** *** 43,46 **** --- 43,48 ---- #include "Portability.h" #include "Logger.h" + #include "Vec3r.h" + #include "Point3r.h" /// The main namespace that contains everything in OPAL. *************** *** 50,95 **** class Joint; ! /// Types of Forces. Used when creating a Force struct to designate /// how the Forces should be applied to a Solid. enum ForceType { ! /// Apply a force in a direction relative to the Solid's local /// coordinate system. LOCAL_FORCE, ! /// Apply a force in a direction relative to the global /// coordinate system. GLOBAL_FORCE, ! /// Apply a torque with the axis specified relative to the Solid's /// local coordinate system. LOCAL_TORQUE, ! /// Apply a torque with the axis specified relative to global /// coordinate system. GLOBAL_TORQUE, ! /// Apply a force at a position relative to the Solid's local ! /// coordinate system in a direction relative to the Solid's local /// coordinate system. LOCAL_FORCE_AT_LOCAL_POS, ! /// Apply a force at a position relative to the global ! /// coordinate system in a direction relative to the Solid's local /// coordinate system. LOCAL_FORCE_AT_GLOBAL_POS, ! /// Apply a force at a position relative to the Solid's local ! /// coordinate system in a direction relative to the global /// coordinate system. GLOBAL_FORCE_AT_LOCAL_POS, ! /// Apply a force at a position relative to the global ! /// coordinate system in a direction relative to the global /// coordinate system. GLOBAL_FORCE_AT_GLOBAL_POS }; ! /// Data structure containing all necessary info for applying a /// force/torque to a Solid. struct Force --- 52,97 ---- class Joint; ! /// Types of Forces. Used when creating a Force struct to designate /// how the Forces should be applied to a Solid. enum ForceType { ! /// Apply a force in a direction relative to the Solid's local /// coordinate system. LOCAL_FORCE, ! /// Apply a force in a direction relative to the global /// coordinate system. GLOBAL_FORCE, ! /// Apply a torque with the axis specified relative to the Solid's /// local coordinate system. LOCAL_TORQUE, ! /// Apply a torque with the axis specified relative to global /// coordinate system. GLOBAL_TORQUE, ! /// Apply a force at a position relative to the Solid's local ! /// coordinate system in a direction relative to the Solid's local /// coordinate system. LOCAL_FORCE_AT_LOCAL_POS, ! /// Apply a force at a position relative to the global ! /// coordinate system in a direction relative to the Solid's local /// coordinate system. LOCAL_FORCE_AT_GLOBAL_POS, ! /// Apply a force at a position relative to the Solid's local ! /// coordinate system in a direction relative to the global /// coordinate system. GLOBAL_FORCE_AT_LOCAL_POS, ! /// Apply a force at a position relative to the global ! /// coordinate system in a direction relative to the global /// coordinate system. GLOBAL_FORCE_AT_GLOBAL_POS }; ! /// Data structure containing all necessary info for applying a /// force/torque to a Solid. struct Force *************** *** 107,130 **** ForceType type; ! /// Specifies how long to apply to force. This makes it easy to ! /// apply forces independent of the step size. This will be ignored /// if "singleStep" is true. real duration; ! /// This is mainly used internally by OPAL. It specifies that ! /// the force will be applied across a single time step. If this /// parameter is true, "duration" will be ignored. bool singleStep; ! /// The force direction or torque axis. This parameter encodes the /// magnitude of the force or torque. Vec3r vec; ! /// Only used when the force is applied at an offset (i.e. not /// the center of mass). Point3r pos; }; ! /// Data structure describing material properties. These properties /// determine the collision response when two Solids collide. struct Material --- 109,132 ---- ForceType type; ! /// Specifies how long to apply to force. This makes it easy to ! /// apply forces independent of the step size. This will be ignored /// if "singleStep" is true. real duration; ! /// This is mainly used internally by OPAL. It specifies that ! /// the force will be applied across a single time step. If this /// parameter is true, "duration" will be ignored. bool singleStep; ! /// The force direction or torque axis. This parameter encodes the /// magnitude of the force or torque. Vec3r vec; ! /// Only used when the force is applied at an offset (i.e. not /// the center of mass). Point3r pos; }; ! /// Data structure describing material properties. These properties /// determine the collision response when two Solids collide. struct Material *************** *** 151,155 **** } ! /// Determines how far Solids can interpenetrate. This must /// be between 0 and 1. real hardness; --- 153,157 ---- } ! /// Determines how far Solids can interpenetrate. This must /// be between 0 and 1. real hardness; *************** *** 158,175 **** real friction; ! /// Bounciness (i.e. restitution) determines how elastic the ! /// collisions will be between this Material and another. In other ! /// words, the more bounciness, the farther the Solids will bounce ! /// when they collide (and, in real life, the less energy is lost /// due to heat and sound). This must be between 0 and 1. real bounciness; ! /// Density combined with the volume of a Solid's shapes determine /// the Solid's mass. This must be >= 0. real density; }; ! /// Solver accuracy levels determine how the physics engine constraint ! /// solver is used (e.g. the number of iterations in an iterative /// solver). enum SolverAccuracyLevel --- 160,177 ---- real friction; ! /// Bounciness (i.e. restitution) determines how elastic the ! /// collisions will be between this Material and another. In other ! /// words, the more bounciness, the farther the Solids will bounce ! /// when they collide (and, in real life, the less energy is lost /// due to heat and sound). This must be between 0 and 1. real bounciness; ! /// Density combined with the volume of a Solid's shapes determine /// the Solid's mass. This must be >= 0. real density; }; ! /// Solver accuracy levels determine how the physics engine constraint ! /// solver is used (e.g. the number of iterations in an iterative /// solver). enum SolverAccuracyLevel *************** *** 182,186 **** }; ! /// Joints use different break modes to determine how they are damaged /// from stress. enum JointBreakMode --- 184,188 ---- }; ! /// Joints use different break modes to determine how they are damaged /// from stress. enum JointBreakMode *************** *** 239,243 **** namespace globals { ! /// The highest value that can be used for the Simulator's /// max contacts parameter. const int maxMaxContacts=(int)128; --- 241,245 ---- namespace globals { ! /// The highest value that can be used for the Simulator's /// max contacts parameter. const int maxMaxContacts=(int)128; *************** *** 266,276 **** // Global materials ! const Material metalMaterial(metalHardness, metalFriction, metalBounciness, metalDensity); ! const Material woodMaterial(woodHardness, woodFriction, woodBounciness, woodDensity); ! const Material rubberMaterial(rubberHardness, rubberFriction, rubberBounciness, rubberDensity); ! const Material iceMaterial(iceHardness, iceFriction, iceBounciness, iceDensity); } --- 268,278 ---- // Global materials ! const Material metalMaterial(metalHardness, metalFriction, metalBounciness, metalDensity); ! const Material woodMaterial(woodHardness, woodFriction, woodBounciness, woodDensity); ! const Material rubberMaterial(rubberHardness, rubberFriction, rubberBounciness, rubberDensity); ! const Material iceMaterial(iceHardness, iceFriction, iceBounciness, iceDensity); } Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SConscript 24 Jun 2005 17:50:48 -0000 1.21 --- SConscript 30 Nov 2005 06:28:12 -0000 1.22 *************** *** 81,84 **** --- 81,85 ---- ThrusterMotor.cpp VolumeSensor.cpp + Vec3r.cpp """) --- NEW FILE: Vec3r.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 header #include "Vec3r.h" //#pragma implementation // system headers #include <cassert> namespace opal { Vec3r::Vec3r() { x = 0; y = 0; z = 0; } Vec3r::Vec3r( const Vec3r & src ) { x = src.x; y = src.y; z = src.z; } Vec3r::Vec3r( real xx, real yy, real zz ) { x = xx; y = yy; z = zz; } Vec3r::Vec3r( const real * data ) { x = data[ 0 ]; y = data[ 1 ]; z = data[ 2 ]; } void Vec3r::set( real xx, real yy, real zz ) { x = xx; y = yy; z = zz; } void Vec3r::set( real * data ) { x = data[ 0 ]; y = data[ 1 ]; z = data[ 2 ]; } real & Vec3r::operator[] ( unsigned int i ) { switch ( i ) { case 0: return x; case 1: return y; case 2: return z; default: assert( i < 3 && i > -1 ); } } const real & Vec3r::operator[] ( unsigned int i ) const { switch ( i ) { case 0: return x; case 1: return y; case 2: return z; default: assert( i < 3 && i > -1 ); } } real Vec3r::lengthSquared() const { return dot( *this, *this ); } real Vec3r::length() const { return sqrt( dot( *this, *this ) ); } void Vec3r::normalize() { real len = length(); assert( 0 != len ); real factor = ( real ) 1.0 / len; ( *this ) *= factor; } Vec3r Vec3r::unit() const { return ( *this ) / length(); } void Vec3r::operator+=( const Vec3r & v ) { x += v.x; y += v.y; z += v.z; } void Vec3r::operator-=( const Vec3r & v ) { x -= v.x; y -= v.y; z -= v.z; } void Vec3r::operator*=( const Vec3r & v ) { x *= v.x; y *= v.y; z *= v.z; } void Vec3r::operator*=( real scalar ) { x *= scalar; y *= scalar; z *= scalar; } void Vec3r::operator/=( real scalar ) { x /= scalar; y /= scalar; z /= scalar; } void Vec3r::operator/=( const Vec3r & v ) { x /= v.x; y /= v.y; z /= v.z; } bool Vec3r::operator==( const Vec3r & v ) { return ( x == v.x && y == v.y && z == v.z ); } void Vec3r::operator=( const Vec3r & v ) { x = v.x; y = v.y; z = v.z; } bool Vec3r::operator!=( const Vec3r & v ) { return ( x != v.x || y != v.y || 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; } } Index: Makefile.in =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.in,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.in 21 Nov 2005 13:59:16 -0000 1.3 --- Makefile.in 30 Nov 2005 06:28:12 -0000 1.4 *************** *** 16,19 **** --- 16,20 ---- + srcdir = @srcdir@ top_srcdir = @top_srcdir@ *************** *** 40,44 **** bin_PROGRAMS = test_opal$(EXEEXT) subdir = src ! DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in --- 41,46 ---- bin_PROGRAMS = test_opal$(EXEEXT) subdir = src ! DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ ! $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in *************** *** 60,64 **** ServoMotor.$(OBJEXT) Simulator.$(OBJEXT) Solid.$(OBJEXT) \ SolidData.$(OBJEXT) Space.$(OBJEXT) SpringMotor.$(OBJEXT) \ ! ThrusterMotor.$(OBJEXT) VolumeSensor.$(OBJEXT) libopalode_a_OBJECTS = $(am_libopalode_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" --- 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)" *************** *** 67,71 **** am_test_opal_OBJECTS = testopal.$(OBJEXT) testsolid.$(OBJEXT) \ testAccelerationSensor.$(OBJEXT) testRaycastSensor.$(OBJEXT) \ ! testSimulator.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ --- 69,74 ---- am_test_opal_OBJECTS = testopal.$(OBJEXT) testsolid.$(OBJEXT) \ testAccelerationSensor.$(OBJEXT) testRaycastSensor.$(OBJEXT) \ ! testSimulator.$(OBJEXT) testVec3r.$(OBJEXT) \ ! testPoint3r.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ *************** *** 92,95 **** --- 95,99 ---- pdf-recursive ps-recursive uninstall-info-recursive \ uninstall-recursive + HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags *************** *** 201,217 **** SUBDIRS = external ODE 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 test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode all: all-recursive --- 205,221 ---- SUBDIRS = external ODE 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 \ ! 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 + noinst_HEADERS = Mass.h Matrix33r.h all: all-recursive *************** *** 312,319 **** --- 316,326 ---- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SpringMotor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ThrusterMotor.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vec3r.Po@am__quote@ @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)/testPoint3r.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@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testVec3r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testopal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testsolid.Po@am__quote@ *************** *** 526,530 **** check-am: all-am check: check-recursive ! all-am: Makefile $(LIBRARIES) $(PROGRAMS) installdirs: installdirs-recursive installdirs-am: --- 533,537 ---- check-am: all-am check: check-recursive ! all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS) installdirs: installdirs-recursive installdirs-am: --- NEW FILE: testPoint3r.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> #include <sstream> // project headers #include "opal.h" using namespace opal; namespace testPoint3r { QT_TEST( default_constructor ) { Point3r v; QT_CHECK_EQUAL( v.x, 0 ); QT_CHECK_EQUAL( v.y, 0 ); QT_CHECK_EQUAL( v.z, 0 ); } QT_TEST( copy_constructor ) { Point3r copy( 1, 2, 3 ); Point3r v( copy ); QT_CHECK_EQUAL( v.x, 1 ); QT_CHECK_EQUAL( v.y, 2 ); QT_CHECK_EQUAL( v.z, 3 ); } QT_TEST( set_constructor ) { Point3r v( 1, 2, 3 ); QT_CHECK_EQUAL( v.x, 1 ); QT_CHECK_EQUAL( v.y, 2 ); QT_CHECK_EQUAL( v.z, 3 ); } QT_TEST( assign_constructor ) { Point3r v = Point3r( 1, 2, 3 ); QT_CHECK_EQUAL( v.x, 1 ); QT_CHECK_EQUAL( v.y, 2 ); QT_CHECK_EQUAL( v.z, 3 ); } QT_TEST( array_constructor ) { real d[] = {1, 2, 3}; Point3r v( d ); QT_CHECK_EQUAL( v.x, 1 ); QT_CHECK_EQUAL( v.y, 2 ); QT_CHECK_EQUAL( v.z, 3 ); } QT_TEST( set ) { Point3r v; v.set( 1, 2, 3 ); QT_CHECK_EQUAL( v.x, 1 ); QT_CHECK_EQUAL( v.y, 2 ); QT_CHECK_EQUAL( v.z, 3 ); } QT_TEST( set_array ) { real d[] = {1, 2, 3}; Point3r v; v.set( d ); QT_CHECK_EQUAL( v.x, 1 ); QT_CHECK_EQUAL( v.y, 2 ); QT_CHECK_EQUAL( v.z, 3 ); } QT_TEST( operator_sq_brackets ) { Point3r v( 1, 2, 3 ); QT_CHECK_EQUAL( v[ 0 ], 1 ); QT_CHECK_EQUAL( v[ 1 ], 2 ); QT_CHECK_EQUAL( v[ 2 ], 3 ); } QT_TEST( operator_add ) { Point3r v( 1, 2, 3 ); Vec3r w( 4, 5, 6 ); QT_CHECK_EQUAL( v + w, Point3r( 5, 7, 9 ) ); } QT_TEST( operator_add_to ) { Point3r v( 1, 2, 3 ); Vec3r w( 4, 5, 6 ); v += w; QT_CHECK_EQUAL( v, Point3r( 5, 7, 9 ) ); } QT_TEST( operator_substract_vector ) { Point3r v( 1, 2, 3 ); Vec3r w( 4, 5, 6 ); QT_CHECK_EQUAL( v - w, Point3r( -3, -3, -3 ) ); } QT_TEST( operator_substract_from_vector ) { Point3r v( 1, 2, 3 ); Vec3r w( 4, 5, 6 ); v -= w; QT_CHECK_EQUAL( v, Point3r( -3, -3, -3 ) ); } QT_TEST( operator_substract_point ) { Point3r v( 1, 2, 3 ); Point3r w( 4, 5, 6 ); QT_CHECK_EQUAL( v - w, Vec3r( -3, -3, -3 ) ); } QT_TEST( operator_substract_from_point ) { Point3r v( 1, 2, 3 ); Vec3r w( 4, 5, 6 ); v -= w; QT_CHECK_EQUAL( v, Point3r( -3, -3, -3 ) ); } QT_TEST( operator_mutliply_scalar_after ) { Point3r v( 1, 2, 3 ); QT_CHECK_EQUAL( v * 3, Point3r( 3, 6, 9 ) ); } QT_TEST( operator_mutliply_scalar_before ) { Point3r v( 1, 2, 3 ); QT_CHECK_EQUAL( 3 * v, Point3r( 3, 6, 9 ) ); } QT_TEST( operator_divide_vector ) { Point3r v( 1, 2, 3 ); QT_CHECK_EQUAL( v / 2, Point3r( 1 / 2.0, 2 / 2.0, 3 / 2.0 ) ); } QT_TEST( operator_divide_scalar ) { Point3r v( 1, 2, 3 ); QT_CHECK_EQUAL( v / 2, Point3r( 0.5, 1, 1.5 ) ); } QT_TEST( operator_equal ) { QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) == Point3r( 1, 2, 3 ), true ); QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) == Point3r( 4, 2, 3 ), false ); QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) == Point3r( 1, 4, 3 ), false ); QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) == Point3r( 1, 2, 4 ), false ); } QT_TEST( operator_not_equal ) { QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) != Point3r( 1, 2, 3 ), false ); QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) != Point3r( 4, 2, 3 ), true ); QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) != Point3r( 1, 4, 3 ), true ); QT_CHECK_EQUAL( Point3r( 1, 2, 3 ) != Point3r( 1, 2, 4 ), true ); } QT_TEST( negate ) { QT_CHECK_EQUAL( -Point3r( 1, 2, 3 ), Point3r( -1, -2, -3 ) ); } QT_TEST( operator_stream ) { { std::ostringstream ss; ss << Point3r( 1, 1, 1 ); QT_CHECK_EQUAL( ss.str(), "[1 1 1]" ); } { std::ostringstream ss; ss << Point3r( 1, 1, 1.5 ); QT_CHECK_EQUAL( ss.str(), "[1 1 1.5]" ); } } QT_TEST( distance ) { QT_CHECK_EQUAL( distance( Point3r( 1, 2, 3 ) , Point3r( 1, 2, 3 ) ), 0 ); QT_CHECK_EQUAL( distance( Point3r( 1, 0, 1 ) , Point3r( 1, 0, 3 ) ), 2 ); QT_CHECK_EQUAL( distance( Point3r( 1, 0, 3 ) , Point3r( 1, 0, 1 ) ), 2 ); } } Index: OpalMath.h =================================================================== RCS file: /cvsroot/opal/opal/src/OpalMath.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** OpalMath.h 24 Jun 2005 16:40:49 -0000 1.14 --- OpalMath.h 30 Nov 2005 06:28:12 -0000 1.15 *************** *** 29,32 **** --- 29,33 ---- #define OPAL_OPAL_MATH_H + // system headers #include <math.h> *************** *** 67,75 **** } ! /// Returns true if the two values are equal within some tolerance, ! /// using a combination of absolute and relative (epsilon is scaled ! /// by the magnitudes of the values) tolerance, depending on whether /// both values are both less than 1. ! /// See Christer Ericson's GDC 2005 presentation: /// http://realtimecollisiondetection.net/pubs/GDC05_Ericson_Numerical_Robustness_for_Geometric_Calculations.ppt inline bool areEqual(real x, real y) --- 68,76 ---- } ! /// Returns true if the two values are equal within some tolerance, ! /// using a combination of absolute and relative (epsilon is scaled ! /// by the magnitudes of the values) tolerance, depending on whether /// both values are both less than 1. ! /// See Christer Ericson's GDC 2005 presentation: /// http://realtimecollisiondetection.net/pubs/GDC05_Ericson_Numerical_Robustness_for_Geometric_Calculations.ppt inline bool areEqual(real x, real y) *************** *** 98,106 **** } ! #include "Point3r.h" ! #include "Vec3r.h" ! #include "Rayr.h" ! #include "Matrix44r.h" ! #include "Quaternion.h" #endif --- 99,107 ---- } ! //#include "Point3r.h" ! //#include "Vec3r.h" ! //#include "Rayr.h" ! //#include "Matrix44r.h" ! //#include "Quaternion.h" #endif Index: SpringMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SpringMotor.h 30 Mar 2005 23:26:23 -0000 1.14 --- SpringMotor.h 30 Nov 2005 06:28:12 -0000 1.15 *************** *** 30,33 **** --- 30,34 ---- #include "Defines.h" + #include "Matrix44r.h" #include "Motor.h" #include "SpringMotorData.h" *************** *** 35,41 **** namespace opal { ! /// This is a spring that either 1) operates in 3 dimensions to keep ! /// a Solid in a desired position, or 2) operates in 3 degrees of ! /// rotational motion to keep a Solid in a desired orientation. It can /// also do both modes at once. class SpringMotor : public Motor --- 36,42 ---- namespace opal { ! /// This is a spring that either 1) operates in 3 dimensions to keep ! /// a Solid in a desired position, or 2) operates in 3 degrees of ! /// rotational motion to keep a Solid in a desired orientation. It can /// also do both modes at once. class SpringMotor : public Motor *************** *** 46,50 **** virtual ~SpringMotor(); ! /// Initializes the Motor with the given data structure. If the /// Solid pointer in the data are NULL, the Motor will do nothing. virtual void OPAL_CALL init(const SpringMotorData& data); --- 47,51 ---- virtual ~SpringMotor(); ! /// Initializes the Motor with the given data structure. If the /// Solid pointer in the data are NULL, the Motor will do nothing. virtual void OPAL_CALL init(const SpringMotorData& data); *************** *** 63,114 **** virtual void OPAL_CALL setEnabled(bool e); ! /// Sets the spring's attach point on the Solid. This is a local /// offset point from the Solid's position. virtual void OPAL_CALL setLocalAttachOffset(const Point3r& offset); ! /// Returns the spring's attach point on the Solid. This is a local /// offset point from the Solid's position. virtual const Point3r& OPAL_CALL getLocalAttachOffset()const; ! /// Sets the spring's attach point on the Solid in global /// coordinates. virtual void OPAL_CALL setGlobalAttachPoint(const Point3r& p); ! /// Returns the spring's attach point on the Solid in global /// coordinates. virtual Point3r OPAL_CALL getGlobalAttachPoint()const; ! /// Sets the desired position and orientation. virtual void OPAL_CALL setDesiredTransform(const Matrix44r& transform); ! /// Sets the desired position. virtual void OPAL_CALL setDesiredPosition(const Point3r& pos); ! /// Sets the desired orientation. ! virtual void OPAL_CALL setDesiredOrientation(const Vec3r& forward, const Vec3r& up, const Vec3r& right); ! /// Sets the damping constant for linear mode. virtual void OPAL_CALL setLinearKd(real kd); ! /// Sets the spring constant for linear mode. virtual void OPAL_CALL setLinearKs(real ks); ! /// Returns the damping constant for linear mode. virtual real OPAL_CALL getLinearKd()const; ! /// Returns the spring constant for linear mode. virtual real OPAL_CALL getLinearKs()const; ! /// Sets the damping constant for angular mode. virtual void OPAL_CALL setAngularKd(real kd); ! /// Sets the spring constant for angular mode. virtual void OPAL_CALL setAngularKs(real ks); ! /// Returns the damping constant for angular mode. virtual real OPAL_CALL getAngularKd()const; ! /// Returns the spring constant for angular mode. virtual real OPAL_CALL getAngularKs()const; --- 64,115 ---- virtual void OPAL_CALL setEnabled(bool e); ! /// Sets the spring's attach point on the Solid. This is a local /// offset point from the Solid's position. virtual void OPAL_CALL setLocalAttachOffset(const Point3r& offset); ! /// Returns the spring's attach point on the Solid. This is a local /// offset point from the Solid's position. virtual const Point3r& OPAL_CALL getLocalAttachOffset()const; ! /// Sets the spring's attach point on the Solid in global /// coordinates. virtual void OPAL_CALL setGlobalAttachPoint(const Point3r& p); ! /// Returns the spring's attach point on the Solid in global /// coordinates. virtual Point3r OPAL_CALL getGlobalAttachPoint()const; ! /// Sets the desired position and orientation. virtual void OPAL_CALL setDesiredTransform(const Matrix44r& transform); ! /// Sets the desired position. virtual void OPAL_CALL setDesiredPosition(const Point3r& pos); ! /// Sets the desired orientation. ! virtual void OPAL_CALL setDesiredOrientation(const Vec3r& forward, const Vec3r& up, const Vec3r& right); ! /// Sets the damping constant for linear mode. virtual void OPAL_CALL setLinearKd(real kd); ! /// Sets the spring constant for linear mode. virtual void OPAL_CALL setLinearKs(real ks); ! /// Returns the damping constant for linear mode. virtual real OPAL_CALL getLinearKd()const; ! /// Returns the spring constant for linear mode. virtual real OPAL_CALL getLinearKs()const; ! /// Sets the damping constant for angular mode. virtual void OPAL_CALL setAngularKd(real kd); ! /// Sets the spring constant for angular mode. virtual void OPAL_CALL setAngularKs(real ks); ! /// Returns the damping constant for angular mode. virtual real OPAL_CALL getAngularKd()const; ! /// Returns the spring constant for angular mode. virtual real OPAL_CALL getAngularKs()const; Index: Point3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Point3r.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Point3r.h 18 Apr 2005 22:21:03 -0000 1.13 --- Point3r.h 30 Nov 2005 06:28:12 -0000 1.14 *************** *** 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_POINT3R_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_POINT3R_H *************** *** 34,208 **** namespace opal { ! class Point3r; ! inline Point3r operator+(const Point3r &u, const Vec3r &v); ! inline Point3r operator-(const Point3r &u, const Vec3r &v); ! inline Vec3r operator-(const Point3r &u, const Point3r &v); ! inline Point3r operator*(const Point3r &v, real scalar); ! i... [truncated message content] |