Fixed units usage
This commit is contained in:
parent
2f22ac7816
commit
f99b67f11c
|
@ -147,9 +147,9 @@ def displacement(ship, draft, roll=0.0, trim=0.0, yaw=0.0):
|
||||||
# Create the "sea" box to intersect the ship
|
# Create the "sea" box to intersect the ship
|
||||||
L = xmax - xmin
|
L = xmax - xmin
|
||||||
B = bbox.YMax - bbox.YMin
|
B = bbox.YMax - bbox.YMin
|
||||||
p = Vector(-1.5*L, -1.5*B, bbox.ZMin)
|
p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0)
|
||||||
try:
|
try:
|
||||||
box = Part.makeBox(3.0*L, 3.0*B, - bbox.ZMin, p)
|
box = Part.makeBox(3.0*L, 3.0*B, - bbox.ZMin + 1.0, p)
|
||||||
except:
|
except:
|
||||||
return [0.0, Vector(), 0.0]
|
return [0.0, Vector(), 0.0]
|
||||||
|
|
||||||
|
@ -206,12 +206,13 @@ def wettedArea(shape, draft, trim):
|
||||||
nObjects = 0
|
nObjects = 0
|
||||||
|
|
||||||
shape = shape.copy()
|
shape = shape.copy()
|
||||||
shape.translate(Vector(0.0, 0.0, -draft))
|
shape.translate(Vector(0.0, 0.0, -draft * Units.Metre.Value))
|
||||||
shape.rotate(Vector(0.0, 0.0, 0.0), Vector(0.0, -1.0, 0.0), trim)
|
shape.rotate(Vector(0.0, 0.0, 0.0), Vector(0.0, -1.0, 0.0), trim)
|
||||||
|
|
||||||
bbox = shape.BoundBox
|
bbox = shape.BoundBox
|
||||||
xmin = bbox.XMin
|
xmin = bbox.XMin
|
||||||
xmax = bbox.XMax
|
xmax = bbox.XMax
|
||||||
|
|
||||||
# Create the "sea" box
|
# Create the "sea" box
|
||||||
L = xmax - xmin
|
L = xmax - xmin
|
||||||
B = bbox.YMax - bbox.YMin
|
B = bbox.YMax - bbox.YMin
|
||||||
|
@ -238,7 +239,9 @@ def moment(ship, draft, trim, disp, xcb):
|
||||||
@note Moment is positive when produce positive trim.
|
@note Moment is positive when produce positive trim.
|
||||||
"""
|
"""
|
||||||
factor = 10.0
|
factor = 10.0
|
||||||
angle = factor * math.degrees(math.atan2(0.01, 0.5 * ship.Length))
|
angle = factor * math.degrees(math.atan2(
|
||||||
|
0.01,
|
||||||
|
0.5 * ship.Length.getValueAs('m').Value))
|
||||||
newTrim = trim + angle
|
newTrim = trim + angle
|
||||||
data = displacement(ship, draft, 0.0, newTrim, 0.0)
|
data = displacement(ship, draft, 0.0, newTrim, 0.0)
|
||||||
mom0 = -disp * xcb
|
mom0 = -disp * xcb
|
||||||
|
@ -261,22 +264,23 @@ def FloatingArea(ship, draft, trim):
|
||||||
minY = 0.0
|
minY = 0.0
|
||||||
|
|
||||||
shape = ship.Shape.copy()
|
shape = ship.Shape.copy()
|
||||||
shape.translate(Vector(0.0, 0.0, -draft))
|
shape.translate(Vector(0.0, 0.0, -draft * Units.Metre.Value))
|
||||||
shape.rotate(Vector(0.0, 0.0, 0.0), Vector(0.0, -1.0, 0.0), trim)
|
shape.rotate(Vector(0.0, 0.0, 0.0), Vector(0.0, -1.0, 0.0), trim)
|
||||||
|
|
||||||
bbox = shape.BoundBox
|
bbox = shape.BoundBox
|
||||||
xmin = bbox.XMin
|
xmin = bbox.XMin
|
||||||
xmax = bbox.XMax
|
xmax = bbox.XMax
|
||||||
|
|
||||||
# Create the "sea" box
|
# Create the "sea" box
|
||||||
L = xmax - xmin
|
L = xmax - xmin
|
||||||
B = bbox.YMax - bbox.YMin
|
B = bbox.YMax - bbox.YMin
|
||||||
p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0)
|
p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0)
|
||||||
box = Part.makeBox(3.0*L, 3.0*B, - bbox.ZMin + 1.0, p)
|
box = Part.makeBox(3.0*L, 3.0*B, - bbox.ZMin + 1.0, p)
|
||||||
|
|
||||||
maxX = bbox.XMin
|
maxX = bbox.XMin / Units.Metre.Value
|
||||||
minX = bbox.XMax
|
minX = bbox.XMax / Units.Metre.Value
|
||||||
maxY = bbox.YMin
|
maxY = bbox.YMin / Units.Metre.Value
|
||||||
minY = bbox.YMax
|
minY = bbox.YMax / Units.Metre.Value
|
||||||
for s in shape.Solids:
|
for s in shape.Solids:
|
||||||
try:
|
try:
|
||||||
common = box.common(s)
|
common = box.common(s)
|
||||||
|
@ -301,11 +305,11 @@ def FloatingArea(ship, draft, trim):
|
||||||
if abs(faceBounds.ZMax) > 0.00001:
|
if abs(faceBounds.ZMax) > 0.00001:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
area = area + f.Area
|
area = area + f.Area / Units.Metre.Value**2
|
||||||
maxX = max(maxX, faceBounds.XMax)
|
maxX = max(maxX, faceBounds.XMax / Units.Metre.Value)
|
||||||
minX = min(minX, faceBounds.XMin)
|
minX = min(minX, faceBounds.XMin / Units.Metre.Value)
|
||||||
maxY = max(maxY, faceBounds.YMax)
|
maxY = max(maxY, faceBounds.YMax / Units.Metre.Value)
|
||||||
minY = min(minY, faceBounds.YMin)
|
minY = min(minY, faceBounds.YMin / Units.Metre.Value)
|
||||||
App.ActiveDocument.removeObject(App.ActiveDocument.Objects[-1].Name)
|
App.ActiveDocument.removeObject(App.ActiveDocument.Objects[-1].Name)
|
||||||
|
|
||||||
dx = maxX - minX
|
dx = maxX - minX
|
||||||
|
@ -353,7 +357,7 @@ def mainFrameCoeff(ship, draft):
|
||||||
minY = 0.0
|
minY = 0.0
|
||||||
|
|
||||||
shape = ship.Shape.copy()
|
shape = ship.Shape.copy()
|
||||||
shape.translate(Vector(0.0, 0.0, -draft))
|
shape.translate(Vector(0.0, 0.0, -draft * Units.Metre.Value))
|
||||||
x = 0.0
|
x = 0.0
|
||||||
area = 0.0
|
area = 0.0
|
||||||
|
|
||||||
|
@ -367,8 +371,8 @@ def mainFrameCoeff(ship, draft):
|
||||||
p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0)
|
p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0)
|
||||||
box = Part.makeBox(1.5*L + x, 3.0*B, - bbox.ZMin + 1.0, p)
|
box = Part.makeBox(1.5*L + x, 3.0*B, - bbox.ZMin + 1.0, p)
|
||||||
|
|
||||||
maxY = bbox.YMin
|
maxY = bbox.YMin / Units.Metre.Value
|
||||||
minY = bbox.YMax
|
minY = bbox.YMax / Units.Metre.Value
|
||||||
for s in shape.Solids:
|
for s in shape.Solids:
|
||||||
try:
|
try:
|
||||||
common = box.common(s)
|
common = box.common(s)
|
||||||
|
@ -393,9 +397,9 @@ def mainFrameCoeff(ship, draft):
|
||||||
if abs(faceBounds.XMax - x) > 0.00001:
|
if abs(faceBounds.XMax - x) > 0.00001:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
area = area + f.Area
|
area = area + f.Area / Units.Metre.Value**2
|
||||||
maxY = max(maxY, faceBounds.YMax)
|
maxY = max(maxY, faceBounds.YMax / Units.Metre.Value)
|
||||||
minY = min(minY, faceBounds.YMin)
|
minY = min(minY, faceBounds.YMin / Units.Metre.Value)
|
||||||
App.ActiveDocument.removeObject(App.ActiveDocument.Objects[-1].Name)
|
App.ActiveDocument.removeObject(App.ActiveDocument.Objects[-1].Name)
|
||||||
|
|
||||||
dy = maxY - minY
|
dy = maxY - minY
|
||||||
|
|
Loading…
Reference in New Issue
Block a user