15 from plume
import Plume
17 from tf.transformations
import quaternion_matrix
21 """Plume model to generate a static plume with spheroid form. 25 def __init__(self, a, c, orientation, source_pos, n_points, start_time):
26 """Spheroid plume class constructor. 30 * `a` and `c` (*type:* `float`): length of the ellipsoid's principal 32 * `orientation` (*type:* `list`): quaternion describing the orientation 34 * `n_points` (*type:* `int`): maximum number of plume particles 35 * `start_time` (*type:* `float`): time stamp for the creation of 38 Plume.__init__(self, source_pos, n_points, start_time)
40 assert a > 0
and c > 0,
'The length of the principal axes must be ' \
42 assert orientation.size == 4,
'Orientation vector must be a quaternion' 51 """Update the position of all particles and create/remove particles from 52 the plume according to the bounding box limit constraints and the 53 maximum number of particles allowed. 57 * `t` (*type: `float`): current time stamp in seconds 61 `True` if update was succesful, `False` if computed time step is invalid. 63 if self.
_pnts is not None:
67 theta_range = np.linspace(-np.pi / 2, np.pi / 2, self._n_points)
68 phi_range = np.linspace(-np.pi, np.pi, self._n_points)
70 theta, phi = np.meshgrid(theta_range, phi_range)
73 (self.
_a * np.multiply(np.cos(theta.flatten()),
74 np.cos(phi.flatten())),
75 self.
_a * np.multiply(np.cos(theta.flatten()),
76 np.sin(phi.flatten())),
77 self.
_c * np.sin(theta.flatten()))).T
84 rot_matrix = quaternion_matrix(self.
_rot)[0:3, 0:3]
85 for t, p
in zip(theta.flatten(), phi.flatten()):
86 vec = [self.
_a * np.cos(t) * np.cos(p),
87 self.
_a * np.cos(t) * np.sin(p),
89 vec = np.dot(rot_matrix, vec)
90 if self.
_pnts is None:
91 self.
_pnts = np.array(vec)
96 for i
in range(len(self._source_pos)):
97 self.
_pnts[:, i] += self._source_pos[i]
99 self.apply_constraints()
def __init__(self, a, c, orientation, source_pos, n_points, start_time)