Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move getLines to polygon.tsx #1398

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brave-rats-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Internal: move the getLines function to polygon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {PolygonAngle} from "./components/angle-indicators";
import {StyledMovablePoint} from "./components/movable-point";
import {TextLabel} from "./components/text-label";
import {useDraggable} from "./use-draggable";
import {getLines} from "./utils";

import type {MafsGraphProps, PolygonGraphState} from "../types";
import type {CollinearTuple} from "@khanacademy/perseus";

type Props = MafsGraphProps<PolygonGraphState>;

Expand Down Expand Up @@ -124,3 +124,10 @@ export const PolygonGraph = (props: Props) => {
</>
);
};

function getLines(points: readonly vec.Vector2[]): CollinearTuple[] {
return points.map((point, i) => {
const next = points[(i + 1) % points.length];
return [point, next];
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {CollinearTuple} from "../../../perseus-types";
import type {Interval, vec} from "mafs";

/**
Expand Down Expand Up @@ -42,13 +41,6 @@ export const getIntersectionOfRayWithBox = (
}
};

export const getLines = (points: readonly vec.Vector2[]): CollinearTuple[] => {
return points.map((point, i) => {
const next = points[(i + 1) % points.length];
return [point, next];
});
};

function isBetween(x: number, low: number, high: number) {
return x >= low && x <= high;
}