Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Fixed `AttributeError` when deserializing a model with Lap joints.
* Fixed a bug in `compas_timber.fabrication.Lap` where `ref_side_index` failed for `0` by checking for `None` instead.
* Fixed a bug in `compas_timber.fabrication.Lap` to handle the case when the vectors used to calculate the `inclination` angle are perpendicular.
* Adjusted `angle_vectors_projected` function so that it returns `None` if any of the projections results in a zero-vector.
Comment thread
papachap marked this conversation as resolved.
Outdated

### Removed


Expand Down
7 changes: 5 additions & 2 deletions src/compas_timber/connections/l_lap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from compas.tolerance import TOL

from compas_timber.errors import BeamJoiningError
from compas_timber.fabrication import JackRafterCut
from compas_timber.fabrication import Lap
Expand Down Expand Up @@ -64,8 +66,9 @@ def add_extensions(self):
raise BeamJoiningError(self.elements, self, debug_info=str(ae), debug_geometries=geometries)
except Exception as ex:
raise BeamJoiningError(self.elements, self, debug_info=str(ex))
self.main_beam.add_blank_extension(start_main, end_main, self.main_beam_guid)
self.cross_beam.add_blank_extension(start_cross, end_cross, self.cross_beam_guid)
tol = TOL.absolute
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure that's enough? TOL.absolute is like 1e-9 iirc..

self.main_beam.add_blank_extension(start_main + tol, end_main + tol, self.main_beam_guid)
self.cross_beam.add_blank_extension(start_cross + tol, end_cross + tol, self.cross_beam_guid)

def add_features(self):
"""Adds the required joint features to both beams.
Expand Down
16 changes: 8 additions & 8 deletions src/compas_timber/fabrication/lap.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def from_volume_and_beam(cls, volume, beam, machining_limits=None, ref_side_inde
raise ValueError("Volume must have 6 faces.")

# get ref_side of the
if not ref_side_index:
if ref_side_index is None:
ref_side_index = cls._get_optimal_ref_side_index(beam, volume)
ref_side = beam.ref_sides[ref_side_index]

Expand Down Expand Up @@ -442,6 +442,8 @@ def from_volume_and_beam(cls, volume, beam, machining_limits=None, ref_side_inde

# calculate the inclination of the lap
inclination = angle_vectors_projected(zzaxis, front_plane.normal, yyaxis)
Comment thread
obucklin marked this conversation as resolved.
Outdated
if inclination is None:
inclination = angle_vectors_signed(zzaxis, ref_side.xaxis, ref_side.normal, deg=True)
inclination = 180 + inclination if inclination < 0 else inclination

# calculate the slope of the lap
Expand Down Expand Up @@ -736,25 +738,23 @@ def _planes_from_params_and_beam(self, beam):
tol = Tolerance()
tol.absolute=1e-3

if self.machining_limits["FaceLimitedStart"]:
start_frame = self._start_frame_from_params_and_beam(beam)
else:
start_frame = beam.ref_sides[4]
start_frame = self._start_frame_from_params_and_beam(beam)

top_frame = beam.ref_sides[self.ref_side_index] # top should always be unlimited
top_frame.translate(top_frame.normal * TOL.absolute)

if self.machining_limits["FaceLimitedEnd"]:
end_frame = start_frame.translated(-start_frame.normal * self.length)
end_frame.yaxis = -end_frame.yaxis
else:
end_frame = beam.ref_sides[5]

top_frame = beam.ref_sides[self.ref_side_index] # top should always be unlimited

if self.machining_limits["FaceLimitedBottom"]:
bottom_frame = Frame(start_frame.point, start_frame.zaxis, start_frame.yaxis)
angle = angle_vectors_signed(top_frame.xaxis, -start_frame.xaxis, top_frame.yaxis)
bottom_frame = bottom_frame.translated(bottom_frame.zaxis * (self.depth/math.sin(angle)))
else:
bottom_frame = beam.ref_sides[4]
bottom_frame = beam.opp_side(self.ref_side_index)

if self.machining_limits["FaceLimitedFront"]:
front_frame = bottom_frame.rotated(math.radians(self.lead_angle), bottom_frame.xaxis, point=bottom_frame.point)
Expand Down
5 changes: 4 additions & 1 deletion src/compas_timber/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from compas.geometry import intersection_line_plane
from compas.geometry import closest_point_on_segment
from compas.geometry import intersection_line_line
from compas.tolerance import TOL


def intersection_line_line_param(line1, line2, max_distance=1e-6, limit_to_segments=True, tol=1e-6):
Expand Down Expand Up @@ -307,14 +308,16 @@ def angle_vectors_projected(vector_a, vector_b, normal):
Returns
-------
float
The angle between the two projected vectors
The angle between the two projected vectors. If any of the projections results in a zero vector, None is returned.
"""
if isinstance(normal, (Plane, Frame)):
normal = normal.normal

projection = Projection.from_plane(Plane(Point(0, 0, 0), normal))
proj_vect_a = vector_a.transformed(projection)
proj_vect_b = vector_b.transformed(projection)
if TOL.is_zero(proj_vect_a.length) or TOL.is_zero(proj_vect_b.length):
return None
return angle_vectors_signed(proj_vect_a, proj_vect_b, normal, deg=True)


Expand Down