vec3_t represents a three-dimensional vector commonly used in 3D space calculations, such as positions, directions, and velocities.
Declaration:
classvec3_t{float x;float y;float z; // calculates the Euclidean distance between this vector and another.floatdistance(constvec3_t&in to); // calculates the dot product between this vector and another.floatdot(constvec3_t&in to); // calculates the magnitude (length) of the vector.floatlength(); // calculates the magnitude of the vector in 2D space (ignoring the z-component).floatlength_2d(); // alias for length().floatmagnitude(); // calculates the cross product between this vector and another.vec3_tcross(constvec3_t&in to); // all operators registered (with their respective operation)boolopEquals(constvec3_t& in) const; // ==boolopNotEquals(constvec3_t&in) const; // !=vec3_topAdd(constvec3_t&in) const; // +vec3_topSub(constvec3_t&in) const; // -vec3_topMul(float) const; // *vec3_t&opDiv(float); // /vec3_t&opAddAssign(constvec3_t&in); // +=vec3_t&opSubAssign(constvec3_t&in); // -=vec3_t&opMulAssign(float); // *=vec3_t&opDivAssign(float); // /=}
Constructors:
vec3_t(float x,float y,float z) // standard constructorvec3_t{float x,float y,float z} // initializer list style
Examples:
Sample code to get the distance to an enemy target
auto player_position =vec3_t( 200.f,200.f,10.f ); // Player's positionauto enemy_position =vec3_t( 250.f,210.f,10.f ); // Enemy's position// distance_to_enemy will be ~50.99 metersauto distance_to_enemy =player_position.distance(enemy_position);
Sample code to calculate player's movement speed
auto previous_position =vec3_t( 100.f,100.f,0.f ); // Player's position at previous frameauto current_position =vec3_t( 110.f,120.f,0.f ); // Player's position at current frameauto movement_vector = current_position - previous_position;auto speed =movement_vector.length(); // speed will be ~22.36 meters per frame
Sample code to convert a 3D world position to a 2D screen position for ESP
auto enemy_world_position =vec3_t( 250.f,210.f,15.f ); // Enemy's world position// enemy_screen_position can be used to draw ESP boxes on the screenauto enemy_screen_position = render::to_screen(enemy_world_position);