top of page
Search
cedarcantab

Studying Box2D-Lite in Javascript, Part 7.2: Test and Compute Distance to Point - Circle

Updated: Mar 1



TestPoint = function(transform, p) {

var center = box2d.b2Mul_X_V2(transform, this.m_p, box2d.b2CircleShape.prototype.TestPoint.s_center);

var d = box2d.b2Sub_V2_V2(p, center, box2d.b2CircleShape.prototype.TestPoint.s_d);

return box2d.b2Dot_V2_V2(d, d) <= box2d.b2Sq(this.m_radius);

}



ComputeDistance = function(xf, p, normal, childIndex) {

var center = box2d.b2Mul_X_V2(xf, this.m_p, box2d.b2CircleShape.prototype.ComputeDistance.s_center);

var d = box2d.b2Sub_V2_V2(p, center, normal);

return normal.Normalize() - this.m_radius;

}

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

Comments


記事: Blog2_Post
bottom of page