.. index:: pair: class; EE::Math::Vector2 .. _doxid-class_e_e_1_1_math_1_1_vector2: template class EE::Math::Vector2 ================================ .. toctree:: :hidden: Overview ~~~~~~~~ Utility template class for manipulating 2-dimensional vectors. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class Vector2 { public: // fields static const Vector2 :target:`Zero` = Vector2(0, 0); static const Vector2 :target:`One` = Vector2(1, 1); T :target:`x`; T :target:`y`; // construction :ref:`Vector2`(); :ref:`Vector2`(T X, T Y); :target:`Vector2`(const Vector2& copy); // methods Vector2 :ref:`copy`(); T :ref:`dot`(const Vector2& V2) const; T :ref:`cross`(const Vector2& V2) const; Vector2 :ref:`perp`() const; Vector2 :ref:`rPerp`() const; Vector2 :ref:`rotate`(const Vector2& V2) const; Vector2 :ref:`unrotate`(const Vector2& V2) const; T :ref:`length`() const; T :ref:`lengthSq`() const; void :ref:`normalize`(); void :ref:`clamp`(T len); Vector2 :ref:`forAngle`(const T& a) const; T :ref:`toAngle`(); void :ref:`rotate`(const T& Angle); void :ref:`rotate`(const T& Angle, const Vector2& RotationCenter); T :ref:`distance`(const Vector2& Vec) const; T :ref:`distanceSq`(const Vector2& Vec) const; bool :ref:`nearDist`(const Vector2& Vec, T Dist) const; Vector2 :ref:`sphericalLerp`(const Vector2& Vec, T Time) const; Vector2 :ref:`sphericalLerpConst`(const Vector2& Vec, T Angle) const; Vector2 :ref:`lerp`(const Vector2& Vec, T Time) const; Vector2 :ref:`lerpConst`(const Vector2& Vec, T Dist) const; void :ref:`scale`(const Vector2& scale, const Vector2& Center); void :ref:`scale`(const T& scale, const Vector2& Center); Vector2 :target:`ceil`() const; Vector2 :target:`floor`() const; Vector2 :target:`round`() const; Vector2 :target:`roundUp`() const; Vector2 :target:`roundDown`() const; Vector2 :target:`abs`() const; Vector2<:ref:`Float`> :target:`asFloat`() const; Vector2 :target:`asInt`() const; Vector2& :target:`operator=`(const Vector2& right); }; .. _details-class_e_e_1_1_math_1_1_vector2: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Utility template class for manipulating 2-dimensional vectors. Construction ------------ .. index:: pair: function; Vector2 .. _doxid-class_e_e_1_1_math_1_1_vector2_1ad3bb57a4919db1f1f4adb16e254a1ea5: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2() Default constructor creates Vector2(0,0) .. index:: pair: function; Vector2 .. _doxid-class_e_e_1_1_math_1_1_vector2_1ae5cdb96662b0b9ab4884d4904408beb9: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2(T X, T Y) Creates a vector from its coordinates Methods ------- .. index:: pair: function; copy .. _doxid-class_e_e_1_1_math_1_1_vector2_1a97ee366c73c8de062731e880b9bbfdf5: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 copy() .. rubric:: Returns: A copy of the :ref:`Vector2 ` .. index:: pair: function; dot .. _doxid-class_e_e_1_1_math_1_1_vector2_1a791fabe92f4f83126db98bb63769462e: .. ref-code-block:: cpp :class: doxyrest-title-code-block T dot(const Vector2& V2) const .. rubric:: Returns: The Dot product of the 2D vectors. .. index:: pair: function; cross .. _doxid-class_e_e_1_1_math_1_1_vector2_1a8bff84dbe4bd3b048beabbb3291e86f7: .. ref-code-block:: cpp :class: doxyrest-title-code-block T cross(const Vector2& V2) const .. rubric:: Returns: The Cross product of the 2D vectors. .. index:: pair: function; perp .. _doxid-class_e_e_1_1_math_1_1_vector2_1a96c1f3bfe3f89d56507b1937607f8e5a: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 perp() const .. rubric:: Returns: The perpendicular vector .. index:: pair: function; rPerp .. _doxid-class_e_e_1_1_math_1_1_vector2_1aad040588dd077fa7a20d42a0664d7669: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 rPerp() const .. rubric:: Returns: The reveser perpendicular vector .. index:: pair: function; rotate .. _doxid-class_e_e_1_1_math_1_1_vector2_1abc8cdd7e0760146e4c60d519158b625a: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 rotate(const Vector2& V2) const Uses complex multiplication to rotate self by vec. Scaling will occur if self is not a unit vector. .. index:: pair: function; unrotate .. _doxid-class_e_e_1_1_math_1_1_vector2_1af51082fd0c3a00da3b2cbdfc8e6a9b95: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 unrotate(const Vector2& V2) const Inverse of :ref:`Vector2::rotate ` .. index:: pair: function; length .. _doxid-class_e_e_1_1_math_1_1_vector2_1a7b59c555996afda6bda655566d86d915: .. ref-code-block:: cpp :class: doxyrest-title-code-block T length() const .. rubric:: Returns: The vector Length .. index:: pair: function; lengthSq .. _doxid-class_e_e_1_1_math_1_1_vector2_1a215b3454c2572cfc9a81ca6a9d7857ef: .. ref-code-block:: cpp :class: doxyrest-title-code-block T lengthSq() const .. rubric:: Returns: The square of the length of the 2D vector. .. index:: pair: function; normalize .. _doxid-class_e_e_1_1_math_1_1_vector2_1a8cf06d2c169b7a0849d1fa12d9a2eefb: .. ref-code-block:: cpp :class: doxyrest-title-code-block void normalize() Normalize the vector .. index:: pair: function; clamp .. _doxid-class_e_e_1_1_math_1_1_vector2_1a29b54336aac6d4525533c6d6e50e3005: .. ref-code-block:: cpp :class: doxyrest-title-code-block void clamp(T len) .. rubric:: Returns: Clamp the vector to a magnitude length. .. index:: pair: function; forAngle .. _doxid-class_e_e_1_1_math_1_1_vector2_1ae204f13c2d0795641a2a6485a2378139: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 forAngle(const T& a) const .. rubric:: Returns: The unit length vector for the given angle (radians) .. index:: pair: function; toAngle .. _doxid-class_e_e_1_1_math_1_1_vector2_1a3a7cfc2124978ca1f5810a445204caf7: .. ref-code-block:: cpp :class: doxyrest-title-code-block T toAngle() .. rubric:: Returns: The angular direction vector is pointing in (radians). .. index:: pair: function; rotate .. _doxid-class_e_e_1_1_math_1_1_vector2_1adab6f8f206f0cf638915525065aaf479: .. ref-code-block:: cpp :class: doxyrest-title-code-block void rotate(const T& Angle) Rotates the vector .. index:: pair: function; rotate .. _doxid-class_e_e_1_1_math_1_1_vector2_1a1f23f66c5badafb4dffc3e087743f5d7: .. ref-code-block:: cpp :class: doxyrest-title-code-block void rotate(const T& Angle, const Vector2& RotationCenter) Rotates the vector against a defined rotation center .. index:: pair: function; distance .. _doxid-class_e_e_1_1_math_1_1_vector2_1aeac60693dd28e1f14c87f272d7bffdb8: .. ref-code-block:: cpp :class: doxyrest-title-code-block T distance(const Vector2& Vec) const .. rubric:: Returns: The distance between two vectors .. index:: pair: function; distanceSq .. _doxid-class_e_e_1_1_math_1_1_vector2_1a9030fb67884285fd44f87747ddd6fdd3: .. ref-code-block:: cpp :class: doxyrest-title-code-block T distanceSq(const Vector2& Vec) const .. rubric:: Returns: The square of the distance between two vectors .. index:: pair: function; nearDist .. _doxid-class_e_e_1_1_math_1_1_vector2_1a8266e04809549f603fdc3d42dee56dff: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool nearDist(const Vector2& Vec, T Dist) const .. rubric:: Returns: True if the distance between the two vectors is less than Dist .. index:: pair: function; sphericalLerp .. _doxid-class_e_e_1_1_math_1_1_vector2_1adb972389f08f5740c004fc16971c02c9: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 sphericalLerp(const Vector2& Vec, T Time) const .. rubric:: Returns: The spherical linear interpolation between two 2D vectors. .. index:: pair: function; sphericalLerpConst .. _doxid-class_e_e_1_1_math_1_1_vector2_1a109732b0c3fb0b252763aa8a078845ec: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 sphericalLerpConst(const Vector2& Vec, T Angle) const Spherical linear interpolation between two vectors .. index:: pair: function; lerp .. _doxid-class_e_e_1_1_math_1_1_vector2_1afa65ffb7b84b496b0bd84a38bc3791ed: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 lerp(const Vector2& Vec, T Time) const Performs a linear interpolation between two 2D vectors. .. index:: pair: function; lerpConst .. _doxid-class_e_e_1_1_math_1_1_vector2_1aec792f7b9533c6283733655f55bfe571: .. ref-code-block:: cpp :class: doxyrest-title-code-block Vector2 lerpConst(const Vector2& Vec, T Dist) const .. rubric:: Returns: A vector interpolated from self towards Vec with length Dist. .. index:: pair: function; scale .. _doxid-class_e_e_1_1_math_1_1_vector2_1a6ddb8841f4c7246cc0ed5fe421b302d6: .. ref-code-block:: cpp :class: doxyrest-title-code-block void scale(const Vector2& scale, const Vector2& Center) Scales the vector position against another vector .. index:: pair: function; scale .. _doxid-class_e_e_1_1_math_1_1_vector2_1a3bc5134f67132b14112e8cbc89b5a38e: .. ref-code-block:: cpp :class: doxyrest-title-code-block void scale(const T& scale, const Vector2& Center) Scales the vector position against another vector