Skip to content

Commit

Permalink
Handle AAM scenario cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gedeschaines committed Dec 26, 2023
1 parent c1149ab commit d46771c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 24 deletions.
6 changes: 3 additions & 3 deletions clipLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

mxvcnt = 32 # maximum vertices in clipped polygon
zmin = 0.1 # minimum z clipping distance
zmax = 10000.0 # maximum z clipping distance
zmax = 20000.0 # maximum z clipping distance


def edgeCode(edge, a_pt):
"""
Calculates edge code for given pyramidal frustum edge and
polygon vertex point.
"""

# Load point into viewing pyramid space.

x = a_pt.Y
Expand Down Expand Up @@ -180,7 +180,7 @@ def polyClip(pcnt, vcnt, vlist):
"""
Clips given polygon to 3D viewing pyramidal frustum.
"""

while True:
# Check all polygon points against each frustum edge.
pcntp1 = pcnt + 1
Expand Down
2 changes: 1 addition & 1 deletion dat/grndpoly.dat → dat/grndpoly1.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0.00 0.00 0.00 1.00 Ground Plane - 10000x10000
0.00 0.00 0.00 5.00 Ground Plane - 10000x10000
4 5 7 0 1.0 Ground Plane
5000.00 -5000.00 0.00
5000.00 5000.00 0.00
Expand Down
7 changes: 7 additions & 0 deletions dat/grndpoly2.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
6000.00 -6000.00 0.00 5.00 Ground Plane - 30000x30000
4 5 7 0 1.0 Ground Plane
6000.00 -6000.00 0.00
6000.00 6000.00 0.00
-6000.00 6000.00 0.00
-6000.00 -6000.00 0.00
0.00 0.00 0.00
54 changes: 37 additions & 17 deletions draw3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,13 @@ def __init__(self, k, flg=False, pri=0, typ=0, cnt0=Pnt3D(), cnt1=Pnt3D(), pat=0

class Draw3D:

def __init__(self, txyzFile="TXYZ.OUT", w=600, h=600,
def __init__(self, txyzFile="TXYZ.OUT", mslType=1, w=600, h=600,
fig=None, ax=None, imgSave=False, imgFPS=50):

# TXYZ file information.

self.txyzFile = txyzFile
self.mslType = mslType
self.lfnt = None

# FOV information.
Expand Down Expand Up @@ -181,7 +182,7 @@ def __init__(self, txyzFile="TXYZ.OUT", w=600, h=600,
(self.xMax, self.yMax))
print("Draw3D.__init__: fovcx,fovcy = %f %f" % \
(self.fovcx, self.fovcy))

# Compute viewport FOV focal length and scale factors.

self.zoom = fOne
Expand Down Expand Up @@ -425,20 +426,36 @@ def XfrmGrid(self):
"""
Transforms grid world space coordinates to viewport coordinates.
"""

self.GridPt1[0].X = 2000.0
self.GridPt1[0].Y = -2000.0
self.GridPt1[0].Z = 0.0
self.GridPt1[1].X = 2000.0
self.GridPt1[1].Y = 2000.0
self.GridPt1[1].Z = 0.0
self.GridPt1[2].X = -2000.0
self.GridPt1[2].Y = 2000.0
self.GridPt1[2].Z = 0.0
self.GridPt1[3].X = -2000.0
self.GridPt1[3].Y = -2000.0
self.GridPt1[3].Z = 0.0


if self.mslType == 1:
# SAM engagement scenario case
self.GridPt1[0].X = 2000.0
self.GridPt1[0].Y = -2000.0
self.GridPt1[0].Z = 0.0
self.GridPt1[1].X = 2000.0
self.GridPt1[1].Y = 2000.0
self.GridPt1[1].Z = 0.0
self.GridPt1[2].X = -2000.0
self.GridPt1[2].Y = 2000.0
self.GridPt1[2].Z = 0.0
self.GridPt1[3].X = -2000.0
self.GridPt1[3].Y = -2000.0
self.GridPt1[3].Z = 0.0
else:
# AAM engagement scenario case
self.GridPt1[0].X = 20000.0
self.GridPt1[0].Y = -16000.0
self.GridPt1[0].Z = 0.0
self.GridPt1[1].X = 20000.0
self.GridPt1[1].Y = 4000.0
self.GridPt1[1].Z = 0.0
self.GridPt1[2].X = 0.0
self.GridPt1[2].Y = 4000.0
self.GridPt1[2].Z = 0.0
self.GridPt1[3].X = 0.0
self.GridPt1[3].Y = -16000.0
self.GridPt1[3].Z = 0.0

for k in range(0,4):
# Translate coordinates into viewport FOV reference frame.
xd = self.GridPt1[k].X - self.fovpt.X
Expand Down Expand Up @@ -910,7 +927,10 @@ def ReadPolyData(self):

self.polcnt = 0

lfni = open("./dat/grndpoly.dat", "rt")
if self.mslType == 1:
lfni = open("./dat/grndpoly1.dat", "rt")
else:
lfni = open("./dat/grndpoly2.dat", "rt")
if lfni is not None:
if DBG_LVL > 0:
print("Draw3D: Loading polygons from file %s" % \
Expand Down
3 changes: 2 additions & 1 deletion pyThreeD.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@
"source": [
"# Instantiate a Draw3D object.\n",
"\n",
"draw3D = Draw3D(txyzFile=File, w=w, h=h, fig=fig, ax=ax, \n",
"msltyp = int(CaseId)//1000\n",
"draw3D = Draw3D(txyzFile=File, mslType=msltyp, w=w, h=h, fig=fig, ax=ax, \n",
" imgSave=img_Save, imgFPS=img_FPS)\n",
"\n",
"# Load object shape polygon data.\n",
Expand Down
5 changes: 3 additions & 2 deletions pyThreeD.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def onClick(event):

File = "./out/TXYZ.OUT." + CaseId
title = "pyThreeD - " + File

# Instantiate a matplotlib pyplot figure.

#fig = plt.figure(figsize=(6.0,6.0), dpi=100.0) # 465x462 viewport
Expand Down Expand Up @@ -120,7 +120,8 @@ def onClick(event):

# Instantiate a Draw3D object.

draw3D = Draw3D(txyzFile=File, w=w, h=h, fig=fig, ax=ax,
msltyp = int(CaseId)//1000
draw3D = Draw3D(txyzFile=File, mslType=msltyp, w=w, h=h, fig=fig, ax=ax,
imgSave=img_Save, imgFPS=img_FPS)

# Load object shape polygon data.
Expand Down

0 comments on commit d46771c

Please sign in to comment.