File indexing completed on 2026-04-09 07:48:49
0001
0002 """
0003
0004 ::
0005
0006 ipython -i flight_plt.py RoundaboutXY
0007 ipython -i flight_plt.py RoundaboutXZ
0008 ipython -i flight_plt.py RoundaboutXY_XZ
0009
0010 """
0011 import os, sys, numpy as np
0012 from opticks.ana.makeflight import Flight
0013
0014 try:
0015 import pyvista as pv
0016 except ImportError:
0017 pv = None
0018 pass
0019
0020
0021 class PVPlot3D(object):
0022 def __init__(self, *args, **kwa):
0023 self.pl = pv.Plotter(*args, **kwa)
0024
0025 def add_grid(self):
0026 self.pl.show_grid()
0027
0028 def gaze_up_right_arrows(self, pos, gaze, up, rhs, mag=0.5):
0029 self.pl.add_arrows( pos, gaze, mag=mag*1.0, color='#FF0000', point_size=2.0 )
0030 self.pl.add_arrows( pos, up , mag=mag*0.50, color='#00FF00', point_size=2.0 )
0031 self.pl.add_arrows( pos, rhs , mag=mag*0.25, color='#0000FF', point_size=2.0 )
0032
0033 def mvp(self):
0034 """
0035 https://github.com/pyvista/pyvista-support/issues/85
0036
0037 TODO: try to project a 3D position onto the 2D screen plane
0038 so can place text using the 2d only add_text
0039 """
0040 vmtx = self.pl.camera.GetModelViewTransformMatrix()
0041 mtx = pv.trans_from_matrix(mtx)
0042 return mtx
0043
0044 def show(self):
0045 self.cp = self.pl.show()
0046 return self.cp
0047
0048
0049 if __name__ == '__main__':
0050
0051 name = sys.argv[1] if len(sys.argv) > 1 else "RoundaboutXY"
0052 f = Flight.Load(name)
0053
0054 pl = PVPlot3D()
0055
0056 pl.gaze_up_right_arrows( f.e3, f.g3, f.u3, f.r3, mag=0.5 )
0057 pl.add_grid()
0058 cp = pl.show()
0059 pass
0060