Skip to content

AcresCoreMath.h#

Core/Source/AcresCoreMath.h Generated

Vector, quaternion and 3 x 3 matrix helpers for ACRES Core (header-only, double precision).

The Core works in a right-handed frame: world ENU metres about the ACRE tile centre (x east, y north, z up, the enu_m of places.json) and body FLU (x forward, y left, z up). The game works in Unreal's left-handed world (X east, Y south, Z up, centimetres) with a body X forward, Y right; the two are mirror images across the east-up plane, so the same physics holds with y negated (AcresCore::FromUnreal, ToUnreal).

QuatFromAxes#

Quaternion of the rotation whose body axes (x forward, y left, z up) are the given orthonormal world vectors.

inline FQuat QuatFromAxes(const FVec3& Fx, const FVec3& Fy, const FVec3& Fz) ;

WrapPi#

Wraps an angle to (-pi, pi].

inline double WrapPi(double A) ;

FVec3#

struct FVec3

A 3-vector.

FVec3::Dot#

Dot product.

double Dot(const FVec3& B) const ;

FVec3::Cross#

Cross product (right-handed).

FVec3 Cross(const FVec3& B) const ;

FVec3::Normalized#

Unit vector (zero stays zero).

FVec3 Normalized() const ;

FQuat#

struct FQuat

A rotation quaternion, W + X i + Y j + Z k (unit length).

FQuat::operator*#

Hamilton product (apply B first, then this).

FQuat operator*(const FQuat& B) const ;

FQuat::Rotate#

Rotates a vector from the body frame to the world frame.

FVec3 Rotate(const FVec3& V) const ;

FQuat::Unrotate#

Rotates a vector from the world frame to the body frame.

FVec3 Unrotate(const FVec3& V) const ;

FQuat::Forward#

Body axes in the world frame.

FVec3 Forward() const ;

FQuat::FromAxisAngle#

Rotation by Angle (rad) about a unit Axis.

static FQuat FromAxisAngle(const FVec3& Axis, double Angle) ;

FQuat::FromYawPitchRoll#

ZYX Euler angles (yaw about z, then pitch about the new y, then roll about the new x), rad, as ROS's tf2 setRPY. Positive pitch here is nose-down (right-handed about y-left); the Core reports PitchUpRad for the nose-up convention of the vehicle model.

static FQuat FromYawPitchRoll(double Yaw, double Pitch, double Roll) ;

FQuat::ToYawPitchRoll#

ZYX Euler angles of this rotation, rad (inverse of FromYawPitchRoll).

void ToYawPitchRoll(double& Yaw, double& Pitch, double& Roll) const ;

FMat3#

struct FMat3

A 3 x 3 matrix, row-major.

FMat3::FromQuat#

Rotation matrix of a unit quaternion (columns are the body axes in the world).

static FMat3 FromQuat(const FQuat& Q) ;