aim2dat.utils.maths

Module that contains custom mathematical functions.

Module Contents

Functions

calc_angle(vector1, vector2)

Calculate the angle between two vectors.

calc_circular_segment_area(radius, distance)

Calculate the circular segment.

calc_plane_equation(point1, point2, point3)

Calculate the plane from 3 given points in the form a*x + b*y + c*z = d.

calc_polygon_area(vertices)

Calculate the area of a polygon.

calc_reflection_matrix(n_vector)

Calculate the 3d reflection matrix normal to the input vector.

calc_solid_angle(center, points)

Calculate the solid angle between a center point and points that span a polyhedron.

create_lin_ind_vector(vector)

Create linearly independent vector with reference to the input vector.

gaussian_function(x, mu, sigma)

Calculate the Gaussian function with a certain sigma-value.

aim2dat.utils.maths.calc_angle(vector1, vector2)[source]

Calculate the angle between two vectors.

Parameters:
  • vector1 (list) – List containing three numbers.

  • vector2 (list) – List containing three numbers.

Returns:

angle (float) – Angle in radian.

aim2dat.utils.maths.calc_circular_segment_area(radius, distance)[source]

Calculate the circular segment.

See: https://en.wikipedia.org/wiki/Circular_segment.

Parameters:
  • radius (float) – Radius of the circle.

  • distance (float) – Distance of the segment from the circle center.

Returns:

segment_area (float) – Area of the segment.

aim2dat.utils.maths.calc_plane_equation(point1, point2, point3)[source]

Calculate the plane from 3 given points in the form a*x + b*y + c*z = d.

Parameters:
  • point1 (list or np.array) – Point in 3-dimensional space.

  • point2 (list or np.array) – Point in 3-dimensional space.

  • point3 (list or np.array) – Point in 3-dimensional space.

Returns:

  • a (float) – plane parameter.

  • b (float) – plane parameter.

  • c (float) – plane parameter.

  • d (float) – plane parameter.

aim2dat.utils.maths.calc_polygon_area(vertices)[source]

Calculate the area of a polygon.

Parameters:

vertices (list or np.array) – (n x 3) list of the vertices.

Returns:

area (float) – Area of the polygon.

aim2dat.utils.maths.calc_reflection_matrix(n_vector)[source]

Calculate the 3d reflection matrix normal to the input vector.

Parameters:

n_vector (list or np.array) – Normal vector of the reflection plane.

Returns:

np.array – Reflection matrix.

aim2dat.utils.maths.calc_solid_angle(center, points)[source]

Calculate the solid angle between a center point and points that span a polyhedron.

Parameters:
  • center (list) – Center point.

  • points (list) – Nested list of points.

Returns:

solid_angle (float) – Solid angle of the polyhedron.

aim2dat.utils.maths.create_lin_ind_vector(vector)[source]

Create linearly independent vector with reference to the input vector. The method adds one to the first element of the vector which is zero. In case all elements are non-zero, one is added to the first element of the vector.

Parameters:

vector (list, tuple or np.array) – Input vector

Returns:

np.array – Linearly independent vector.

aim2dat.utils.maths.gaussian_function(x, mu, sigma)[source]

Calculate the Gaussian function with a certain sigma-value.

Parameters:
  • x (float) – x value for which the y value is calculated.

  • mu (float) – Expected value.

  • sigma (float) – Variance.

Returns:

y (float) – y value.