mahautils.shapes.CartesianPoint3D

class mahautils.shapes.CartesianPoint3D(*args: List[float] | Tuple[float, float, float] | ndarray | CartesianPoint3D | float, units: str | None = None, **kwargs)

Bases: Point

Class representing a point in 3D Cartesian coordinates

This class can be used to represent a point in the 3D Cartesian coordinate system. Note that although the axes for such a coordinate system can be arbitrary (\(xyz\)-coordinates, \(a_1 a_2 a_3\)-coordinates, etc.), in this class the axes are always referred to as \(x\), \(y\), and \(z\) for simplicity and clarity.

Notes

The equality operator (==) is defined for points. Points are considered equal if they are of the same type (Point, CartesianPoint3D, etc.), have coordinates attributes of the same shape and values, and have the same value of units.

Examples

Create a CartesianPoint3D with no location initialized:

>>> print(mahautils.shapes.CartesianPoint3D())
()

Create a CartesianPoint3D with location specified by positional arguments:

>>> print(mahautils.shapes.CartesianPoint3D(1, 2.3, 4))
(1.0, 2.3, 4.0)
>>> print(mahautils.shapes.CartesianPoint3D([4, 5, 6]))
(4.0, 5.0, 6.0)
>>> pnt = mahautils.shapes.CartesianPoint3D([6, 7, 8])
>>> print(mahautils.shapes.CartesianPoint3D(pnt))
(6.0, 7.0, 8.0)

Create a CartesianPoint3D with location specified by keyword arguments:

>>> print(mahautils.shapes.CartesianPoint3D(x=1, y=2, z=3))
(1.0, 2.0, 3.0)

Attributes

coordinates

The coordinates of the point, represented as a tuple (x, y, z)

x

The x-coordinate of the point

y

The y-coordinate of the point

z

The z-coordinate of the point

Methods

__init__(*args[, units])

Defines a point in the 3D Cartesian coordinate system

distance_to(point)

Computes the distance to another point

Inherited Attributes

units

The units in which the geometry is defined

__init__(*args: List[float] | Tuple[float, float, float] | ndarray | CartesianPoint3D | float, units: str | None = None, **kwargs)

Defines a point in the 3D Cartesian coordinate system

Creates a CartesianPoint3D instance and optionally allows the user to define the location of the point.

Parameters:
  • args (list or tuple or CartesianPoint3D or float, optional) – Positional arguments provided when creating the point object. See the “Notes” section for information on how to use positional arguments to specify the point location

  • units (str, optional) – The units in which the geometry is defined, or None to indicate dimensionless geometry or that units are to be ignored (default is None)

  • kwargs (Any, optional) – Keyword arguments provided when creating the point object. See the “Notes” section for information on how to use keyword arguments to specify the point location

Notes

When creating a CartesianPoint3D instance, it is possible to provide the point location using the constructor arguments. This location can be provided using either positional or keyword arguments, but not both.

If providing the location using positional arguments, then any of the following may be specified: (1) three floating-point numbers; (2) a list, tuple, NumPy array, or any other array-like object containing two floating-point numbers; or (3) another CartesianPoint3D instance.

If providing the location using keyword arguments, then three keyword arguments must be specified: x, y, and z. Both arguments must be numeric types (integer or floating-point values).

property coordinates

The coordinates of the point, represented as a tuple (x, y, z)

property units: str | None

The units in which the geometry is defined

property x

The x-coordinate of the point

property y

The y-coordinate of the point

property z

The z-coordinate of the point

distance_to(point: List[float] | Tuple[float, float, float] | ndarray | CartesianPoint3D)

Computes the distance to another point

Calculates and returns the distance to another point in the same 3D Cartesian coordinate system.

Parameters:

point (list or tuple or CartesianPoint3D) – The point to which to calculate distance

Returns:

The distance to another location point in 3D Cartesian space

Return type:

float