mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Refactoring points
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
parent
8ca4cf3260
commit
b4cb314090
40 changed files with 746 additions and 783 deletions
|
@ -4,6 +4,7 @@ import type {
|
|||
LocalPoint,
|
||||
PolarCoords,
|
||||
Radians,
|
||||
ViewportPoint,
|
||||
} from "./types";
|
||||
import { PRECISION } from "./utils";
|
||||
|
||||
|
@ -23,10 +24,9 @@ export const normalizeRadians = (angle: Radians): Radians => {
|
|||
* (x, y) for the center point 0,0 where the first number returned is the radius,
|
||||
* the second is the angle in radians.
|
||||
*/
|
||||
export const cartesian2Polar = <P extends GlobalPoint | LocalPoint>([
|
||||
x,
|
||||
y,
|
||||
]: P): PolarCoords => [Math.hypot(x, y), Math.atan2(y, x)];
|
||||
export const cartesian2Polar = <
|
||||
P extends GlobalPoint | LocalPoint | ViewportPoint,
|
||||
>([x, y]: P): PolarCoords => [Math.hypot(x, y), Math.atan2(y, x)];
|
||||
|
||||
export function degreesToRadians(degrees: Degrees): Radians {
|
||||
return ((degrees * Math.PI) / 180) as Radians;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue