From 6c21dceb35f7aaf90e54d3c030130e9465f343f3 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 11 Sep 2012 21:14:32 +0200 Subject: Tests rewrite and Doxygen in src/math - rewritten tests to use new framework - updated/reformatted Doxygen - removed legacy conversions --- src/math/vector.h | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/math/vector.h') diff --git a/src/math/vector.h b/src/math/vector.h index 4378e75..eb54a5b 100644 --- a/src/math/vector.h +++ b/src/math/vector.h @@ -32,16 +32,17 @@ namespace Math { -/** \struct Vector math/vector.h - \brief 3D (3x1) vector - - Represents a universal 3x1 vector that can be used in OpenGL and DirectX engines. - Contains the required methods for operating on vectors. - - All methods are made inline to maximize optimization. - - Unit tests for the structure and related functions are in module: math/test/vector_test.cpp. - +/** + * \struct Vector + * \brief 3D (3x1) vector + * + * Represents a universal 3x1 vector that can be used in OpenGL and DirectX engines. + * Contains the required methods for operating on vectors. + * + * All methods are made inline to maximize optimization. + * + * Unit tests for the structure and related functions are in module: math/test/vector_test.cpp. + * */ struct Vector { @@ -103,8 +104,10 @@ struct Vector } //! Calculates the cross product with another vector - /** \a right right-hand side vector - \returns the cross product*/ + /** + * \param right right-hand side vector + * \returns the cross product + */ inline Vector CrossMultiply(const Vector &right) const { float px = y * right.z - z * right.y; @@ -114,8 +117,10 @@ struct Vector } //! Calculates the dot product with another vector - /** \a right right-hand side vector - \returns the dot product */ + /** + * \param right right-hand side vector + * \returns the dot product + */ inline float DotMultiply(const Vector &right) const { return x * right.x + y * right.y + z * right.z; @@ -218,7 +223,7 @@ struct Vector return s.str(); } -}; // struct Point +}; // struct Vector //! Checks if two vectors are equal within given \a tolerance inline bool VectorsEqual(const Math::Vector &a, const Math::Vector &b, float tolerance = TOLERANCE) -- cgit v1.2.3-1-g7c22 From 10c9d92cd2581448d76548efb20957a7a1c24478 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 19 Sep 2012 21:23:42 +0200 Subject: Mouse wheel events, motion vectors - added mouse wheel events - added motion vectors to CRobotMain - other minor changes in event.h --- src/math/vector.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/math/vector.h') diff --git a/src/math/vector.h b/src/math/vector.h index eb54a5b..222d0cd 100644 --- a/src/math/vector.h +++ b/src/math/vector.h @@ -267,4 +267,14 @@ inline float Distance(const Math::Vector &a, const Math::Vector &b) (a.z-b.z)*(a.z-b.z) ); } +//! Clamps the vector \a vec to range between \a min and \a max +inline Vector Clamp(const Vector &vec, const Vector &min, const Vector &max) +{ + Vector clamped; + clamped.x = Min(Max(min.x, vec.x), max.x); + clamped.y = Min(Max(min.y, vec.y), max.y); + clamped.z = Min(Max(min.z, vec.z), max.z); + return clamped; +} + }; // namespace Math -- cgit v1.2.3-1-g7c22