geometry¶
Function summary¶
eqn_of_plane (pts) |
Equation of plane defined by polygon points |
integrate_f_over_polygon_code (f) |
Generate code that will integrate a function over a polygon |
integrate_f_over_polyhedra_code (f) |
Generate code that will integrate a function over a polyhedra |
make_hexahedron (coords) |
Assemble the face vertices of a hexahedron |
polygon_2nd_moment_of_area (pts) |
2nd moment of area of polygon defined by points |
polygon_area (pts) |
Area of polygon defined by points |
polygon_centroid (pts) |
Centroid of polygon defined by points |
polyhedron_volume (faces) |
Volume of polyhedron defined by faces defined py pts |
replace_x0_and_x1_with_vect (s[, xyz]) |
Replaces strings x0 with x[:-1], x1 with x[1:], y0 with y[:-1] ... |
xyz_from_pts (pts[, close_polygon]) |
Extract x, y and z values from an (n, 3) or (n, 2) shaped array |
Module listing¶
Some routines loosely related to geometry.
-
geotecha.mathematics.geometry.
eqn_of_plane
(pts)[source]¶ Equation of plane defined by polygon points
a, b, c, d from a*x+b*y+c*z+d = 0 Looking at the plane, counter-clockwise (CCW) points the positive normal is towards you. For clockwise points (CW) the positive normal is away from you.
Parameters: pts : array_like
aAray of x, y or x, y, z points.
Returns: [a, b, c] : ndarray with 3 elements
Direction cosines of normal to plane.
d : float
Constant in plane equation.
-
geotecha.mathematics.geometry.
integrate_f_over_polygon_code
(f)[source]¶ Generate code that will integrate a function over a polygon
Parameters: f : sympy expression
Expression to be integrated over the polygon.
Returns: out : str
Multiline string of function code
-
geotecha.mathematics.geometry.
integrate_f_over_polyhedra_code
(f)[source]¶ Generate code that will integrate a function over a polyhedra
Parameters: f : sympy expression
Expression to be integrated over the polyhedron.
Returns: out : str
Multiline string of funciton code.
-
geotecha.mathematics.geometry.
make_hexahedron
(coords)[source]¶ Assemble the face vertices of a hexahedron
Parameters: coords : 8 by 3 ndarray
x, y, z coords of 8 corner nodes of hexahedron. node numbering is as per Smith and Grifiths.
Returns: faces : list of pts arrays
List of pts arrays. Each list defines vertices of a face.
Notes
Node numbering:
x (6)-------(7) ^ / /| | y / / | | / / / | |/ (2)-------(3) (8) |-------->x | | / | | / | | / (1)-------(4)
-
geotecha.mathematics.geometry.
polygon_2nd_moment_of_area
(pts)[source]¶ 2nd moment of area of polygon defined by points
Parameters: pts : array_like
Array of x, y or x, y, z points.
Returns: [Ixx, Iyy, Izz] : ndarray of float
2nd moment of area about centroidal x, y, and z axes.
-
geotecha.mathematics.geometry.
polygon_area
(pts)[source]¶ Area of polygon defined by points
Parameters: pts : array_like
Array of x, y or x, y, z points.
Returns: a : float
Area of polygon.
-
geotecha.mathematics.geometry.
polygon_centroid
(pts)[source]¶ Centroid of polygon defined by points
Parameters: pts : array_like
Array of x, y or x, y, z points.
Returns: [xc, yc, zc] : ndarray of float
Coordinates of centroid.
-
geotecha.mathematics.geometry.
polyhedron_volume
(faces)[source]¶ Volume of polyhedron defined by faces defined py pts
Parameters: faces : list
A list of pts arrays defining x,y,z coords of face vertices.
Returns: v : float
Volume of polyhedron.
Notes
I think points on a face have to be defined in anti clockwise (CCW) order to give a positive volume. No checks are done to check the order.
-
geotecha.mathematics.geometry.
replace_x0_and_x1_with_vect
(s, xyz=['x', 'y', 'z'])[source]¶ Replaces strings x0 with x[:-1], x1 with x[1:], y0 with y[:-1] ...
Parameters: s : string, or sympy_expression
Expression to make replacements on
xyz : list of strings
Replacements will be made for each element of xyz. default xyz=[‘x’,’y’,’z’].
Returns: out : string
string with all replacements made
-
geotecha.mathematics.geometry.
xyz_from_pts
(pts, close_polygon=False)[source]¶ Extract x, y and z values from an (n, 3) or (n, 2) shaped array
Parameters: pts : array_like
Array of x, y or x, y, z points.
close_polygon : boolean, optional
If True then 1st point will be repeated i.e. to close the polygon. Default close_polygon=False.
Returns: x, y, z : 1d ndarrays
1d array of x coords, y coords, z coords.