www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit 72e7a74eb1c672ef8b0248fee6714b1517a30b37
parent 80158979948635c9e03404a45ac8c6d186f0a5fd
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Mon, 14 Oct 2024 22:59:58 -0700

Fix point removal behavior added in e87407

The angle calculation was off. Still a bit strange but it's working.

Diffstat:
Mfiles/floorplans/floorplan/editor.js | 5++---
Mfiles/floorplans/floorplan/geometry.js | 4++++
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/files/floorplans/floorplan/editor.js b/files/floorplans/floorplan/editor.js @@ -545,7 +545,7 @@ export class FloorplanEditor { const pointsAngle = function(a, b) { a = editor.backend.reqObj(a) b = editor.backend.reqObj(b) - return new Vector2(a.x, a.y).angleTo(new Vector2(b.x, b.y)) + return geometry.lineAngle(new Vector2(a.x, a.y), new Vector2(b.x, b.y)) } for (let i in later) { @@ -560,8 +560,7 @@ export class FloorplanEditor { } let a2 = pointsAngle(p, o2) - console.warn(a1,a2,a1-a2, geometry.deg(Math.abs(a1-a2))) - if (geometry.deg(Math.abs(a1 - a2)) < 1) { + if ((geometry.deg(Math.abs(a1 - a2)) % 180) < 1) { editor.backend.mapPoints({ a: o, b: o2 }) } } diff --git a/files/floorplans/floorplan/geometry.js b/files/floorplans/floorplan/geometry.js @@ -198,3 +198,7 @@ export function length(a, b, length) { */ return b.sub(a).normalize().multiplyScalar(length).add(a) } + +export function lineAngle(p1, p2) { + return Math.atan2(p2.y - p1.y, p2.x - p1.x) +}