Skip to content

Commit 412dbb3

Browse files
committed
fix: Correct trigonometric function usage in Matrix transformations
1 parent 55b23a6 commit 412dbb3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/core/math/Line.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ export class Line {
2424
return new Line(start.x, start.y, end.x, end.y);
2525
}
2626

27-
public contains(point: Vector): boolean {
27+
public contains(point: Vector, tolerance: number = 0.001): boolean {
2828
const distanceStart = point.distanceBetween(this.start);
2929
const distanceEnd = point.distanceBetween(this.end);
30-
3130
const length = this.getLength();
32-
const tolerance = 0.1;
33-
31+
3432
return distanceStart + distanceEnd >= length - tolerance && distanceStart + distanceEnd <= length + tolerance;
3533
}
3634

src/core/math/Matrix.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ export class Matrix {
110110
const radian = toRadians(angle);
111111

112112
const transformation = new Matrix([
113-
[1, Math.atan(radian), 0],
114-
[Math.atan(radian), 1, 0],
113+
[1, Math.tan(radian), 0],
114+
[Math.tan(radian), 1, 0],
115115
[0, 0, 1]
116116
]);
117117

@@ -123,7 +123,7 @@ export class Matrix {
123123
const radian = toRadians(angle);
124124

125125
const transformation = new Matrix([
126-
[1, Math.atan(radian), 0],
126+
[1, Math.tan(radian), 0],
127127
[0, 1, 0],
128128
[0, 0, 1]
129129
]);
@@ -137,7 +137,7 @@ export class Matrix {
137137

138138
const transformation = new Matrix([
139139
[1, 0, 0],
140-
[Math.atan(radian), 0, 0],
140+
[Math.tan(radian), 1, 0],
141141
[0, 0, 1]
142142
]);
143143

0 commit comments

Comments
 (0)