commit b0eba3e5d134aca7f2d2ef5ce8ea1f09cf3c30d5
parent f5c8ef2fa264a9baf4c4c17fd2ad06898f2f6003
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Sat, 12 Oct 2024 19:54:02 -0700
Add rad function to geometry library
This just converts degrees to radians. I did have it defined in the
door swing code but will need it elsewhere now.
Diffstat:
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/files/floorplans/floorplan/editor.js b/files/floorplans/floorplan/editor.js
@@ -1,6 +1,7 @@
import { default as SVG } from "/lib/github.com/svgdotjs/svg.js/svg.js"
import * as backend from "./backend.js"
import { Vector2 } from "/lib/github.com/mrdoob/three.js/math/Vector2.js"
+import * as geometry from "/lib/geometry.js"
const selectEvent = new Event("select")
const unselectEvent = new Event("unselect")
@@ -692,15 +693,12 @@ export class FloorplanEditor {
a = b
b = t
}
- const rad = function(deg) {
- return deg * Math.PI / 180
- }
let deg = 90
if (value.door_swing.at(1) === "-") {
deg = -deg
}
- let e = b.clone().rotateAround(a, rad(deg))
+ let e = b.clone().rotateAround(a, geometry.rad(deg))
let r = a.distanceTo(b)
let d = `M ${b.x} ${b.y} A ${r} ${r} ${deg} 0 ${deg < 0 ? 0 : 1} ${e.x} ${e.y} L ${a.x} ${a.y} Z`
diff --git a/files/floorplans/floorplan/geometry.js b/files/floorplans/floorplan/geometry.js
@@ -170,3 +170,8 @@ SVG.extend(SVG.Box, {
return this.closestEdge(x, y).distanceTo(new Vector2(x, y))
}
})
+
+export function rad(deg) {
+ return deg * Math.PI / 180
+}
+