Skip to content

Commit e41a2e6

Browse files
committed
fix(room2d): Add transforms for comparison geometry
1 parent 4ecd044 commit e41a2e6

File tree

2 files changed

+55
-8
lines changed

2 files changed

+55
-8
lines changed

docs/cli/index.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

dragonfly_comparison/properties/room2d.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# coding=utf-8
22
"""Room2D Comparison Properties."""
3+
import math
4+
35
from ladybug_geometry.geometry3d import Point3D, Vector3D, Plane, Face3D
46
from dragonfly.windowparameter import _WindowParameterBase
5-
from dragonfly.skylightparameter import _SkylightParameterBase
7+
from dragonfly.skylightparameter import _SkylightParameterBase, DetailedSkylights
68
import dragonfly.windowparameter as glzpar
79
import dragonfly.skylightparameter as skypar
810

@@ -270,6 +272,58 @@ def reset(self):
270272
self.comparison_windows = self.host.window_parameters
271273
self.comparison_skylight = self.host.skylight_parameters
272274

275+
def move(self, moving_vec):
276+
"""Move these properties along a vector.
277+
278+
Args:
279+
moving_vec: A ladybug_geometry Vector3D with the direction and distance
280+
to move the room.
281+
"""
282+
if self.comparison_floor_geometry is not None:
283+
self.comparison_floor_geometry = \
284+
self.comparison_floor_geometry.move(moving_vec)
285+
if isinstance(self.comparison_skylight, DetailedSkylights):
286+
self.comparison_skylight = self.comparison_skylight.move(moving_vec)
287+
288+
def rotate_xy(self, angle, origin):
289+
"""Rotate these properties counterclockwise in the XY plane by a certain angle.
290+
291+
Args:
292+
angle: An angle in degrees.
293+
origin: A ladybug_geometry Point3D for the origin around which the
294+
object will be rotated.
295+
"""
296+
if self.comparison_floor_geometry is not None:
297+
self.comparison_floor_geometry = \
298+
self.comparison_floor_geometry.rotate_xy(math.radians(angle), origin)
299+
if isinstance(self.comparison_skylight, DetailedSkylights):
300+
self.comparison_skylight = self.comparison_skylight.rotate(angle, origin)
301+
302+
def scale(self, factor, origin=None):
303+
"""Scale these properties by a factor from an origin point.
304+
305+
Args:
306+
factor: A number representing how much the object should be scaled.
307+
origin: A ladybug_geometry Point3D representing the origin from which
308+
to scale. If None, it will be scaled from the World origin (0, 0, 0).
309+
"""
310+
# scale the floor geometry
311+
if self.comparison_floor_geometry is not None:
312+
self.comparison_floor_geometry = \
313+
self.comparison_floor_geometry.scale(factor, origin)
314+
# scale the window parameters
315+
if self.comparison_windows is not None:
316+
scaled_windows = []
317+
for win_par in self.comparison_windows:
318+
s_wp = win_par.scale(factor) if win_par is not None else None
319+
scaled_windows.append(s_wp)
320+
self.comparison_windows = tuple(scaled_windows)
321+
# scale the skylight parameters
322+
if self.comparison_skylight is not None:
323+
self.comparison_skylight = self.comparison_skylight.scale(factor, origin) \
324+
if isinstance(self.comparison_skylight, DetailedSkylights) else \
325+
self.comparison_skylight.scale(factor)
326+
273327
@classmethod
274328
def from_dict(cls, data, host):
275329
"""Create Room2DComparisonProperties from a dictionary.

0 commit comments

Comments
 (0)