Giter Club home page Giter Club logo

guozanhua / motion-toolkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dtecta/motion-toolkit

0.0 2.0 0.0 287 KB

The Motion Toolkit is a collection of C++ class templates providing basic types for applications involving 3D geometry, kinematics and dynamics of systems composed of rigid bodies. The toolkit contains class templates for 2D, 3D, and 4D vectors (quaternions, planes), dual numbers, dual vectors (Plücker coordinates), dual quaternions, 3x3 matrices, and 4x4 homogenous matrices. Vector operators are adopted from shader languages Cg/HLSL.

License: MIT License

CMake 0.53% C 1.31% C++ 98.15%

motion-toolkit's Introduction

		 MoTo - Motion Toolkit

MoTo is a software library written in C++ and contains class and
function templates that are useful for animation and simulation of
rigid bodies. MoTo evolved while being applied in SOLID, the software
library for interference detection, as well as numerous other project
involving graphics and physics.

A proper set of documentation is still pending, however I would like
to give a preview of MoTo's features and peculiarities.

First of all, since MoTo is composed of headers only, there is no need to build
and link a library. All class and function templates are fully inlined. 
 
Secondly, MoTo tries to mimic the Cg shader language as much as possible. This
shows in the naming of functions, e.g. "normalize" and "saturate", but also in
the use of operator*. In MoTo operator* is always component-wise. For
algebraic products such as a quaternion or matrix product, MoTo uses an
overloaded global "mul" function. So beware

mt::Matrix3x3<float> a, b, c;
...
c = a * b; // performs a component-wise multiply
c = mul(a, b); // performs a matrix product

Component-wise multiplies of matrix types (operator*) are disabled by default in 
order to avoid confusion with other matrix libraries where operator* is used as 
algabraic product. You can enable component-wise products by setting

#define USE_MATRIX_COMP_MULT 1

before including the MoTo header.
 

There is no dedicated quaternion class. In order to represent a quaternion,
simply use mt::Vector4. Again beware   

mt::Vector4<float> a, b, c;
...
c = a * b; // performs a component-wise multiply e.g. color modulate
c = mul(a, b); // performs a quaternion product
   
MoTo has a number of types that do not hold any values but are used to change
the behavior of constructors, operators and functions. These are

struct Zero; // The algebraic zero
struct Identity; // The identity for operator "mul"
template <int> struct Unit; // The i-th unit vector

See Algebra.hpp for a definition of these types.


Functions that involve a metric such as "distance" and "normalize" are found in
Metric.hpp. These function templates use a "dot" function and are generic for
all vector types.

Functions that involve angles such as "slerp" and "euler" are found in
Trigonometric.hpp. 


mt::Vector4 and mt::Matrix4x4 have specializations for "float" on an ia32 or
emt64 (amd64) platform. The specializations are implemented using SSE
intrinsics. See Vector4_SSE.hpp and Matrix4x4_SSE.hpp for details.


A dual number class is defined in Dual.hpp. Pluecker coordinates, spatial
vectors, and motor algebra requires DualVector3.hpp. Dual quaternions can be
created using DualVector4.hpp. See my GDC Europe 2009
presentation "Dual Numbers. Simple Math, Easy C++ Coding, and Lots of Tricks"
for details.

Sample code on how to make use of mt::Dual and other classes can be found in
UnitTest.cpp

 


Installation

MoTo itself can be readily used. For building consolid and the UnitTest.cpp
sample you need CMake 2.4 or up. Please, check the CMake documentation on how
to generate a MSVC project or makefiles for GCC.


Platforms

MoTo has been tested on the following platforms:

    Linux 32-bit/64-bit  gcc 3.4
	Win32 32-bit/64-bit	 MSVC 8.0 SP1, 9.0 SP1, 10, 11, 12

  

Good luck,


Gino van den Bergen
www.dtecta.com

motion-toolkit's People

Contributors

dtecta avatar

Watchers

guozanhua avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.