top of page
Search

sopiro(js) nsquared

  • cedarcantab
  • Apr 12, 2024
  • 1 min read


import { createAABB, detectCollisionAABB } from "./aabb.js";

//N^2 broad phase, actually (N^2 - N) / 2

export function getCollisionPairsNSquared(bodies) {

let pairs = [];

for (let i = 0; i < bodies.length; i++) {

let a = bodies[i];

for (let j = i + 1; j < bodies.length; j++) {

let b = bodies[j];

if (detectCollisionAABB(createAABB(a), createAABB(b))) {

pairs.push({ p1: a, p2: b });

}

}

}

return pairs;

}

 
 
 

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";...

 
 
 

Comments


記事: Blog2_Post

Subscribe Form

Thanks for submitting!

  • Facebook
  • Twitter
  • LinkedIn

©2021 by Cozy Cozy World。Wix.com で作成されました。

bottom of page