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
20
packages/math/arc.ts
Normal file
20
packages/math/arc.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { cartesian2Polar } from "./angle";
|
||||
import type { GlobalPoint, LocalPoint, SymmetricArc } from "./types";
|
||||
import { PRECISION } from "./utils";
|
||||
|
||||
/**
|
||||
* Determines if a cartesian point lies on a symmetric arc, i.e. an arc which
|
||||
* is part of a circle contour centered on 0, 0.
|
||||
*/
|
||||
export const isPointOnSymmetricArc = <P extends GlobalPoint | LocalPoint>(
|
||||
{ radius: arcRadius, startAngle, endAngle }: SymmetricArc,
|
||||
point: P,
|
||||
): boolean => {
|
||||
const [radius, angle] = cartesian2Polar(point);
|
||||
|
||||
return startAngle < endAngle
|
||||
? Math.abs(radius - arcRadius) < PRECISION &&
|
||||
startAngle <= angle &&
|
||||
endAngle >= angle
|
||||
: startAngle <= angle || endAngle >= angle;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue