Box2D 2.4.1
A 2D physics engine for games
Loading...
Searching...
No Matches
b2Vec2 Struct Reference

A 2D column vector. More...

#include <b2_math.h>

Public Member Functions

 b2Vec2 ()=default
 Default constructor does nothing (for performance).
 
 b2Vec2 (float xIn, float yIn)
 Construct using coordinates.
 
void SetZero ()
 Set this vector to all zeros.
 
void Set (float x_, float y_)
 Set this vector to some specified coordinates.
 
b2Vec2 operator- () const
 Negate this vector.
 
float operator() (int32 i) const
 Read from and indexed element.
 
float & operator() (int32 i)
 Write to an indexed element.
 
void operator+= (const b2Vec2 &v)
 Add a vector to this vector.
 
void operator-= (const b2Vec2 &v)
 Subtract a vector from this vector.
 
void operator*= (float a)
 Multiply this vector by a scalar.
 
float Length () const
 Get the length of this vector (the norm).
 
float LengthSquared () const
 
float Normalize ()
 Convert this vector into a unit vector. Returns the length.
 
bool IsValid () const
 Does this vector contain finite coordinates?
 
b2Vec2 Skew () const
 Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
 

Public Attributes

float x
 
float y
 

Detailed Description

A 2D column vector.

Member Function Documentation

◆ LengthSquared()

float b2Vec2::LengthSquared ( ) const
inline

Get the length squared. For performance, use this instead of b2Vec2::Length (if possible).


The documentation for this struct was generated from the following file: