explaingit

zalo/mathutilities

4,726C#Audience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A grab-bag of math and physics algorithms for Unity in C#, covering mesh deformation, inverse kinematics, soft-body physics, Kalman filtering, and spatial hashing, free to use however you like.

Mindmap

mindmap
  root((mathutilities))
    What it does
      Mesh deformation
      Physics simulation
      Spatial lookups
    Algorithms
      Inverse kinematics
      Kalman filter
      Kabsch alignment
    Use Cases
      Game physics
      Sensor smoothing
      Shape rendering
    Tech Stack
      C#
      Unity
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add soft-body, cloth, or chain physics to a Unity game using the Verlet integration system.

USE CASE 2

Animate a character arm or robotic limb reaching a target using the CCDIK or FABRIK inverse kinematics solver.

USE CASE 3

Speed up nearest-neighbor lookups in a 3D Unity scene with the spatial hashing system.

USE CASE 4

Smooth noisy sensor or controller input data using the included Kalman filter.

Tech stack

C#Unity

Getting it running

Difficulty · easy Time to first run · 30min

Requires Unity game engine, copy the relevant subfolder directly into your Unity project Assets folder.

Free to use for any purpose with no restrictions stated by the author.

In plain English

MathUtilities is a collection of math and physics algorithms implemented in C# for the Unity game engine. The author describes it as a grab bag of techniques gathered over several years, and the code is free to use however you like. The collection covers a wide range of problems that come up in game development and simulations. One tool handles mesh deformation, bending and warping 3D shapes in real time based on control points you place, with adjustable rigidity. Another implements signed distance fields, a technique for representing and rendering solid 3D shapes by storing how far each point in space is from the nearest surface. There is an implementation of the Kabsch algorithm, which finds the best rotation and position to align two sets of points with each other, and a least-squares fitter for finding the line or plane that best fits a cloud of points in 3D space. The physics-related tools include a Verlet integration system for simulating soft bodies, rigid bodies, cloth, and chains of linked particles. A Kalman filter implementation is included for smoothing noisy sensor data by combining signals from multiple sources into a cleaner result. The collection also has inverse kinematics solvers, which are algorithms for figuring out how a chain of jointed limbs (like a robotic arm) should position itself to reach a target point. Two different IK approaches are included: CCDIK and FABRIK, with illustrated examples for each. Other items in the collection include a general-purpose numerical optimizer, a linear assignment solver for pairing items between two lists at minimum cost, and a spatial hashing system for fast proximity lookups in 3D space. A fisheye camera prefab stitches together four camera views into a single 180-degree image. All examples run in Unity and each item in the collection links to its own subfolder with source code and animated demonstrations.

Copy-paste prompts

Prompt 1
I'm using the zalo/mathutilities FABRIK inverse kinematics solver in Unity. Write a C# MonoBehaviour that chains 5 bones and makes the tip follow my mouse cursor in 3D space.
Prompt 2
Show me how to use the Verlet integration cloth simulation from zalo/mathutilities to create a flag that waves in the wind in a Unity scene.
Prompt 3
I want to use the spatial hashing system from zalo/mathutilities to find all game objects within 5 units of the player. Write the Unity C# code.
Prompt 4
Use the Kalman filter from zalo/mathutilities to smooth noisy position data from an input device in a Unity C# MonoBehaviour.
Prompt 5
How do I use the Kabsch algorithm from zalo/mathutilities to align two sets of 3D points, for example matching a scanned mesh to a reference mesh in Unity?
Open on GitHub → Explain another repo

← zalo on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.