pocket-physics
Version:
Verlet physics extracted from pocket-ces demos
20 lines (19 loc) • 692 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.projectCposWithRadius = void 0;
const v2_1 = require("./v2");
// preallocations
const v = (0, v2_1.v2)();
const direction = (0, v2_1.v2)();
const radiusSegment = (0, v2_1.v2)();
/**
* Compute the leading edge of a circular moving object given a radius: cpos + radius in the direction of velocity.
*/
const projectCposWithRadius = (out, p, radius) => {
(0, v2_1.sub)(v, p.cpos, p.ppos);
(0, v2_1.normalize)(direction, v);
(0, v2_1.scale)(radiusSegment, direction, radius);
(0, v2_1.add)(out, radiusSegment, p.cpos);
return out;
};
exports.projectCposWithRadius = projectCposWithRadius;