Coverage for navipy/trajectories/triangle.py : 63%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" """
""" A Triangle is defined by three apexes - apex 0 - apex 1 - apex 2
This class provides methods to calculate triangle properties when the \ apexes of a triangle are known """
('y' not in apex0.index) or \ ('z' not in apex0.index): raise IOError('apex0 ' + msg) ('y' not in apex1.index) or \ ('z' not in apex1.index): raise IOError('apex1 ' + msg) ('y' not in apex2.index) or \ ('z' not in apex2.index): raise IOError('apex2 ' + msg)
# The apexes are stored in a pandas dataframe columns=['apex0', 'apex1', 'apex2'], dtype=float)
if isinstance(clist, list): clist = np.array(clist) return clist
"""center of mass
:returns: center of mass of the triangle :rtype: pandas series
"""
"""apexes2vectors return a vector between each apexes the vector originating from apex a and going to apex b, \ can be access as (a,b), here a and b are the apex index. for example for the vector between apex0 and apex1, \ the tuple is (0,1)
:returns: return the vectors between edges :rtype: pandas multiindexed DataFrame
""" index=['x', 'y', 'z'], columns=pd.MultiIndex.from_tuples([(0, 1), (1, 2), (2, 0)]))
"""apexes2edges_norm return the edges norm.
the edges are accessed by a tuple (a,b), here a and b \ are the apex indeces. for example for the edge between apex0 and apex1, the \ tuple is (0,1)
:returns: return edges norm :rtype: pandas multindexed Series
"""
"""medians :returns: the point on the facing edge of an apex at which the median \ emanating from this apex cross the facing edge. :rtype: pd.dataframe """ columns=[0, 1, 2])
raise TypeError('frame should be a numpy array') raise TypeError('frame should have 2 dimensions') raise TypeError('frame should be a 3x4 or 4x4 matrix') [row.x, row.y, row.z, 1])[:3]
facecolor='k', edgecolor='k', alpha=1, apex_marker=None): vtx = np.zeros((3, 3)) vtx[:, 0] = self.apexes.apex0.values vtx[:, 1] = self.apexes.apex1.values vtx[:, 2] = self.apexes.apex2.values tri = a3.art3d.Poly3DCollection([vtx.transpose()]) tri.set_facecolor(facecolor) tri.set_edgecolor(edgecolor) tri.set_alpha(alpha) ax.add_collection3d(tri) if apex_marker is not None: for _, row in self.apexes.transpose().iterrows(): plt.plot([row.x], [row.y], [row.z], apex_marker) xlim = list(ax.get_xlim()) ylim = list(ax.get_ylim()) zlim = list(ax.get_zlim()) if min(xlim) < min(vtx[0, :]): xlim[0] = min(vtx[0, :]) if max(xlim) > max(vtx[0, :]): xlim[1] = max(vtx[0, :]) if min(ylim) < min(vtx[1, :]): ylim[0] = min(vtx[1, :]) if max(ylim) > max(vtx[1, :]): ylim[1] = max(vtx[1, :]) if min(zlim) < min(vtx[2, :]): zlim[0] = min(vtx[2, :]) if max(xlim) > max(vtx[2, :]): zlim[1] = max(vtx[2, :]) ax.set_xlim(xlim) ax.set_ylim(ylim) ax.set_zlim(zlim) |