Skip to content

Commit 9f51b4d

Browse files
authored
Beakerboy patch 1 (#116)
* Update buildingpart.test.js * Update buildingpart.js
1 parent e5c52da commit 9f51b4d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/buildingpart.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ class BuildingPart {
148148
const directionalRoofs = ['gabled', 'round'];
149149
calculatedOptions.roof.direction = this.options.specified.roof.direction ?? this.options.inherited.roof.direction;
150150
if (calculatedOptions.roof.direction === undefined && directionalRoofs.includes(calculatedOptions.roof.shape)) {
151-
// Radians pi > x >= -pi
152151
let longestSide = BuildingShapeUtils.longestSideAngle(this.shape);
153152

154153
// Convert to angle.
155-
calculatedOptions.roof.direction = BuildingPart.atanRadToCompassDeg(longestSide);
154+
calculatedOptions.roof.direction = (BuildingPart.atanRadToCompassDeg(longestSide) + 90) % 360;
156155
}
157156
const extents = BuildingShapeUtils.extents(this.shape, calculatedOptions.roof.direction / 360 * 2 * Math.PI);
158157
const shapeHeight = extents[3] - extents[1];

test/buildingpart.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test('Constructor', () => {
7070
expect(value).toStrictEqual([4.332747472106493, 5.88221335051411]);
7171
expect(BuildingShapeUtils.edgeDirection(part.shape)).toStrictEqual([Math.PI / 2, 0, -Math.PI / 2, Math.PI]);
7272
expect(BuildingShapeUtils.longestSideAngle(part.shape)).toBe(Math.PI / 2);
73-
expect(part.options.roof.direction).toBe(0);
73+
expect(part.options.roof.direction).toBe(90);
7474
expect(errors.length).toBe(0);
7575
});
7676

0 commit comments

Comments
 (0)