vec2_t
vec2_t represents a two-dimensional vector commonly used in 2D space calculations, such as screen positions and UI element placements.
Declaration:
class vec2_t
{
float x;
float y;
// calculates the euclidean distance between this vector and another.
float distance(const vec2_t& to);
// calculates the magnitude (length) of the vector.
float length();
// all operators registered (with respective operation)
vec2_t opAdd(const vec2_t&in) const; // +
vec2_t opSub(const vec2_t&in) const; // -
vec2_t opMul(const vec2_t&in) const; // *
vec2_t opDiv(const vec2_t&in) const; // "/"
vec2_t opMul(float) const; // *
vec2_t opDiv(float) const; // "/"
vec2_t& opAddAssign(const vec2_t&in); // +=
vec2_t& opSubAssign(const vec2_t&in); // -=
vec2_t& opMulAssign(const vec2_t&in); // *=
vec2_t& opDivAssign(const vec2_t&in); // "/="
vec2_t& opMulAssign(float); // *=
vec2_t& opDivAssign(float); // "/="
}Constructors:
Examples:
Sample code to move the cursor to a specific screen position
Calculating the Distance Between Two Points on the Screen
Checking if a Point is Inside a Bounding Box
Last updated
Was this helpful?