Vector2D#

class ansys.geometry.core.math.vector.Vector2D(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)#

Bases: numpy.ndarray

Provides for creating and managing a 2D vector.

Parameters:
inputndarray | RealSequence

2D numpy.ndarray class with shape(X,).

Overview#

from_points

Create a 2D vector from two distinct 2D points.

cross

Return the cross product of Vector2D objects.

is_perpendicular_to

Check if this 2D vector and another 2D vector are perpendicular.

is_parallel_to

Check if this vector and another vector are parallel.

is_opposite

Check if this vector and another vector are opposite.

normalize

Return a normalized version of the 2D vector.

get_angle_between

Get the angle between this 2D vector and another 2D vector.

x

X coordinate of the 2D vector.

y

Y coordinate of the 2D vector.

norm

Norm of the 2D vector.

magnitude

Norm of the 2D vector.

is_zero

Check if values for all components of the 2D vector are zero.

__eq__

Equals operator for the Vector2D class.

__ne__

Not equals operator for the Vector2D class.

__mul__

Overload * operator with dot product.

__add__

Addition operation overload for 2D vectors.

__sub__

Subtraction operation overload for 2D vectors.

__mod__

Overload % operator with cross product.

Import detail#

from ansys.geometry.core.math.vector import Vector2D

Property detail#

property Vector2D.x: ansys.geometry.core.typing.Real#

X coordinate of the 2D vector.

property Vector2D.y: ansys.geometry.core.typing.Real#

Y coordinate of the 2D vector.

property Vector2D.norm: float#

Norm of the 2D vector.

property Vector2D.magnitude: float#

Norm of the 2D vector.

property Vector2D.is_zero: bool#

Check if values for all components of the 2D vector are zero.

Method detail#

Vector2D.cross(v: Vector2D) ansys.geometry.core.typing.Real#

Return the cross product of Vector2D objects.

Vector2D.is_perpendicular_to(other_vector: Vector2D) bool#

Check if this 2D vector and another 2D vector are perpendicular.

Vector2D.is_parallel_to(other_vector: Vector2D) bool#

Check if this vector and another vector are parallel.

Vector2D.is_opposite(other_vector: Vector2D) bool#

Check if this vector and another vector are opposite.

Vector2D.normalize() Vector2D#

Return a normalized version of the 2D vector.

Vector2D.get_angle_between(v: Vector2D) pint.Quantity#

Get the angle between this 2D vector and another 2D vector.

Parameters:
vVector2D

Other 2D vector to compute the angle with.

Returns:
Quantity

Angle between these two 2D vectors.

Vector2D.__eq__(other: Vector2D) bool#

Equals operator for the Vector2D class.

Vector2D.__ne__(other: Vector2D) bool#

Not equals operator for the Vector2D class.

Vector2D.__mul__(other: Vector2D | ansys.geometry.core.typing.Real) Vector2D | ansys.geometry.core.typing.Real#

Overload * operator with dot product.

Notes

This method also admits scalar multiplication.

Vector2D.__add__(other: Vector2D | ansys.geometry.core.math.point.Point2D) Vector2D | ansys.geometry.core.math.point.Point2D#

Addition operation overload for 2D vectors.

Vector2D.__sub__(other: Vector2D) Vector2D#

Subtraction operation overload for 2D vectors.

Vector2D.__mod__(other: Vector2D) ansys.geometry.core.typing.Real#

Overload % operator with cross product.

classmethod Vector2D.from_points(point_a: numpy.ndarray | ansys.geometry.core.typing.RealSequence | ansys.geometry.core.math.point.Point2D, point_b: numpy.ndarray | ansys.geometry.core.typing.RealSequence | ansys.geometry.core.math.point.Point2D)#

Create a 2D vector from two distinct 2D points.

Parameters:
point_andarray | RealSequence | Point2D

Point2D class representing the first point.

point_bndarray | RealSequence | Point2D

Point2D class representing the second point.

Returns:
Vector2D

2D vector from point_a to point_b.

Notes

The resulting 2D vector is always expressed in Point2D base units.