Skip to content

Commit

Permalink
fix(pipe): Fix all pipe and duct transforms
Browse files Browse the repository at this point in the history
- Fix bug (degrees/radians) in pip and duct rotation transforms
  • Loading branch information
ed-p-may committed May 2, 2024
1 parent 155c249 commit d6789ba
Show file tree
Hide file tree
Showing 13 changed files with 732 additions and 419 deletions.
6 changes: 3 additions & 3 deletions honeybee_ph_standards/programtypes/PHIUS_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@
},
"2021::PHIUS_NR::Library_Storage": {
"name": "Library Storage",
"hb_base_program": "",
"hb_base_program": "2019::SecondarySchool::Library",
"protocol": "PHIUS_NonRes",
"description": "Library magazine and stores",
"source": ["PHIUS_Certification_Guidebook_v3.02_N10", ""],
Expand Down Expand Up @@ -795,7 +795,7 @@
},
"2021::PHIUS_NR::Library_Stacks": {
"name": "Library Stacks",
"hb_base_program": "",
"hb_base_program": "2019::SecondarySchool::Library",
"protocol": "PHIUS_NonRes",
"description": "Library-open stacks areas",
"source": ["PHIUS_Certification_Guidebook_v3.02_N10", ""],
Expand Down Expand Up @@ -1160,7 +1160,7 @@
},
"2021::PHIUS_NR::Office_Workspace_Closed": {
"name": "Office Workspace Closed",
"hb_base_program": "",
"hb_base_program": "2019::MediumOffice::ClosedOffice",
"protocol": "PHIUS_NonRes",
"description": "Personal office (single occupant)",
"source": ["PHIUS_Certification_Guidebook_v3.02_N10", ""],
Expand Down
90 changes: 46 additions & 44 deletions honeybee_phhvac/ducting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

"""Honeybee-PH-HVAC-Equipment: Ducts."""

from math import radians

try:
from typing import Any, Dict, List, Optional, Union
except ImportError:
Expand Down Expand Up @@ -145,18 +147,18 @@ def __repr__(self):
def ToString(self):
return self.__repr__()

def move(self, moving_vec):
def move(self, moving_vec3D):
# type: (Point3D) -> PhDuctSegment
"""Move the duct segment along a vector.
Args:
moving_vec: A Vector3D with the direction and distance to move the ray.
moving_vec3D: A Vector3D with the direction and distance to move the ray.
"""
new_segment = self.duplicate()
new_segment.geometry = self.geometry.move(moving_vec)
new_segment.geometry = self.geometry.move(moving_vec3D)
return new_segment

def rotate(self, axis, angle, origin):
def rotate(self, axis_vec3D, angle_degrees, origin_pt3D):
# type: (Point3D, float, Point3D) -> PhDuctSegment
"""Rotate the duct segment by a certain angle around an axis and origin.
Expand All @@ -165,54 +167,54 @@ def rotate(self, axis, angle, origin):
If axis has a negative orientation, rotation will be counterclockwise.
Args:
axis: A Vector3D axis representing the axis of rotation.
angle: An angle for rotation in radians.
origin: A Point3D for the origin around which the object will be rotated.
axis_vec3D: A Vector3D axis representing the axis of rotation.
angle_degrees: An angle for rotation in degrees.
origin_pt3D: A Point3D for the origin around which the object will be rotated.
"""
new_segment = self.duplicate()
new_segment.geometry = self.geometry.rotate(axis, angle, origin)
new_segment.geometry = self.geometry.rotate(axis_vec3D, radians(angle_degrees), origin_pt3D)
return new_segment

def rotate_xy(self, angle, origin):
def rotate_xy(self, angle_degrees, origin_pt3D):
# type: (float, Point3D) -> PhDuctSegment
"""Rotate the duct segment counterclockwise in the XY plane by a certain angle.
Args:
angle: An angle in radians.
origin: A Point3D for the origin around which the object will be rotated.
angle_degrees: An angle in degrees.
origin_pt3D: A Point3D for the origin around which the object will be rotated.
"""
new_segment = self.duplicate()
new_segment.geometry = self.geometry.rotate_xy(angle, origin)
new_segment.geometry = self.geometry.rotate_xy(radians(angle_degrees), origin_pt3D)
return new_segment

def reflect(self, normal, origin):
def reflect(self, normal_vec3D, origin_pt3D):
# type: (Point3D, Point3D) -> PhDuctSegment
"""Reflected the duct segment across a plane with the input normal vector and origin.
Args:
normal: A Vector3D representing the normal vector for the plane across
normal_vec3D: A Vector3D representing the normal vector for the plane across
which the line segment will be reflected. THIS VECTOR MUST BE NORMALIZED.
origin: A Point3D representing the origin from which to reflect.
origin_pt3D: A Point3D representing the origin from which to reflect.
"""
new_segment = self.duplicate()
new_segment.geometry = self.geometry.reflect(normal, origin)
new_segment.geometry = self.geometry.reflect(normal_vec3D, origin_pt3D)
return new_segment

def scale(self, factor, origin=None):
def scale(self, scale_factor, origin_pt3D=None):
# type: (float, Optional[Point3D]) -> PhDuctSegment
"""Scale the duct segment by a factor from an origin point.
Args:
factor: A number representing how much the line segment should be scaled.
origin: A Point3D representing the origin from which to scale.
scale_factor: A number representing how much the line segment should be scaled.
origin_pt3D: A Point3D representing the origin from which to scale.
If None, it will be scaled from the World origin (0, 0, 0).
"""
new_segment = self.duplicate()
new_segment.geometry = self.geometry.scale(factor, origin)
new_segment.insulation_thickness = self.insulation_thickness * factor
new_segment.diameter = self.diameter * factor
new_segment.height = factor * self.height if self.height else None
new_segment.width = factor * self.width if self.width else None
new_segment.geometry = self.geometry.scale(scale_factor, origin_pt3D)
new_segment.insulation_thickness = self.insulation_thickness * scale_factor
new_segment.diameter = self.diameter * scale_factor
new_segment.height = scale_factor * self.height if self.height else None
new_segment.width = scale_factor * self.width if self.width else None
return new_segment


Expand Down Expand Up @@ -361,74 +363,74 @@ def __repr__(self):
def ToString(self):
return self.__repr__()

def move(self, moving_vec):
def move(self, moving_vec3D):
"""Move the duct element's segment along a vector.
Args:
moving_vec: A Vector3D with the direction and distance to move the ray.
moving_vec3D: A Vector3D with the direction and distance to move the ray.
"""
new_element = self.duplicate()
new_element.clear_segments()
for segment in self.segments:
new_element.add_segment(segment.move(moving_vec))
new_element.add_segment(segment.move(moving_vec3D))
return new_element

def rotate(self, axis, angle, origin):
def rotate(self, axis_vec3D, angle_degrees, origin_pt3D):
"""Rotate the duct element's segment by a certain angle around an axis and origin.
Right hand rule applies:
If axis has a positive orientation, rotation will be clockwise.
If axis has a negative orientation, rotation will be counterclockwise.
Args:
axis: A Vector3D axis representing the axis of rotation.
angle: An angle for rotation in radians.
origin: A Point3D for the origin around which the object will be rotated.
axis_vec3D: A Vector3D axis representing the axis of rotation.
angle_degrees: An angle for rotation in degrees.
origin_pt3D: A Point3D for the origin around which the object will be rotated.
"""
new_element = self.duplicate()
new_element.clear_segments()
for segment in self.segments:
new_element.add_segment(segment.rotate(axis, angle, origin))
new_element.add_segment(segment.rotate(axis_vec3D, angle_degrees, origin_pt3D))
return new_element

def rotate_xy(self, angle, origin):
def rotate_xy(self, angle_degrees, origin_pt3D):
"""Rotate the duct element's segment counterclockwise in the XY plane by a certain angle.
Args:
angle: An angle in radians.
origin: A Point3D for the origin around which the object will be rotated.
angle_degree: An angle in degrees.
origin_pt3D: A Point3D for the origin around which the object will be rotated.
"""
new_element = self.duplicate()
new_element.clear_segments()
for segment in self.segments:
new_element.add_segment(segment.rotate_xy(angle, origin))
new_element.add_segment(segment.rotate_xy(angle_degrees, origin_pt3D))
return new_element

def reflect(self, normal, origin):
def reflect(self, normal_vec3D, origin_pt3D):
"""Reflected the duct element's segment across a plane with the input normal vector and origin.
Args:
normal: A Vector3D representing the normal vector for the plane across
normal_vec3D: A Vector3D representing the normal vector for the plane across
which the line segment will be reflected. THIS VECTOR MUST BE NORMALIZED.
origin: A Point3D representing the origin from which to reflect.
origin_pt3D: A Point3D representing the origin from which to reflect.
"""
new_element = self.duplicate()
new_element.clear_segments()
for segment in self.segments:
new_element.add_segment(segment.reflect(normal, origin))
new_element.add_segment(segment.reflect(normal_vec3D, origin_pt3D))
return new_element

def scale(self, factor, origin=None):
def scale(self, scale_factor, origin_pt3D=None):
# type: (float, Optional[Point3D]) -> PhDuctElement
"""Scale the duct element's segments by a factor from an origin point.
Args:
factor: A number representing how much the line segment should be scaled.
origin: A Point3D representing the origin from which to scale.
scale_factor: A number representing how much the line segment should be scaled.
origin_pt3D: A Point3D representing the origin from which to scale.
If None, it will be scaled from the World origin (0, 0, 0).
"""
new_element = self.duplicate()
new_element.clear_segments()
for segment in self.segments:
new_element.add_segment(segment.scale(factor, origin))
new_element.add_segment(segment.scale(scale_factor, origin_pt3D))
return new_element
42 changes: 21 additions & 21 deletions honeybee_phhvac/heat_pumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,54 +72,54 @@ def __lt__(self, other):
# type: (PhHeatPumpSystem) -> bool
return self.identifier < other.identifier

def move(self, moving_vec):
def move(self, moving_vec3D):
"""Move the System's elements along a vector.
Args:
moving_vec: A Vector3D with the direction and distance to move the ray.
moving_vec3D: A Vector3D with the direction and distance to move the ray.
"""
pass

def rotate(self, axis, angle, origin):
"""Rotate the System's elements by a certain angle around an axis and origin.
def rotate(self, axis_vec3D, angle_degrees, origin_pt3D):
"""Rotate the System's elements by a certain angle around an axis_vec3D and origin_pt3D.
Right hand rule applies:
If axis has a positive orientation, rotation will be clockwise.
If axis has a negative orientation, rotation will be counterclockwise.
If axis_vec3D has a positive orientation, rotation will be clockwise.
If axis_vec3D has a negative orientation, rotation will be counterclockwise.
Args:
axis: A Vector3D axis representing the axis of rotation.
angle: An angle for rotation in radians.
origin: A Point3D for the origin around which the object will be rotated.
axis_vec3D: A Vector3D axis_vec3D representing the axis_vec3D of rotation.
angle_degrees: An angle for rotation in degrees.
origin_pt3D: A Point3D for the origin_pt3D around which the object will be rotated.
"""
pass

def rotate_xy(self, angle, origin):
def rotate_xy(self, angle_degrees, origin_pt3D):
"""Rotate the System's elements counterclockwise in the XY plane by a certain angle.
Args:
angle: An angle in radians.
origin: A Point3D for the origin around which the object will be rotated.
angle_degrees: An angle in degrees.
origin_pt3D: A Point3D for the origin_pt3D around which the object will be rotated.
"""
pass

def reflect(self, normal, origin):
"""Reflected the System's elements across a plane with the input normal vector and origin.
def reflect(self, normal_vec3D, origin_pt3D):
"""Reflected the System's elements across a plane with the input normal vector and origin_pt3D.
Args:
normal: A Vector3D representing the normal vector for the plane across
normal_vec3D: A Vector3D representing the normal vector for the plane across
which the line segment will be reflected. THIS VECTOR MUST BE NORMALIZED.
origin: A Point3D representing the origin from which to reflect.
origin_pt3D: A Point3D representing the origin_pt3D from which to reflect.
"""
pass

def scale(self, factor, origin=None):
"""Scale the System's elements by a factor from an origin point.
def scale(self, scale_factor, origin_pt3D=None):
"""Scale the System's elements by a factor from an origin_pt3D point.
Args:
factor: A number representing how much the line segment should be scaled.
origin: A Point3D representing the origin from which to scale.
If None, it will be scaled from the World origin (0, 0, 0).
scale_factor: A number representing how much the line segment should be scaled.
origin_pt3D: A Point3D representing the origin_pt3D from which to scale.
If None, it will be scaled from the World origin_pt3D (0, 0, 0).
"""
pass

Expand Down
14 changes: 7 additions & 7 deletions honeybee_phhvac/heating.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ def __lt__(self, other):
# type: (PhHeatingSystem) -> bool
return self.identifier < other.identifier

def move(self, moving_vec):
def move(self, moving_vec3D):
"""Move the System's elements along a vector.
Args:
moving_vec: A Vector3D with the direction and distance to move the ray.
"""
pass

def rotate(self, axis, angle, origin):
def rotate(self, axis_vec3D, angle_degree, origin_pt3D):
"""Rotate the System's elements by a certain angle around an axis and origin.
Right hand rule applies:
Expand All @@ -84,21 +84,21 @@ def rotate(self, axis, angle, origin):
Args:
axis: A Vector3D axis representing the axis of rotation.
angle: An angle for rotation in radians.
angle: An angle for rotation in degrees.
origin: A Point3D for the origin around which the object will be rotated.
"""
pass

def rotate_xy(self, angle, origin):
def rotate_xy(self, angle_degree, origin_pt3D):
"""Rotate the System's elements counterclockwise in the XY plane by a certain angle.
Args:
angle: An angle in radians.
angle: An angle in degrees.
origin: A Point3D for the origin around which the object will be rotated.
"""
pass

def reflect(self, normal, origin):
def reflect(self, normal_vec3D, origin_pt3D):
"""Reflected the System's elements across a plane with the input normal vector and origin.
Args:
Expand All @@ -108,7 +108,7 @@ def reflect(self, normal, origin):
"""
pass

def scale(self, factor, origin=None):
def scale(self, scale_factor, origin=None):
"""Scale the System's elements by a factor from an origin point.
Args:
Expand Down
9 changes: 9 additions & 0 deletions honeybee_phhvac/hot_water_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ def __init__(self):
self.percent_coverage = 1.0
self.in_conditioned_space = True

def __copy__(self):
# type: () -> PhHvacHotWaterHeater
# TODO: Implement copy
return self

def duplicate(self):
# type: () -> PhHvacHotWaterHeater
return self.__copy__()

def to_dict(self):
# type: () -> dict
d = super(PhHvacHotWaterHeater, self).to_dict()
Expand Down
Loading

0 comments on commit d6789ba

Please sign in to comment.