|
@@ -41,6 +41,7 @@ import {
|
|
|
import {
|
|
|
deconstructDiamondElement,
|
|
|
deconstructRectanguloidElement,
|
|
|
+ elementCenterPoint,
|
|
|
} from "./utils";
|
|
|
|
|
|
import type {
|
|
@@ -191,10 +192,7 @@ const intersectRectanguloidWithLineSegment = (
|
|
|
l: LineSegment<GlobalPoint>,
|
|
|
offset: number = 0,
|
|
|
): GlobalPoint[] => {
|
|
|
- const center = pointFrom<GlobalPoint>(
|
|
|
- element.x + element.width / 2,
|
|
|
- element.y + element.height / 2,
|
|
|
- );
|
|
|
+ const center = elementCenterPoint(element);
|
|
|
// To emulate a rotated rectangle we rotate the point in the inverse angle
|
|
|
// instead. It's all the same distance-wise.
|
|
|
const rotatedA = pointRotateRads<GlobalPoint>(
|
|
@@ -253,10 +251,7 @@ const intersectDiamondWithLineSegment = (
|
|
|
l: LineSegment<GlobalPoint>,
|
|
|
offset: number = 0,
|
|
|
): GlobalPoint[] => {
|
|
|
- const center = pointFrom<GlobalPoint>(
|
|
|
- element.x + element.width / 2,
|
|
|
- element.y + element.height / 2,
|
|
|
- );
|
|
|
+ const center = elementCenterPoint(element);
|
|
|
|
|
|
// Rotate the point to the inverse direction to simulate the rotated diamond
|
|
|
// points. It's all the same distance-wise.
|
|
@@ -304,10 +299,7 @@ const intersectEllipseWithLineSegment = (
|
|
|
l: LineSegment<GlobalPoint>,
|
|
|
offset: number = 0,
|
|
|
): GlobalPoint[] => {
|
|
|
- const center = pointFrom<GlobalPoint>(
|
|
|
- element.x + element.width / 2,
|
|
|
- element.y + element.height / 2,
|
|
|
- );
|
|
|
+ const center = elementCenterPoint(element);
|
|
|
|
|
|
const rotatedA = pointRotateRads(l[0], center, -element.angle as Radians);
|
|
|
const rotatedB = pointRotateRads(l[1], center, -element.angle as Radians);
|