Docs

Math Types

Docs Index

Purpose

Perro scripting uses Vector2, Vector3, Quaternion, Color, Transform2D, and Transform3D for common gameplay and scene math.

Math Types explains behavior, constraints, and practical usage so implementation decisions stay consistent across scripts and scenes.

API Source

Functions

Vector2::newVector3::newQuaternion::looking_atColor::from_hex

Enums

// not documented yet for this module

Constants

Vector2::ZEROColor::WHITE

Types

Vector2Vector3QuaternionColorTransform2DTransform3D

Usage Pattern

let dir = from.direction_to(target);let q = Quaternion::looking_at(    Vector3::new(0.0, 0.0, -1.0),    Vector3::new(0.0, 1.0, 0.0),);let accent = Color::from_hex("#3A86FF").unwrap_or(Color::WHITE);

Key Details

Vector2 and Vector3 support distance, direction, angle, dot, cross, length, normalization, and lerp helpers.

Quaternion supports stable 3D rotation, look-at, vector rotation, inverse, normalize, and slerp.

Color supports RGBA creation, hex parsing, conversion, and preset constants.

Transforms are the common 2D/3D position, rotation, and scale containers.