SC2API
An API for AI for StarCraft II
Classes | Typedefs | Functions
sc2_common.h File Reference

Common data types, including points, rectangles and colors. More...

#include <algorithm>
#include <cmath>
#include <cstdint>

Go to the source code of this file.

Classes

struct  sc2::Point3D
 
struct  sc2::Point2D
 
struct  sc2::Rect2D
 2D rectangle. More...
 
struct  sc2::Point2DI
 2D integer point. More...
 
struct  sc2::Rect2DI
 2D integer rectangle. More...
 
struct  sc2::Color
 RGB Color. More...
 

Typedefs

typedef Point2D sc2::Vector2D
 
typedef Point3D sc2::Vector3D
 

Functions

Point3D sc2::operator+ (const Point3D &lhs, const Point3D &rhs)
 
Point3D sc2::operator- (const Point3D &lhs, const Point3D &rhs)
 
Point3D sc2::operator* (const Point3D &lhs, float rhs)
 
Point3D sc2::operator* (float lhs, const Point3D &rhs)
 
Point3D sc2::operator/ (const Point3D &lhs, float rhs)
 
Point3D sc2::operator/ (float lhs, const Point3D &rhs)
 
Point2D sc2::operator+ (const Point2D &lhs, const Point2D &rhs)
 
Point2D sc2::operator- (const Point2D &lhs, const Point2D &rhs)
 
Point2D sc2::operator* (const Point2D &lhs, float rhs)
 
Point2D sc2::operator* (float lhs, const Point2D &rhs)
 
Point2D sc2::operator/ (const Point2D &lhs, float rhs)
 
Point2D sc2::operator/ (float lhs, const Point2D &rhs)
 
float sc2::GetRandomScalar ()
 
float sc2::GetRandomFraction ()
 
int sc2::GetRandomInteger (int min, int max)
 
template<typename Container >
Container::value_type & sc2::GetRandomEntry (Container &container)
 
float sc2::Distance2D (const Point2D &a, const Point2D &b)
 
float sc2::DistanceSquared2D (const Point2D &a, const Point2D &b)
 
void sc2::Normalize2D (Point2D &a)
 
float sc2::Dot2D (const Point2D &a, const Point2D &b)
 
float sc2::Distance3D (const Point3D &a, const Point3D &b)
 
float sc2::DistanceSquared3D (const Point3D &a, const Point3D &b)
 
void sc2::Normalize3D (Point3D &a)
 
float sc2::Dot3D (const Point3D &a, const Point3D &b)
 

Detailed Description

Common data types, including points, rectangles and colors.

Function Documentation

float sc2::Distance2D ( const Point2D a,
const Point2D b 
)

The distance between two 2D points.

Parameters
aFirst point.
bSecond point.
Returns
Distance.
float sc2::Distance3D ( const Point3D a,
const Point3D b 
)

The distance between two 3D points.

Parameters
aFirst point.
bSecond point.
Returns
Distance.
float sc2::DistanceSquared2D ( const Point2D a,
const Point2D b 
)

The distance squared between two 2D points, faster than Distance2D.

Parameters
aFirst point.
bSecond point.
Returns
Distance^2.
float sc2::DistanceSquared3D ( const Point3D a,
const Point3D b 
)

The distance squared between two 3D points, faster than Distance3D.

Parameters
aFirst point.
bSecond point.
Returns
Distance^2.
float sc2::Dot2D ( const Point2D a,
const Point2D b 
)

The dot product of two 2D vectors.

Parameters
aFirst vector.
bSecond vector.
Returns
Dot product.
float sc2::Dot3D ( const Point3D a,
const Point3D b 
)

The dot product of two 3D vectors.

Parameters
aFirst vector.
bSecond vector.
Returns
Dot product.
template<typename Container >
Container::value_type& sc2::GetRandomEntry ( Container &  container)

Gets a random entry from the container.

Parameters
containerArray, list or whatever container.
Returns
A random entry.
float sc2::GetRandomFraction ( )

Gets a random floating-point number between 0.0 and 1.0.

Returns
Random floating-point number between 0.0 and 1.0.
int sc2::GetRandomInteger ( int  min,
int  max 
)

Gets a random integer between min and max inclusive.

Parameters
minSmallest value a random number could be.
maxLargest value a random number could be.
Returns
Random integer between min and max.
float sc2::GetRandomScalar ( )

Gets a random floating-point number between -1.0 and 1.0.

Returns
Random floating-point number between -1.0 and 1.0.
void sc2::Normalize2D ( Point2D a)

Normalize a 2D point.

Parameters
aPoint.
void sc2::Normalize3D ( Point3D a)

Normalize a 3D point.

Parameters
aPoint.