|
1 | 1 | # coding=utf-8
|
2 | 2 | """Room2D Comparison Properties."""
|
| 3 | +import math |
| 4 | + |
3 | 5 | from ladybug_geometry.geometry3d import Point3D, Vector3D, Plane, Face3D
|
4 | 6 | from dragonfly.windowparameter import _WindowParameterBase
|
5 |
| -from dragonfly.skylightparameter import _SkylightParameterBase |
| 7 | +from dragonfly.skylightparameter import _SkylightParameterBase, DetailedSkylights |
6 | 8 | import dragonfly.windowparameter as glzpar
|
7 | 9 | import dragonfly.skylightparameter as skypar
|
8 | 10 |
|
@@ -270,6 +272,58 @@ def reset(self):
|
270 | 272 | self.comparison_windows = self.host.window_parameters
|
271 | 273 | self.comparison_skylight = self.host.skylight_parameters
|
272 | 274 |
|
| 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 | + |
273 | 327 | @classmethod
|
274 | 328 | def from_dict(cls, data, host):
|
275 | 329 | """Create Room2DComparisonProperties from a dictionary.
|
|
0 commit comments