Skip to content
Draft
Changes from all 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
24 changes: 20 additions & 4 deletions xplt/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ def ang(a):
continue

element = None
rot_s_rad = 0
rot_x_rad = 0
rot_y_rad = 0
shift_y = 0
shift_x = 0
if line is not None:
# Fallback to extract missing properties from line
try:
Expand All @@ -440,7 +445,13 @@ def ang(a):
order = effective_order(element)
if not length:
length = get(element, "length", 0)
except (TypeError, KeyError):

rot_s_rad = get(element, "rot_s_rad", 0)
rot_x_rad = get(element, "rot_x_rad", 0)
rot_y_rad = get(element, "rot_y_rad", 0)
shift_y = get(element, "shift_y", 0)
shift_x = get(element, "shift_x", 0)
except (TypeError, KeyError) as e:
pass

if self.ignore is not None:
Expand Down Expand Up @@ -476,12 +487,16 @@ def ang(a):
else:
legend_entries.append(box_style.get("label"))

# get the shift angle of the projection
proj = self.projection[1].lower()
shift_angle = {"x": rot_x_rad, "y": rot_y_rad, "z": rot_s_rad}.get(proj, 0)

# Handle thick elements
if is_thick:
# Find the center of single kick for equivalent thin element
d = length * tanc(arc / 2) / 2
x += d * np.cos(ang(rt))
y += d * np.sin(ang(rt))
x += d * np.cos(ang(rt) + ang(shift_angle)) + shift_x
y += d * np.sin(ang(rt) + ang(shift_angle)) + shift_y
Comment on lines -483 to +499
Copy link
Member

Choose a reason for hiding this comment

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

At this point, x and y refer to the plot axis, i.e. the coordinate system of the floor. Depending on the projection this can be any two out of (X, Y, Z).
But shift and rotation is in the relative coordinate system (x, y, s) of the reference trajectory, right? So some translation of the reference trajectory coordinates to floor coordinates is required (equivalent to what the survey command does + projection). And the anchor point of the misalignment has to be taken into account (e.g. if the anchor is not the center and there is a rotation misalignment, then the shift at the center may be larger or smaller than shift_x).

Also unit scaling with scale is missing, but that seems to be missing anywhere around these lines, we can probably fix it in the process.

Copy link
Author

Choose a reason for hiding this comment

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

Ok makes sense, I made my tests on a straight section, that's why it was working I guess.


if length > 0 and arc:
# bending elements as wedge
Expand All @@ -504,14 +519,15 @@ def ang(a):
box = mpl.patches.Wedge(**wedge_kwargs)
else:
# other elements as rect

box = mpl.patches.Rectangle(
**defaults_for(
mpl.patches.Rectangle,
box_style,
xy=(x - width / 2, y - length / 2),
width=width,
height=length,
angle=np.rad2deg(ang(rt - arc / 2)) - 90,
angle=np.rad2deg(ang(rt + shift_angle - arc / 2)) - 90,
rotation_point="center",
alpha=0.5,
zorder=3,
Expand Down
Loading