resqpy.olio.vector_utilitiesΒΆ
Utilities for working with 3D vectors in cartesian space.
note: some of these functions are redundant as they are provided by builtin numpy operations.
a vector is a one dimensional numpy array with 3 elements: x, y, z. some functions accept a tuple or list of 3 elements as an alternative to a numpy array.
Functions
Returns vector sum a+b. 

Returns vector with direction of v, amplified by scaling. 

Returns the area of the triangle defined by three vertices. 

Returns numpy array of areas of triangles, optionally when projected onto xy plane. 

Returns the compass bearing in degrees of the direction of v (x = East, y = North), ignoring z. 

Returns the compass bearings in degrees of the direction of each vector in va (x = East, y = North), ignoring z. 

Returns a +ve value if 2D points a,b,c are in clockwise order, 0.0 if in line, ve for ccw. 

Returns a clockwise sorted numpy list of indices b into the points p. 

Returns a numpy array of +ve values where triangle points are in clockwise order, 0.0 if in line, ve for ccw. 

Returns the cross product (vector product) of the two vectors. 

Returns the angle between two vectors, in degrees. 

Converts angle from radians to degrees. 

Returns the determinant of the 3 x 3 matrix comprised of the 3 vectors. 

Returns the determinant of the 3 x 3 matrix. 

Returns the dot product (scalar product) of the two vectors. 

Returns the dot products of pairs of vectors; last axis covers element of a vector. 

Returns vector with products of corresponding elements of a and b. 

Returns True if point d lies within the circumcircle pf ccw points a, b, c, projected onto xy plane. 

Returns True if point d lies wholly within the triangle pf ccw points a, b, c, projected onto xy plane. 

Returns True if d lies within or on the boudnary of triangle of ccw points a,b,c projected onto xy plane. 

Returns the inclination in degrees of v (angle relative to +ve z axis). 

Returns the inclination in degrees of each vector in a (angle relative to +ve z axis). 

Returns True if the two points are extremely close to one another (ie. 

Returns True if the angle at point p subtended by points p1 and p2, in xy plane, is greater than 90 degrees; else False. 

Returns True if the two points are extremely close to one another (ie. 

Returns the Manhattan distance between two points. 

Returns the Manhattan distance between two points. 

Calculates which implicit mesh points are within a triangle in 2D for normalised triangle. 

Returns coordinate matrices from coordinate vectors x and y. 

Returns the length of the vector projected onto xy plane, assuming consistent units. 

Returns the lengths of the vectors projected onto xy plane, assuming consistent units. 

Returns the length of the vector assuming consistent units. 

Returns the lengths of the vectors assuming consistent units. 

Returns the inclination in degrees of each vector in a (angle relative to +ve z axis), allowing NaNs. 

Returns vectors with same direction as those in v but with unit length, allowing NaNs. 

Returns the index into points array closest to point p; projection is 'xy', 'xz' or 'yz'. 

Returns a rotation matrix which will not move points (identity matrix). 

Returns a version of vector with a perspective applied. 

Returns an array of projected distances squared between p and points; projection is 'xy', 'xz' or 'yz'. 

Ignoring any z values, returns the xy distance of point p from line passing through l1 and l2. 

Ignoring any z values, returns the xy distance of point p from line segment between l1 and l2. 

Calculates if a point in within a polygon in 2D. 

Calculates if a point in within a triangle in 2D. 

Returns an average direction vector based on first and last nonNaN points or slices in given axis. 

Calculates which points are within a polygon in 2D. 

Calculates which points are within which polygons in 2D. 

Calculates which points are within a triangle in 2D. 

Returns 2D numpy bool array indicating which of points da are within which triangles. 

Calculates which points are within which triangles in 2D for a regular mesh of aligned points. 

Calculates which points are within which triangles in 2D for a regular mesh of aligned points. 

Calculates which points are within which triangles in 2D. 

Modifies array of xyz points in situ to project onto a plane defined by a point and normal vector. 

Returns the angle between two vectors, in radians. 

Converts angle from degrees to radians. 

Returns a rotation matrix which will rotate points about the y, z, then x axis by angles in degrees. 

Returns a copy of array a with each vector rotated by the rotation matrix. 

Returns a copy of array a with each vector rotated by the rotation matrix. 

Returns the rotated vector. 

Returns a copy of array a suitable for presenting a crosssection using the resulting x,z values. 

Returns a rotation matrix which will rotate points about the x, z, then y axis by angles in degrees. 

Returns a rotation matrix which will rotate points about the x, z, then y axis by angles in degrees. 

Returns a rotation matrix which will rotate points about axis (0: x, 1: y, or 2: z) by angle in degrees. 

Returns a rotation matrix which will rotate vector v to the vertical (z) axis. 

Returns a rotation matrix which will rotate points by inclination and azimuth of vector. 

Returns vector difference ab. 

Returns a 3D rotation matrix for applying a dip in a certain azimuth. 

Modifies array of xyz points in situ to apply dip in direction of azimuth, about pivot point. 

Finds the minimum and maximum x and y values of a single traingle. 

For a triangle in 3D space, defined by 3 vertex points, returns a unit vector normal to the plane of the triangle. 

For a triangle in 3D space, defined by 3 vertex points, returns a unit vector normal to the plane of the triangle. 

Returns the length of the vector v after applying the unit_conversion factors. 

Returns vector with same direction as v but with unit length. 

Returns horizontal unit vector in compass bearing given by azimuth (x = East, y = North). 

Returns unit vector with compass bearing of azimuth and inclination off +z axis. 

Returns vector with same direction as v but with unit length. 

Returns vectors with same direction as those in v but with unit length. 

Returns a 3D vector for a 2D or 3D vector. 

Finds the y value of a straight line between two points at a given x. 

Returns copy of points p sorted according to x or y (whichever has greater range). 

Returns copy of points p sorted according to x or y (whichever has greater range). 

Returns a zero vector [0.0, 0.0, 0.0]. 