mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
chore: Unify math types, utils and functions (#8389)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
parent
e3d1dee9d0
commit
f4dd23fc31
98 changed files with 4291 additions and 3661 deletions
26
packages/math/ga/gadirections.ts
Normal file
26
packages/math/ga/gadirections.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import * as GA from "./ga";
|
||||
import type { Line, Direction, Point } from "./ga";
|
||||
|
||||
/**
|
||||
* A direction is stored as an array `[0, 0, 0, 0, y, x, 0, 0]` representing
|
||||
* vector `(x, y)`.
|
||||
*/
|
||||
|
||||
export const from = (point: Point): Point => [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
point[4],
|
||||
point[5],
|
||||
0,
|
||||
0,
|
||||
];
|
||||
|
||||
export const fromTo = (from: Point, to: Point): Direction =>
|
||||
GA.inormalized([0, 0, 0, 0, to[4] - from[4], to[5] - from[5], 0, 0]);
|
||||
|
||||
export const orthogonal = (direction: Direction): Direction =>
|
||||
GA.inormalized([0, 0, 0, 0, -direction[5], direction[4], 0, 0]);
|
||||
|
||||
export const orthogonalToLine = (line: Line): Direction => GA.mul(line, GA.I);
|
Loading…
Add table
Add a link
Reference in a new issue