28 Vector2(
const float x = 0,
const float y = 0);
49 void Set(
const float x,
const float y) {
X = x;
Y = y; }
63 bool IsZero()
const {
return (
X == 0 &&
Y == 0); }
Defines a point in 2D space.
Defines a vector with 2 components (x and y).
float Y
The y-coordinate of the vector.
const Vector2 operator*(const float scalar) const
Multiplies a vector by a scalar.
static const Vector2 UNIT_X
A unit vector on the x-axis.
const Point ToPoint() const
Converts the vector into a point.
float DotProduct(const Vector2 &vector) const
Calculates the dot product of two vectors.
Vector2 & operator/=(const float scalar)
Divides by a scalar.
void Set(const Vector2 vector)
Sets the components of the vector.
static float Distance(const Vector2 &vector1, const Vector2 &vector2)
Calculates the distance between two vectors.
float CrossProduct(const Vector2 &vector) const
Calculates the cross product between two vectors.
const Vector2 operator-() const
Negates the vector.
void Normalize()
Resize a vector to a length of one unit. If the starting vector is the zero vector,...
static const Vector2 UNIT_Y
A unit vector on the y-axis.
static Vector2 GetRandom(bool normalize=false)
Creates a random vector.
const Vector2 operator+(const Vector2 &vector) const
Adds two vectors.
Vector2 Right()
Calculates the right-hand orthogonal vector.
float LengthSquared() const
Calculates the length of the vector squared.
static const Vector2 ZERO
A vector with both of its components set to zero.
Vector2 & operator+=(const Vector2 &vector)
Adds a vector.
bool IsZero() const
Determines if the vector is the zero vector.
const Vector2 operator/(const float scalar) const
Divides a vector by a scalar.
static Vector2 Lerp(const Vector2 &start, const Vector2 &end, const float value)
Linearly interpolate between two vectors.
Vector2(const float x=0, const float y=0)
Instantiates a new Vector2 object.
static float DistanceSquared(const Vector2 &vector1, const Vector2 &vector2)
Calculates the distance squared between two vectors.
Vector2 Left()
Calculates the left-hand orthogonal vector.
void Display() const
Prints the vector to the console.
Vector2 & operator*=(const float scalar)
Multiplies by a scalar.
bool operator==(const Vector2 &vector) const
Determines if two vectors are equal.
void Set(const float x, const float y)
Sets the components of the vector.
Vector2 & operator-=(const Vector2 &vector)
Subtracts a vector.
std::string ToString() const
Gets a string representation of the vector.
float Length() const
Calculates the length of the vector.
bool operator!=(const Vector2 &vector) const
Determines if two vectors are not equal.
static const Vector2 ONE
A vector with both of its components set to one.
Vector2 & operator=(const Vector2 &vector)
Assigns the reference of a vector.
float X
The x-coordinate of the vector.
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...