@@ -36,6 +36,14 @@ def vector_dist(v1, v2) -> float:
3636 """Euclidean distance between two vectors"""
3737 return vo .distance (v1 ,v2 )
3838
39+ def vector_dot (v1 , v2 ) -> float :
40+ """Dot product between two vectors"""
41+ return vo .dot (v1 ,v2 )
42+
43+ def vector_cross (v1 , v2 ) -> float :
44+ """Cross product between two 2D vectors"""
45+ return vo .cross (v1 ,v2 )
46+
3947def vector2_angle (v1 , v2 = None ) -> float :
4048 """find the ccw angle bewtween two 2d vectors"""
4149 if v2 is None :
@@ -123,3 +131,16 @@ def xy_to_lat_lon(x_east : float, y_north : float, lat_reference : float, lon_re
123131 # convert GNSS waypoints into local fixed frame reprented in x and y
124132 lat , lon = axy .xy2ll (x_east , y_north , lat_reference , lon_reference )
125133 return lat , lon
134+
135+ def quaternion_to_euler (x : float , y : float , z : float , w : float ):
136+ t0 = + 2.0 * (w * x + y * z )
137+ t1 = + 1.0 - 2.0 * (x * x + y * y )
138+ roll = np .arctan2 (t0 , t1 )
139+ t2 = + 2.0 * (w * y - z * x )
140+ t2 = + 1.0 if t2 > + 1.0 else t2
141+ t2 = - 1.0 if t2 < - 1.0 else t2
142+ pitch = np .arcsin (t2 )
143+ t3 = + 2.0 * (w * z + x * y )
144+ t4 = + 1.0 - 2.0 * (y * y + z * z )
145+ yaw = np .arctan2 (t3 , t4 )
146+ return [roll , pitch , yaw ]
0 commit comments