Changeset 6617 in orxonox.OLD for trunk/src/lib/math/vector.h
- Timestamp:
- Jan 19, 2006, 12:45:55 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/math/vector.h
r6616 r6617 124 124 #define VECTOR_RAND(sideLength) (Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * sideLength) 125 125 126 127 //! 3D rotation (OBSOLETE)128 /**129 Class to handle 3-dimensional rotations.130 Can create a rotation from several inputs, currently stores rotation using a 3x3 Matrix131 */132 class Rotation {133 public:134 135 float m[9]; //!< 3x3 Rotation Matrix136 137 Rotation ( const Vector& v);138 Rotation ( const Vector& axis, float angle);139 Rotation ( float pitch, float yaw, float roll);140 Rotation ();141 ~Rotation () {}142 143 Rotation operator* (const Rotation& r);144 145 void glmatrix (float* buffer);146 };147 148 //!< Apply a rotation to a vector149 Vector rotateVector( const Vector& v, const Rotation& r);150 151 //! 3D line152 /**153 Class to store Lines in 3-dimensional space154 155 Supports line-to-line distance measurements and rotation156 */157 class Line158 {159 public:160 161 Vector r; //!< Offset162 Vector a; //!< Direction163 164 Line ( Vector r, Vector a) : r(r), a(a) {} //!< assignment constructor165 Line () : r(Vector(0,0,0)), a(Vector (1,1,1)) {}166 ~Line () {}167 168 float distance (const Line& l) const;169 float distancePoint (const Vector& v) const;170 float distancePoint (const sVec3D& v) const;171 Vector* footpoints (const Line& l) const;172 float len () const;173 174 void rotate(const Rotation& rot);175 };176 177 //! 3D plane178 /**179 Class to handle planes in 3-dimensional space180 181 Critical for polygon-based collision detection182 */183 class Plane184 {185 public:186 187 Vector n; //!< Normal vector188 float k; //!< Offset constant189 190 Plane (const Vector& a, const Vector& b, const Vector& c);191 Plane (const Vector& norm, const Vector& p);192 Plane (const Vector& norm, const sVec3D& p);193 Plane (const Vector& n, float k) : n(n), k(k) {} //!< assignment constructor194 Plane () : n(Vector(1,1,1)), k(0) {}195 ~Plane () {}196 197 Vector intersectLine (const Line& l) const;198 float distancePoint (const Vector& p) const;199 float distancePoint (const sVec3D& p) const;200 float locatePoint (const Vector& p) const;201 };202 203 204 205 //! A class that represents a rectangle, this is needed for SpatialSeparation206 class Rectangle207 {208 209 public:210 Rectangle() { this->center = Vector(); }211 Rectangle(const Vector ¢er, float len) { this->center = Vector(center.x, center.y, center.z); this->axis[0] = len; this->axis[1] = len; }212 virtual ~Rectangle() {}213 214 /** \brief sets the center of the rectangle to a defined vector @param center the new center */215 inline void setCenter(const Vector ¢er) { this->center = center;}216 /** \brief sets the center of the rectangle to a defined vector @param x coord of the center @param y coord of the center @param z coord of the center */217 inline void setCenter(float x, float y, float z) { this->center.x = x; this->center.y = y; this->center.z = z; }218 /** \brief returns the center of the rectangle to a defined vector @returns center the new center */219 inline const Vector& getCenter() const { return this->center; }220 221 /** \brief sets both axis of the rectangle to a defined vector @param unityLength the new center */222 inline void setAxis(float unityLength) { this->axis[0] = unityLength; this->axis[1] = unityLength; }223 /** \brief sets both axis of the rectangle to a defined vector @param v1 the length of the x axis @param v2 the length of the z axis*/224 inline void setAxis(float v1, float v2) { this->axis[0] = v1; this->axis[1] = v2; }225 /** \brief gets one axis length of the rectangle @returns the length of the axis 0 */226 inline float getAxis() { return this-> axis[0]; }227 228 private:229 Vector center;230 float axis[2];231 };232 233 234 126 #endif /* __VECTOR_H_ */ 235 127
Note: See TracChangeset
for help on using the changeset viewer.