Skip to content

Commit

Permalink
fix(extension): Ensure that center points are correctly respected
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Oct 27, 2022
1 parent 170a1f2 commit 198cf85
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions ladybug_display/extension/sunpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def sunpath_to_vis_set(
daily.append(DisplayArc3D(arc, line_width=lw, line_type=lt))
else:
# draw arcs and analemmas in the requested projection
bp = Plane(o=center_point)
bp = Plane(o=Point3D(0, 0, z))
ana_plin_1 = sunpath.hourly_analemma_polyline2d(
projection, center_point, radius, True, solar_time, 1, 6, 4)
ana_plin_2 = sunpath.hourly_analemma_polyline2d(
Expand Down Expand Up @@ -147,7 +147,7 @@ def sunpath_to_vis_set(
d_arc = sunpath.day_arc3d(dat.month, dat.day, center_point, radius)
daily.append(DisplayArc3D(d_arc))
else:
bp = Plane(o=center_point)
bp = Plane(o=Point3D(0, 0, z))
daily = []
for dat in dates:
d_arc = sunpath.day_polyline2d(
Expand Down
38 changes: 23 additions & 15 deletions ladybug_display/extension/windrose.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from ladybug_geometry.geometry3d import Point3D, Plane, LineSegment3D, \
Polyline3D, Mesh3D

from ladybug_display.geometry3d import DisplayLineSegment3D, DisplayPolyline3D
from ladybug_display.geometry3d import DisplayLineSegment3D, DisplayPolyline3D, \
DisplayText3D
from ladybug_display.visualization import VisualizationSet, AnalysisGeometry, \
VisualizationData, ContextGeometry
from ladybug_display.extension.compass import compass_to_vis_set
Expand All @@ -17,19 +18,17 @@ def wind_rose_to_vis_set(windrose, z=0):
Returns:
A VisualizationSet with the wind rose represented several ContextGeometries
(and optionally an AnalysisGeometry if data is input). This includes these
objects in the following order.
and an AnalysisGeometry. This includes these objects in the following order.
- Compass -- A ContextGeometry for the Compass at the base of the wind rose.
- Orientation_Lines -- Line geometries representing the edges (or "spokes")
of the wind rose directions.
- Orientation_Lines -- A ContextGeometry with lines representing the
edges (or "spokes") of the wind rose directions.
- Frequency_Lines -- Polygon geometries representing the frequency intervals
of the wind rose.
- Frequency_Lines -- A ContextGeometry with polygons representing
the frequency intervals of the wind rose.
- Analysis_Data -- An AnalysisGeometry for representing the wind rose
derived from the input data.
- Analysis_Data -- An AnalysisGeometry for the wind rose data.
"""
# establish the VisualizationSet object
wr_metadata = windrose.analysis_data_collection.header.metadata
Expand All @@ -39,26 +38,35 @@ def wind_rose_to_vis_set(windrose, z=0):
vis_set = VisualizationSet(set_id, ())

# add the compass to the bottom of the path
vis_set.add_geometry(compass_to_vis_set(windrose.compass, z=z)[0])
legend_par = windrose.legend.legend_parameters
font, txt_h = legend_par.font, legend_par.text_height
vis_set.add_geometry(compass_to_vis_set(windrose.compass, z=z, font=font)[0])

# add the orientation lines
orient_line = [LineSegment3D.from_line_segment2d(seg, z) for seg in
windrose.orientation_lines]
dis_orient = []
for i, lin in enumerate(orient_line):
for lin in orient_line:
dis_orient.append(DisplayLineSegment3D(lin, line_type='Dotted'))
orient_geo = ContextGeometry('Orientation_Lines', dis_orient)
orient_geo.display_name = 'Orientation Lines'
vis_set.add_geometry(orient_geo)

# add the frequency lines
wr_pln = Plane(o=Point3D(windrose.base_point.x, windrose.base_point.y, z))
wr_pln = Plane(o=Point3D(0, 0, z))
freq_line = [Polyline3D.from_polyline2d(Polyline2D.from_polygon(poly), wr_pln)
for poly in windrose.frequency_lines[:-1]]
dis_freq = []
for i, lin in enumerate(freq_line):
dis_freq, freq_text = [], []
f_int = windrose.frequency_hours
txt_h = min((windrose.frequency_spacing_distance / 4, txt_h))
freqs = range(0, f_int * windrose.frequency_intervals_compass, f_int)
for i, (lin, val) in enumerate(zip(freq_line, freqs)):
dis_freq.append(DisplayPolyline3D(lin, line_type='Dotted'))
freq_geo = ContextGeometry('Frequency_Lines', dis_freq)
if i % 2 == 0 and i != 0:
b_pln = Plane(o=lin.segments[0].midpoint)
d_txt = DisplayText3D(str(val), b_pln, txt_h, None, font, 'Center', 'Bottom')
freq_text.append(d_txt)
freq_geo = ContextGeometry('Frequency_Lines', dis_freq + freq_text)
freq_geo.display_name = 'Frequency Lines'
vis_set.add_geometry(freq_geo)

Expand Down

0 comments on commit 198cf85

Please sign in to comment.