X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fmath%2Fvector2.h;h=2d7df3368eb3837cc8e9832c3161dde3904eb9e0;hb=646f736e77b085c86e982c0d1d4b895c2a431330;hp=63025487803081aa7f03d6d74f00978605f3304e;hpb=4bd2fbea750e7dc85627868d8d276cc416b01b5a;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/math/vector2.h b/dali/public-api/math/vector2.h index 6302548..2d7df33 100644 --- a/dali/public-api/math/vector2.h +++ b/dali/public-api/math/vector2.h @@ -2,7 +2,7 @@ #define __DALI_VECTOR_2_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ */ // EXTERNAL INCLUDES +#include // uint32_t #include // INTERNAL INCLUDES @@ -37,8 +38,9 @@ struct Vector4; /** * @brief A two dimensional vector. + * @SINCE_1_0.0 */ -struct DALI_IMPORT_API Vector2 +struct DALI_CORE_API Vector2 { // (x width) and (y height) must be consecutive in memory. // No other data must be added before (x width) member. @@ -48,6 +50,7 @@ public: /** * @brief Constructor. + * @SINCE_1_0.0 */ Vector2() : x(0.0f), @@ -58,6 +61,7 @@ public: /** * @brief Constructor. * + * @SINCE_1_0.0 * @param[in] x x or width component * @param[in] y y or height component */ @@ -69,7 +73,8 @@ public: /** * @brief Conversion constructor from an array of two floats. * - * @param [in] array of xy + * @SINCE_1_0.0 + * @param[in] array Array of xy */ explicit Vector2(const float* array) : x(array[0]), @@ -80,14 +85,16 @@ public: /** * @brief Constructor. * - * @param [in] vec3 Vector3 to create this vector from + * @SINCE_1_0.0 + * @param[in] vec3 Vector3 to create this vector from */ explicit Vector2(const Vector3& vec3); /** * @brief Constructor. * - * @param [in] vec4 Vector4 to create this vector from + * @SINCE_1_0.0 + * @param[in] vec4 Vector4 to create this vector from */ explicit Vector2(const Vector4& vec4); @@ -105,8 +112,9 @@ public: /** * @brief Assignment operator. * - * @param[in] array of floats - * @return itself + * @SINCE_1_0.0 + * @param[in] array Array of floats + * @return Itself */ Vector2& operator=(const float* array) { @@ -119,23 +127,26 @@ public: /** * @brief Assignment operator. * - * @param[in] rhs vector to assign. - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs Vector to assign + * @return Itself */ Vector2& operator=(const Vector3& rhs); /** * @brief Assignment operator. * - * @param[in] rhs vector to assign. - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs Vector to assign + * @return Itself */ Vector2& operator=(const Vector4& rhs); /** * @brief Addition operator. * - * @param[in] rhs vector to add. + * @SINCE_1_0.0 + * @param[in] rhs Vector to add * @return A vector containing the result of the addition */ Vector2 operator+(const Vector2& rhs) const @@ -148,8 +159,9 @@ public: /** * @brief Addition assignment operator. * - * @param[in] rhs vector to add. - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs Vector to add + * @return Itself */ Vector2& operator+=(const Vector2& rhs) { @@ -162,7 +174,8 @@ public: /** * @brief Subtraction operator. * - * @param[in] rhs the vector to subtract + * @SINCE_1_0.0 + * @param[in] rhs The vector to subtract * @return A vector containing the result of the subtraction */ Vector2 operator-(const Vector2& rhs) const @@ -175,8 +188,9 @@ public: /** * @brief Subtraction assignment operator. * - * @param[in] rhs the vector to subtract - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs The vector to subtract + * @return Itself */ Vector2& operator-=(const Vector2& rhs) { @@ -189,7 +203,8 @@ public: /** * @brief Multiplication operator. * - * @param[in] rhs the vector to multiply + * @SINCE_1_0.0 + * @param[in] rhs The vector to multiply * @return A vector containing the result of the multiplication */ Vector2 operator*(const Vector2& rhs) const @@ -200,7 +215,8 @@ public: /** * @brief Multiplication operator. * - * @param[in] rhs the float value to scale the vector + * @SINCE_1_0.0 + * @param[in] rhs The float value to scale the vector * @return A vector containing the result of the scaling */ Vector2 operator*(float rhs) const @@ -211,8 +227,9 @@ public: /** * @brief Multiplication assignment operator. * - * @param[in] rhs the vector to multiply - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs The vector to multiply + * @return Itself */ Vector2& operator*=(const Vector2& rhs) { @@ -225,8 +242,9 @@ public: /** * @brief Multiplication assignment operator. * - * @param[in] rhs the float value to scale the vector - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs The float value to scale the vector + * @return Itself */ Vector2& operator*=(float rhs) { @@ -239,7 +257,8 @@ public: /** * @brief Division operator. * - * @param[in] rhs the vector to divide + * @SINCE_1_0.0 + * @param[in] rhs The vector to divide * @return A vector containing the result of the division */ Vector2 operator/(const Vector2& rhs) const @@ -250,6 +269,7 @@ public: /** * @brief Division operator. * + * @SINCE_1_0.0 * @param[in] rhs The float value to scale the vector by * @return A vector containing the result of the scaling */ @@ -262,8 +282,9 @@ public: /** * @brief Division assignment operator. * - * @param[in] rhs the vector to divide - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs The vector to divide + * @return Itself */ Vector2& operator/=(const Vector2& rhs) { @@ -276,8 +297,9 @@ public: /** * @brief Division assignment operator. * - * @param[in] rhs the float value to scale the vector by - * @return itself + * @SINCE_1_0.0 + * @param[in] rhs The float value to scale the vector by + * @return Itself */ Vector2& operator/=(float rhs) { @@ -290,7 +312,8 @@ public: /** * @brief Unary negation operator. * - * @return A vector containg the negation + * @SINCE_1_0.0 + * @return A vector containing the negation */ Vector2 operator-() const { @@ -302,8 +325,9 @@ public: /** * @brief Equality operator. * - * utilises appropriate machine epsilon values; + * Utilizes appropriate machine epsilon values. * + * @SINCE_1_0.0 * @param[in] rhs The vector to test against * @return true if the vectors are equal */ @@ -312,8 +336,9 @@ public: /** * @brief Inequality operator. * - * utilises appropriate machine epsilon values; + * Utilizes appropriate machine epsilon values. * + * @SINCE_1_0.0 * @param[in] rhs The vector to test against * @return true if the vectors are not equal */ @@ -325,11 +350,12 @@ public: /** * @brief Const array subscript operator overload. * - * Asserts if index is out of range. Should be 0 or 1 - * @param[in] index Subscript - * @return The float at the given index + * Asserts if index is out of range. Should be 0 or 1. + * @SINCE_1_0.0 + * @param[in] index Subscript index + * @return The float at the given index */ - const float& operator[](const unsigned int index) const + const float& operator[](const uint32_t index) const { DALI_ASSERT_ALWAYS( index < 2 && "Vector element index out of bounds" ); @@ -339,11 +365,12 @@ public: /** * @brief Mutable array subscript operator overload. * - * Asserts if index is out of range. Should be 0 or 1 + * Asserts if index is out of range. Should be 0 or 1. + * @SINCE_1_0.0 * @param[in] index Subscript index - * @return The float at the given index. + * @return The float at the given index */ - float& operator[](const unsigned int index) + float& operator[](const uint32_t index) { DALI_ASSERT_ALWAYS( index < 2 && "Vector element index out of bounds" ); @@ -353,7 +380,8 @@ public: /** * @brief Returns the length of the vector. * - * @return the length of the vector + * @SINCE_1_0.0 + * @return The length of the vector */ float Length() const; @@ -362,21 +390,24 @@ public: * * This is more efficient than Length() for threshold * testing as it avoids the use of a square root. - * @return the length of the vector squared. + * @SINCE_1_0.0 + * @return The length of the vector squared */ float LengthSquared() const; /** * @brief Sets the vector to be unit length, whilst maintaining its direction. * + * @SINCE_1_0.0 */ void Normalize(); /** * @brief Clamps the vector between minimum and maximum vectors. * - * @param [in] min the minimum vector - * @param [in] max the maximum vector + * @SINCE_1_0.0 + * @param[in] min The minimum vector + * @param[in] max The maximum vector */ void Clamp( const Vector2& min, const Vector2& max ); @@ -386,8 +417,9 @@ public: * The order of the values in this array are as follows: * 0: x (or width) * 1: y (or height) + * @SINCE_1_0.0 + * @return The vector contents as an array of 2 floats * @note inlined for performance reasons (generates less code than a function call) - * @return the vector contents as an array of 2 floats. */ const float* AsFloat() const {return &x;} @@ -397,8 +429,9 @@ public: * The order of the values in this array are as follows: * 0: x (or width) * 1: y (or height) + * @SINCE_1_0.0 + * @return The vector contents as an array of 2 floats * @note inlined for performance reasons (generates less code than a function call) - * @return the vector contents as an array of 2 floats. */ float* AsFloat() {return &x;} @@ -423,26 +456,29 @@ public: // Data }; /** - * @brief Size is an alias of Dali::Vector2 + * @brief Size is an alias of Dali::Vector2. + * @SINCE_1_0.0 */ typedef Vector2 Size; /** * @brief Print a Vector2. * - * @param [in] o The output stream operator. - * @param [in] vector The vector to print. - * @return The output stream operator. + * @SINCE_1_0.0 + * @param[in] o The output stream operator + * @param[in] vector The vector to print + * @return The output stream operator */ -DALI_IMPORT_API std::ostream& operator<< (std::ostream& o, const Vector2& vector); +DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Vector2& vector); /** * @brief Returns a vector with components set to the minimum of the corresponding component in a and b. * - * If a=0,1 and b=1,0 returns a vector of 0,0. - * @param [in] a a vector - * @param [in] b a vector - * @return a vector containing the minimum of each component from a and b + * If a=0,1 and b=1,0 returns a vector of 0,0. + * @SINCE_1_0.0 + * @param[in] a A vector + * @param[in] b A vector + * @return A vector containing the minimum of each component from a and b */ inline Vector2 Min( const Vector2& a, const Vector2& b ) { @@ -452,10 +488,11 @@ inline Vector2 Min( const Vector2& a, const Vector2& b ) /** * @brief Returns a vector with components set to the maximum of the corresponding component in a and b. * - * If a=0,1 and b=1,0 returns a vector of 1,1 - * @param [in] a a vector - * @param [in] b a vector - * @return a vector containing the maximum of each component from a and b + * If a=0,1 and b=1,0 returns a vector of 1,1. + * @SINCE_1_0.0 + * @param[in] a A vector + * @param[in] b A vector + * @return A vector containing the maximum of each component from a and b */ inline Vector2 Max( const Vector2& a, const Vector2& b ) { @@ -465,12 +502,13 @@ inline Vector2 Max( const Vector2& a, const Vector2& b ) /** * @brief Clamps each of vector v's components between minimum and maximum values. * - * @param [in] v a vector - * @param [in] min the minimum value - * @param [in] max the maximum value - * @return a vector containing the clamped components of v + * @SINCE_1_0.0 + * @param[in] v A vector + * @param[in] min The minimum value + * @param[in] max The maximum value + * @return A vector containing the clamped components of v */ -DALI_IMPORT_API Vector2 Clamp( const Vector2& v, const float& min, const float& max ); +DALI_CORE_API Vector2 Clamp( const Vector2& v, const float& min, const float& max ); // Allow Vector2 to be treated as a POD type template <> struct TypeTraits< Vector2 > : public BasicTypes< Vector2 > { enum { IS_TRIVIAL_TYPE = true }; };