top of page
Search
cedarcantab

pointmass-jc



cpp


#include "PointMass.h"
#include <stdio.h>

namespace  JellyPhysics 
{

	PointMass::PointMass( float mass, const Vector2& pos )
	{
		Mass = mass;
		Position = pos;
		Velocity = Force = Vector2::Zero;
		lastElapsed = 0;
		lastElapMass = 1;
	}
	
	void PointMass::integrateForce( float elapsed )
	{
		if (Mass != 0.0f)
		{
			if (lastElapsed != elapsed)
			{
				lastElapsed = elapsed;
				lastElapMass = elapsed / Mass;
			}
			
			Velocity += (Force * lastElapMass);
			
			Position += (Velocity * elapsed);
		}
		
		Force = Vector2::Zero;
	}
	
}

3 views0 comments

Recent Posts

See All

p2 naive broadphase

var Broadphase = require('../collision/Broadphase'); module.exports = NaiveBroadphase; /** * Naive broadphase implementation. Does N^2...

sopiro motor constranit

import { Matrix2, Vector2 } from "./math.js"; import { RigidBody } from "./rigidbody.js"; import { Settings } from "./settings.js";...

Commenti


記事: Blog2_Post
bottom of page