MCPcopy
hub / github.com/slowlydev/f1-dash / rotate

Function rotate

dashboard/src/lib/map.ts:8–19  ·  view source on GitHub ↗
(x: number, y: number, a: number, px: number, py: number)

Source from the content-addressed store, hash-verified

6export const rad = (deg: number) => deg * (Math.PI / 180);
7
8export const rotate = (x: number, y: number, a: number, px: number, py: number) => {
9 const c = Math.cos(rad(a));
10 const s = Math.sin(rad(a));
11
12 x -= px;
13 y -= py;
14
15 const newX = x * c - y * s;
16 const newY = y * c + x * s;
17
18 return { y: newX + px, x: newY + py };
19};
20
21export const calculateDistance = (x1: number, y1: number, x2: number, y2: number) => {
22 return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));

Callers 2

MapFunction · 0.90
CarDotFunction · 0.90

Calls 1

radFunction · 0.85

Tested by

no test coverage detected