Table of Contents

Class Box2DConvert

Namespace
Gym.Box2D
Assembly
Gym.Environments.dll

The argument conversions of pybox2d's SWIG layer: a Python float passed where C++ takes a float32 rounds to the nearest float32, and values beyond its range are refused rather than becoming infinities.

public static class Box2DConvert
Inheritance
Box2DConvert
Inherited Members

Remarks

SWIG's SWIG_AsVal_float refuses x < -FLT_MAX || x > FLT_MAX (so the infinities) and lets NaN through, which then propagates as NaN.

Methods

FitsFloat32(double)

Whether a Python float converts to float32 without SWIG's overflow refusal (NaN does).

public static bool FitsFloat32(double value)

Parameters

value double

The value.

Returns

bool

False for values beyond ±FLT_MAX, the infinities included.

FormatG(double)

Formats a float as C's and Python's %g: 6 significant digits, trailing zeros dropped, exponent as e+XX.

public static string FormatG(double value)

Parameters

value double

The value.

Returns

string

The text.

ToFloat32(double, string, int)

Converts a Python float to float32 as SWIG does for a float32 parameter.

public static float ToFloat32(double value, string method, int argument)

Parameters

value double

The value.

method string

The SWIG wrapper name the error names (b2Vec2___mul__).

argument int

The 1-based argument position the error names.

Returns

float

The nearest float32.

Exceptions

OverflowError

Thrown, as Python's OverflowError, for a value beyond the float32 range, with SWIG's message in method '…', argument N of type 'float32'.