Update snapshot and comment

This commit is contained in:
Mark Tolmacs 2024-09-25 14:35:21 +02:00
parent 3fe73e79a6
commit 9a8aabbeca
No known key found for this signature in database
2 changed files with 15 additions and 7 deletions

View file

@ -82,13 +82,21 @@ export const ellipseTouchesPoint = <Point extends GenericPoint>(
ellipse: Ellipse<Point>,
threshold = PRECISION,
) => {
return ellipseDistance(point, ellipse) <= threshold;
return ellipseDistanceFromPoint(point, ellipse) <= threshold;
};
export const ellipseDistance = <Point extends GenericPoint>(
/**
* Determine the shortest euclidean distance from a point to the
* outline of the ellipse
*
* @param p The point to consider
* @param ellipse The ellipse to calculate the distance to
* @returns The eucledian distance
*/
export const ellipseDistanceFromPoint = <Point extends GenericPoint>(
p: Point,
ellipse: Ellipse<Point>,
) => {
): number => {
const { angle, halfWidth, halfHeight, center } = ellipse;
const a = halfWidth;
const b = halfHeight;