top of page
Search
cedarcantab

sopiro(js) edge



import { Vector2 } from "./math.js";

import * as Util from "./util.js";

export class Edge {

constructor(p1, p2) {

constructor(p1, p2, id1 = -1, id2 = -1) {

this.p1 = p1.copy();

this.p2 = p2.copy();

if (this.p1.equals(this.p2))

this.dir = new Vector2(0, 0);

else

this.dir = p2.sub(p1).normalized();

this.id1 = id1;

this.id2 = id2;

}

get length() {

return this.p2.sub(this.p1).length;

}

get normal() {

return Util.cross(1, this.dir);

}

}

2 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