Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 2x 194x 194x | import { Point } from "./interfaces";
/**
* Project a rectangle's corner on an axis.
*
* @param {object} Coordinates of a corner (x, y).
* @param {object} Coordinates of an axis (x, y).
* @return {object} The projection defined by coordinates (x, y).
*/
export default function projection(c: Point, a: Point): Point {
const l = (c.x * a.x + c.y * a.y) / (a.x ** 2 + a.y ** 2);
return {
x: l * a.x,
y: l * a.y
};
}
|