Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco User Util

From Leeroopedia
Revision as of 12:47, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Google_deepmind_Mujoco_User_Util.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Physics Simulation, Math Utilities
Last Updated 2026-02-15 04:00 GMT

Overview

Provides low-level mathematical and utility functions for vector operations, quaternion math, string parsing, and numeric validation used throughout the user module.

Description

user_util.cc contains foundational utility functions used across the MuJoCo user module. It implements vector operations (mjuu_setvec, mjuu_dot3, mjuu_dist3, mjuu_normvec, mjuu_scalevec), matrix address computation (mjuu_matadr), numeric validation (mjuu_defined using isnan), and provides overloaded versions for both double and float types. The file includes a macOS-specific workaround for locale-sensitive strtof/strtod functions to ensure consistent numeric parsing across platforms.

Usage

Used as a utility library by most files in the user and xml modules for basic mathematical operations and numeric conversions during model specification and compilation.

Code Reference

Source Location

Key Functions

bool mjuu_defined(double num);
int mjuu_matadr(int g1, int g2, int n);
void mjuu_setvec(double* dest, double x, double y, double z, double w);
void mjuu_setvec(float* dest, double x, double y, double z, double w);
void mjuu_setvec(double* dest, double x, double y, double z);
double mjuu_dot3(const double* a, const double* b);
double mjuu_dist3(const double* a, const double* b);
double mjuu_normvec(double* vec, int n);
void mjuu_scalevec(double* res, const double* vec, double s, int n);

Import

#include "user/user_util.h"

I/O Contract

Inputs

Name Type Required Description
dest double*/float* Yes Destination vector for set/copy operations
vec double*/float* Yes Input vector for normalization/scaling
n int Yes Vector dimension or matrix size
num double Yes (for mjuu_defined) Numeric value to check for NaN

Outputs

Name Type Description
bool bool Whether a numeric value is defined (not NaN)
double double Computed dot product, distance, or previous vector length
void void Vectors modified in-place

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment