From a8621c26218034ba22b4917565bc0fa13bee7fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Luis=20Cerc=C3=B3s=20pita?= Date: Fri, 9 Mar 2012 10:52:18 +0100 Subject: [PATCH] Fixed some hydrostatics computation at monohull ships --- src/Mod/Ship/shipHydrostatics/Tools.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Mod/Ship/shipHydrostatics/Tools.py b/src/Mod/Ship/shipHydrostatics/Tools.py index d3bf8698d..ecef88028 100644 --- a/src/Mod/Ship/shipHydrostatics/Tools.py +++ b/src/Mod/Ship/shipHydrostatics/Tools.py @@ -64,6 +64,7 @@ def Displacement(ship, draft, trim): if z > Z: break n = n+1 + print('orig-> ', section[n-2:n], Z) # Discard invalid sections if n == 0: areas.append(0.0) @@ -80,6 +81,7 @@ def Displacement(ship, draft, trim): factor = (Z - z0) / (z1 - z0) y = y0 + factor*(y1 - y0) points.append(App.Base.Vector(x,y,Z)) + print('dest-> ', points[-3:]) # Convert into array with n elements (Number of points by sections) # with m elements into them (Number of points with the same height, # typical of multibody) @@ -89,11 +91,18 @@ def Displacement(ship, draft, trim): while j < len(points)-1: section.append([points[j]]) k = j+1 - while(Math.isAprox(points[j].z, points[k].z)): + last=False # In order to identify if last point has been append + while(k < len(points)): + if not Math.isAprox(points[j].z, points[k].z): + break section[nPoints].append(points[k]) + last=True k = k+1 nPoints = nPoints + 1 j = k + if not last: # Last point has not been added + section.append([points[len(points)-1]]) + print('Zeq-> ', section[-3:]) # Integrate area area = 0.0 for j in range(0, len(section)-1):