Module gonioanalysis.coordinates
Working in 3D space
Functions
def camera2Fly(horizontal, vertical, radius=1)
-
With the given goniometer positions, calculates camera's position in fly's cartesian coordinate system.
Input in degrees
def camera_rotation(horizontal, vertical, return_degrees=False)
-
Camera's rotation
def camvec2Fly(imx, imy, horizontal, vertical, radius=1, normalize=False)
-
Returns 3D vector endpoints.
normalize If true, return unit length vectors
def distance(a, b)
-
Calculates distance between two points in 3D cartesian space. a,b (x,y,z)
def force_to_tplane(P0, P1, radius=1)
-
Forces a vector (P0-P1) on a tangent plane of a sphere but retaining the vector's length
P0 is the point on the sphere (and the tangent plane) P1 is the point off the tangent plane
Returns P2, point on the tangent plane and the line connecting the sphere centre point to the P1.
Notice DOES NOT RETURN VEC BUT P2 (vec=P2-P0)
def get_rotation_matrix(axis, rot)
-
Returns an elementar rotation matrix.
axis 'x', 'y', or 'z' rot rotation in radians
def mean_vector(point, vectors)
-
Average vectors and return a vector at point point.
def nearest_neighbour(point_A, points_B, max_distance=None)
-
Return the nearest point to the point_A from points_B.
point_A 1D np.array [x0, y0, z0] points_B 2D np.array [ [x1,y1,z1], [z2,y2,z2], … ]
def normalize(P0, P1, scale=1)
-
Normalize a vector
P0 Vector start point P1 Vector end point
def optimal_sampling(horizontals, verticals)
-
Determine optimal way to sample using two orthogonal goniometers.
def rotate_about_x(point, degs)
-
Rotate a point in 3D space along the first axis (x-axis).
def rotate_along_arbitrary(P1, points, rot)
-
Rotate along arbitrary axis.
P0 is at origin.
P0 and P1 specify the rotation axis
Implemented from here: http://paulbourke.net/geometry/rotate/
Arguments
P1
:np.ndarray
points
:np.ndarray
rot
:float
orint
- Rotation in radians (not degres!)
def rotate_points(points, yaw, pitch, roll)
-
Just as rotate_vectors but only for points.
Arguments
yaw
,pitch
,roll
:float
orint
- Rotations in radians (not degrees!)
def rotate_vectors(points, vectors, yaw, pitch, roll)
-
In the beginning, it is assumed that yaw rotation along Z pitch rotation along X roll rotation along Y
ie that the fly head is at zero rotation, antenna roots pointing towards positive y-axis.
def test1_camera_rotation()
def test2_camera_rotation()
def test_camvec2Fly()
def test_imx()
def test_rotate_vectors()
def to_spherical(x, y, z, return_degrees=False)
-
Transform to spherical coordinates (ISO)
return_degrees If true, return angles in degrees instead of radians
Returns: r, phi, theta
def where_vertical_between(points_3d, lower=None, upper=None, reverse=False)
-
'Returns a boolean array based on points' vertical angle.
Takes in 3D points and returns an 1D True/False array of length points_3d
Arguments
points_3d
:sequence
- A sequence of (x,y,z) points
lower
:float
- Lower vertical angle degree in degrees
upper
:float
reverse
:bool
- If True, inverses the returned array (True -> False and vice versa).
Returns
booleans
:ndarray
- 1D True/False array