Convert Figma logo to code with AI

MADEAPPS logonewton-dynamics

Newton Dynamics is an integrated solution for real time simulation of physics environments.

1,020
194
1,020
37

Top Related Projects

13,923

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

9,441

Box2D is a 2D physics engine for games

3,489

NVIDIA PhysX SDK

The Physics engine that accompanies the book "Game Physics Engine Design"

Quick Overview

Newton Dynamics is an open-source, cross-platform, real-time physics engine. It provides a deterministic solver, which is not based on traditional LCP or iterative methods, but on a proprietary algorithm. The engine is designed to be fast, stable, and robust for use in games and real-time simulations.

Pros

  • High performance and stability due to its deterministic solver
  • Cross-platform support (Windows, Linux, macOS)
  • Extensive feature set including rigid body dynamics, collision detection, and vehicle dynamics
  • Active development and community support

Cons

  • Steeper learning curve compared to some other physics engines
  • Documentation could be more comprehensive
  • Smaller community compared to some more widely-used physics engines

Code Examples

  1. Creating a rigid body:
NewtonWorld* world = NewtonCreate();
NewtonCollision* collision = NewtonCreateSphere(world, 1.0f, 0, NULL);
dMatrix matrix(dGetIdentityMatrix());
NewtonBody* body = NewtonCreateDynamicBody(world, collision, &matrix[0][0]);
NewtonDestroyCollision(collision);
  1. Applying force to a body:
void ApplyForce(const NewtonBody* body, dFloat timestep, int threadIndex)
{
    dVector force(0.0f, -9.8f, 0.0f);
    NewtonBodySetForce(body, &force[0]);
}

NewtonBodySetForceAndTorqueCallback(body, ApplyForce);
  1. Setting up a vehicle:
NewtonVehicle* vehicle = NewtonVehicleCreate(world);
NewtonVehicleAddTire(vehicle, tireRadius, tireWidth, suspensionLength, mass, &localPosition[0], &pin[0], vehicleTireMaterial);
NewtonVehicleSetTireSteerAngle(vehicle, tireIndex, steerAngle);
NewtonVehicleSetTireTorque(vehicle, tireIndex, torque);

Getting Started

  1. Download the Newton Dynamics library from the GitHub repository.
  2. Include the necessary headers in your project:
#include <Newton.h>
  1. Create a Newton world:
NewtonWorld* world = NewtonCreate();
  1. Set up your simulation loop:
while (running) {
    // Update your game logic here
    NewtonUpdate(world, timestep);
}
  1. Clean up when done:
NewtonDestroy(world);

Competitor Comparisons

13,923

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Pros of Bullet3

  • More widely adopted and used in various industries, including game development and robotics
  • Extensive documentation and community support
  • Supports a broader range of platforms and programming languages

Cons of Bullet3

  • Can be more complex to set up and use for beginners
  • Performance may be slower in certain scenarios compared to Newton Dynamics
  • Larger codebase, which can make it harder to understand and modify

Code Comparison

Newton Dynamics:

NewtonWorld* world = NewtonCreate();
NewtonBody* body = NewtonCreateDynamicBody(world, collision, &matrix[0][0]);
NewtonBodySetMassMatrix(body, mass, Ixx, Iyy, Izz);

Bullet3:

btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState, shape, localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
world->addRigidBody(body);

Both libraries offer similar functionality for creating physics simulations, but Bullet3 has a more object-oriented approach, while Newton Dynamics uses a more procedural style. Bullet3's wider adoption and extensive documentation make it a popular choice, but Newton Dynamics may offer better performance in specific use cases.

9,441

Box2D is a 2D physics engine for games

Pros of Box2D

  • Lightweight and efficient, ideal for 2D physics simulations
  • Extensive documentation and community support
  • Widely used in game development, particularly for mobile and web games

Cons of Box2D

  • Limited to 2D physics, lacking 3D capabilities
  • Less suitable for complex, high-precision simulations
  • Smaller feature set compared to more comprehensive physics engines

Code Comparison

Box2D (C++):

b2Vec2 gravity(0.0f, -10.0f);
b2World world(gravity);

b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(0.0f, 4.0f);
b2Body* body = world.CreateBody(&bodyDef);

Newton Dynamics (C++):

NewtonWorld* world = NewtonCreate();
NewtonSetWorldSize(world, &minSize[0], &maxSize[0]);

dMatrix matrix(dGetIdentityMatrix());
matrix.m_posit = dVector(0.0f, 4.0f, 0.0f, 1.0f);
NewtonBody* body = NewtonCreateDynamicBody(world, NULL, &matrix[0][0]);

Summary

Box2D is a popular choice for 2D physics simulations, especially in game development, due to its efficiency and ease of use. Newton Dynamics offers more comprehensive 3D physics capabilities and advanced features, making it suitable for more complex simulations. The choice between the two depends on the specific requirements of the project, such as dimensionality, performance needs, and desired level of physics complexity.

3,489

NVIDIA PhysX SDK

Pros of PhysX

  • Widely adopted in the game industry with extensive documentation and support
  • Optimized for NVIDIA GPUs, offering hardware acceleration for improved performance
  • Comprehensive feature set including cloth, particles, and fluid simulation

Cons of PhysX

  • Closed-source nature limits customization and community contributions
  • Potential vendor lock-in due to NVIDIA-specific optimizations
  • May require licensing for commercial use in some cases

Code Comparison

PhysX:

PxRigidDynamic* dynamicActor = physics.createRigidDynamic(PxTransform(0, 10, 0));
PxRigidStatic* staticActor = physics.createRigidStatic(PxTransform(0, 0, 0));
PxShape* shape = physics.createShape(PxSphereGeometry(1), *material);
dynamicActor->attachShape(*shape);

Newton Dynamics:

NewtonBody* dynamicBody = NewtonCreateDynamicBody(world, collision, &matrix[0][0]);
NewtonBody* staticBody = NewtonCreateKinematicBody(world, collision, &matrix[0][0]);
NewtonCollisionSetUserData(collision, userData);
NewtonBodySetMassProperties(dynamicBody, mass, collision);

Both libraries provide similar functionality for creating rigid bodies and shapes, but with different syntax and object-oriented approaches. PhysX uses a more modern C++ style, while Newton Dynamics has a C-style API.

The Physics engine that accompanies the book "Game Physics Engine Design"

Pros of Cyclone Physics

  • Lightweight and easy to understand, making it suitable for educational purposes
  • Written in C++, offering good performance and compatibility
  • Includes a comprehensive book explaining the physics concepts and implementation

Cons of Cyclone Physics

  • Less feature-rich compared to Newton Dynamics
  • Not actively maintained, with the last update several years ago
  • Limited documentation and community support

Code Comparison

Newton Dynamics:

NewtonWorld* world = NewtonCreate();
NewtonBody* body = NewtonCreateDynamicBody(world, collision, &matrix[0][0]);
NewtonBodySetMassMatrix(body, mass, Ixx, Iyy, Izz);
NewtonBodySetForceAndTorqueCallback(body, ApplyForceAndTorque);

Cyclone Physics:

cyclone::World world;
cyclone::RigidBody* body = new cyclone::RigidBody();
body->setMass(mass);
body->setInertiaTensor(inertiaTensor);
world.getBodies().push_back(body);

Both libraries provide similar functionality for creating and managing physics worlds and bodies. Newton Dynamics offers a more extensive API with additional features, while Cyclone Physics has a simpler, more straightforward approach. Newton Dynamics is actively maintained and has better documentation, making it more suitable for production use. Cyclone Physics, however, is an excellent choice for learning and understanding physics engine concepts.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

This repository, along with the old forum at http://newtondynamics.com , has been discontinued.

For questions, ideas, or general discussion, please use the new forum at: https://github.com/JulioJerez/newton-dynamics/discussions

The new official repository is available at: https://github.com/JulioJerez/newton-dynamics