Skip to content

Commit

Permalink
Line and Subsystem shadows now plot on seabed
Browse files Browse the repository at this point in the history
- Adjusted drawLine methdos to now draw the shadow on the seabed
  bathymetry grid if it exists.
  • Loading branch information
mattEhall committed Dec 23, 2024
1 parent 969381d commit 8973cfc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
11 changes: 10 additions & 1 deletion moorpy/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,16 @@ def drawLine(self, Time, ax, color="k", endpoints=False, shadow=True, colortensi
linebit.append(ax.plot(Xs, Ys, Zs, color=color, lw=lw, zorder=100))

if shadow:
ax.plot(Xs, Ys, np.zeros_like(Xs)-self.sys.depth, color=[0.5, 0.5, 0.5, 0.2], lw=lw, zorder = 1.5) # draw shadow
if self.sys.seabedMod == 0:
Zs = np.zeros_like(Xs)-self.sys.depth
elif self.seabedMod == 1:
Zs = self.sys.depth - self.sys.xSlope*Xs - self.sys.ySlope*Ys
elif self.seabedMod == 2:
Zs = np.zeros(len(Xs))
for i in range(len(Xs)):
Zs[i] = self.sys.getDepthAtLocation(Xs[i], Ys[i])

ax.plot(Xs, Ys, Zs, color=[0.5, 0.5, 0.5, 0.2], lw=lw, zorder = 1.5) # draw shadow

if endpoints == True:
linebit.append(ax.scatter([Xs[0], Xs[-1]], [Ys[0], Ys[-1]], [Zs[0], Zs[-1]], color = color))
Expand Down
15 changes: 12 additions & 3 deletions moorpy/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,15 @@ def setEndPosition(self, r, endB, sink=False):
raise LineError("setEndPosition: endB value has to be either 1 or 0")


def staticSolve(self, reset=False, tol=0, profiles=0, maxIter = 500):
def staticSolve(self, tol=0, profiles=0, maxIter = 500):
'''Solve internal equilibrium of the Subsystem and saves the forces
and stiffnesses at the ends in the global reference frame. All the
This method mimics the behavior of the Line.staticSolve method and
the end coordinates rA and rB must be set beforehand. The solve
equilibrium happens in the local 2D plane. Values in this local
frame are also saved.
'''

# >>> need to deal with bathymetry transformation for subsystems! >>>
if tol==0:
tol=self.eqtol

Expand Down Expand Up @@ -462,7 +462,16 @@ def drawLine(self, Time, ax, color="k", endpoints=False, shadow=True, colortensi
ax.plot(Xs, Ys, Zs, color=line.color, lw=line.lw, zorder=100)

if shadow:
ax.plot(Xs, Ys, np.zeros_like(Xs)-self.depth, color=[0.5, 0.5, 0.5, 0.2], lw=line.lw, zorder = 1.5) # draw shadow
if self.seabedMod == 0:
Zs = np.zeros_like(Xs)-self.depth
elif self.seabedMod == 1:
Zs = self.depth - self.xSlope*Xs - self.ySlope*Ys
elif self.seabedMod == 2:
Zs = np.zeros(len(Xs))
for i in range(len(Xs)):
Zs[i] = self.getDepthAtLocation(Xs[i], Ys[i])

ax.plot(Xs, Ys, Zs, color=[0.5, 0.5, 0.5, 0.2], lw=line.lw, zorder = 1.5) # draw shadow

if endpoints == True:
#linebit.append(ax.scatter([Xs[0], Xs[-1]], [Ys[0], Ys[-1]], [Zs[0], Zs[-1]], color = color))
Expand Down

0 comments on commit 8973cfc

Please sign in to comment.