Points/Vectors
Important
Vectors can be implicitly created from tuple, list and
numpy.ndarray objects, as long as the number of elements matches
the dimensionality of the vector.
A 2D vector of |
|
A 3D vector of |
|
A 2D vector of |
|
A 3D vector of |
Integral 2D: Vec2i
- class viren2d.Vec2i
A 2D vector of
intcoordinates.Corresponding C++ API:
viren2d::Vec2i.Methods:
Overloaded function.
Checks for equality.
Allows accessing this vector's values via
vec[i].Overloaded function.
Overloaded function.
Overloaded function.
Checks for inequality.
Returns a
Vec2d, where all values are negated.Allows accessing this vector's values via
vec[idx].Vec2dinstances can be pickled.Overloaded function.
Overloaded function.
Creates a vector where each coordinate is set to the given scalar.
Computes the angle \(\in [0, 180]\) between this and the other vector.
Computes the angle \(\in [0, \pi]\) between this and the other vector.
Returns a
Vec2ias the result of explicitly casting the values.Returns a copy of this vector as
Vec2iReturns a deep copy.
Returns the
Vec2idirection vector,other - self.Returns the Manhattan distance between
selfand the otherVec2i.Returns the Euclidean distance between
selfand the otherVec2i.Returns the dot product of
selfand the otherVec2i.Returns the homogeneous representation of this vector, i.e. a 3-element tuple, where the additional dimension is set to 1.
Returns the length of this vector.
Returns this vector's squared length.
Returns \(i = \arg_i \max(v_i)\).
Returns \(\max(v_i)\).
Returns \(i = \arg_i \min(v_i)\).
Returns \(\min(v_i)\).
Returns the 90° counterclockwise rotated vector.
Returns the 90° clockwise rotated vector.
Returns the corresponding unit vector as
Vec2d.Attributes:
Underlying data type (read-only).
Provides alternative read-write access to the second dimension, (i.e.
y).Number of dimensions (read-only), i.e. 2.
Provides alternative read-write access to the first dimension, (i.e.
x).Read-write access to the first dimension, i.e. same as
vec[0].Read-write access to the second dimension, i.e. same as
vec[1].- __add__(*args, **kwargs)
Overloaded function.
__add__(self: viren2d.Vec2i, scalar: int) -> viren2d.Vec2i
Element-wise addition:
Vec2i=Vec2i+int.__add__(self: viren2d.Vec2i, rhs: viren2d.Vec2i) -> viren2d.Vec2i
- __eq__(self: viren2d.Vec2i, other: viren2d.Vec2i) bool
Checks for equality.
- __getitem__(self: viren2d.Vec2i, arg0: int) int
Allows accessing this vector’s values via
vec[i].
- __getstate__(self: viren2d.Vec2i) tuple
- __iadd__(*args, **kwargs)
Overloaded function.
__iadd__(self: viren2d.Vec2i, rhs: int) -> viren2d.Vec2i
In-place element-wise addition:
Vec2i+=int.__iadd__(self: viren2d.Vec2i, rhs: viren2d.Vec2i) -> viren2d.Vec2i
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: viren2d.Vec2i) -> None
Initializes all values to 0.
__init__(self: viren2d.Vec2i, vec: viren2d.Vec2i) -> None
Creates a copy of the given
Vec2i.__init__(self: viren2d.Vec2i, tpl: tuple) -> None
Creates a vector from a 2-element
tuple.__init__(self: viren2d.Vec2i, lst: list) -> None
Creates a vector from a 2-element
list.__init__(self: viren2d.Vec2i, arr: numpy.ndarray) -> None
Creates a vector from a 2-element
numpy.array.__init__(self: viren2d.Vec2i, x: int, y: int) -> None
Explicit initialization from 2 separate values.
- __mul__(*args, **kwargs)
Overloaded function.
__mul__(self: viren2d.Vec2i, rhs: int) -> viren2d.Vec2i
Element-wise multiplication:
Vec2i=Vec2i*int.__mul__(self: viren2d.Vec2i, rhs: viren2d.Vec2i) -> viren2d.Vec2i
- __ne__(self: viren2d.Vec2i, other: viren2d.Vec2i) bool
Checks for inequality.
- __neg__(self: viren2d.Vec2i) viren2d.Vec2i
Returns a
Vec2d, where all values are negated.
- __rmul__(self: viren2d.Vec2i, lhs: int) viren2d.Vec2i
- __setitem__(self: viren2d.Vec2i, arg0: int, arg1: int) None
Allows accessing this vector’s values via
vec[idx].
- __setstate__(self: viren2d.Vec2i, arg0: tuple) None
Vec2dinstances can be pickled.
- __sub__(*args, **kwargs)
Overloaded function.
__sub__(self: viren2d.Vec2i, rhs: int) -> viren2d.Vec2i
Element-wise subtraction:
Vec2i=Vec2i-int.__sub__(self: viren2d.Vec2i, rhs: viren2d.Vec2i) -> viren2d.Vec2i
- __truediv__(*args, **kwargs)
Overloaded function.
__truediv__(self: viren2d.Vec2i, rhs: int) -> viren2d.Vec2d
Element-wise division with implicit type conversion. Returns a double-precision
Vec2d=Vec2i/int.__truediv__(self: viren2d.Vec2i, rhs: float) -> viren2d.Vec2d
Element-wise division with implicit type conversion. Returns a double-precision
Vec2d=Vec2i/float.__truediv__(self: viren2d.Vec2i, rhs: viren2d.Vec2i) -> viren2d.Vec2d
Element-wise division with implicit type conversion. Returns a double-precision
Vec2d=Vec2i/Vec2i.
- static all(value: int) viren2d.Vec2i
Creates a vector where each coordinate is set to the given scalar.
Corresponding C++ API:
viren2d::Vec2i::All.
- angle_deg(self: viren2d.Vec2i, other: viren2d.Vec2i) float
Computes the angle \(\in [0, 180]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec2i
- Returns:
The angle \(\in [0, 180]\) in degrees.
- angle_rad(self: viren2d.Vec2i, other: viren2d.Vec2i) float
Computes the angle \(\in [0, \pi]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec2i
- Returns:
The angle \(\in [0, \pi]\) in radians.
- as_float(self: viren2d.Vec2i) viren2d.Vec2d
Returns a
Vec2ias the result of explicitly casting the values.Corresponding C++ API:
viren2d::Vec2i::ToDouble.
- as_int(self: viren2d.Vec2i) viren2d.Vec2i
Returns a copy of this vector as
Vec2iCorresponding C++ API:
viren2d::Vec2i::ToInteger.
- copy(self: viren2d.Vec2i) viren2d.Vec2i
Returns a deep copy.
Corresponding C++ API: Copy constructor of
viren2d::Vec2i.
- direction_vector(self: viren2d.Vec2i, other: viren2d.Vec2i) viren2d.Vec2i
Returns the
Vec2idirection vector,other - self.
- distance_l1(self: viren2d.Vec2i, other: viren2d.Vec2i) float
Returns the Manhattan distance between
selfand the otherVec2i.
- distance_l2(self: viren2d.Vec2i, other: viren2d.Vec2i) float
Returns the Euclidean distance between
selfand the otherVec2i.
- dot(self: viren2d.Vec2i, other: viren2d.Vec2i) int
Returns the dot product of
selfand the otherVec2i.
- property dtype
Underlying data type (read-only).
- Type:
- property height
Provides alternative read-write access to the second dimension, (i.e.
y).Can be useful if you want to use this 2D vector to represent a 2D size. This property is only available for 2-dimensional vectors.
- Type:
- homogeneous(self: viren2d.Vec2i) tuple
Returns the homogeneous representation of this vector, i.e. a 3-element tuple, where the additional dimension is set to 1.
- length(self: viren2d.Vec2i) float
Returns the length of this vector.
Corresponding C++ API:
viren2d::Vec2i::Length.
- length_squared(self: viren2d.Vec2i) float
Returns this vector’s squared length.
- max_index(self: viren2d.Vec2i) int
Returns \(i = \arg_i \max(v_i)\).
Corresponding C++ API:
viren2d::Vec2i::MaxIndex.
- max_value(self: viren2d.Vec2i) int
Returns \(\max(v_i)\).
Corresponding C++ API:
viren2d::Vec2i::MaxValue.
- min_index(self: viren2d.Vec2i) int
Returns \(i = \arg_i \min(v_i)\).
Corresponding C++ API:
viren2d::Vec2i::MinIndex.
- min_value(self: viren2d.Vec2i) int
Returns \(\min(v_i)\).
Corresponding C++ API:
viren2d::Vec2i::MinValue.
- perpendicular_ccw(self: viren2d.Vec2i) viren2d.Vec2i
Returns the 90° counterclockwise rotated vector.
This method assumes that the coordinate system is right-handed and is only supported for 2D vectors.
- perpendicular_cw(self: viren2d.Vec2i) viren2d.Vec2i
Returns the 90° clockwise rotated vector.
This method assumes that the coordinate system is right-handed and is only supported for 2D vectors.
- unit_vector(self: viren2d.Vec2i) viren2d.Vec2d
Returns the corresponding unit vector as
Vec2d.
Integral 3D: Vec3i
- class viren2d.Vec3i
A 3D vector of
intcoordinates.Corresponding C++ API:
viren2d::Vec3i.Methods:
Overloaded function.
Checks for equality.
Allows accessing this vector's values via
vec[i].Overloaded function.
Overloaded function.
Overloaded function.
Checks for inequality.
Returns a
Vec3d, where all values are negated.Allows accessing this vector's values via
vec[idx].Vec3dinstances can be pickled.Overloaded function.
Overloaded function.
Creates a vector where each coordinate is set to the given scalar.
Computes the angle \(\in [0, 180]\) between this and the other vector.
Computes the angle \(\in [0, \pi]\) between this and the other vector.
Returns a
Vec3ias the result of explicitly casting the values.Returns a copy of this vector as
Vec3iReturns a deep copy.
Computes the cross product.
Returns the
Vec3idirection vector,other - self.Returns the Manhattan distance between
selfand the otherVec3i.Returns the Euclidean distance between
selfand the otherVec3i.Returns the dot product of
selfand the otherVec3i.Returns the homogeneous representation of this vector, i.e. a 4-element tuple, where the additional dimension is set to 1.
Returns the length of this vector.
Returns this vector's squared length.
Returns \(i = \arg_i \max(v_i)\).
Returns \(\max(v_i)\).
Returns \(i = \arg_i \min(v_i)\).
Returns \(\min(v_i)\).
Returns the corresponding unit vector as
Vec3d.Attributes:
Underlying data type (read-only).
Number of dimensions (read-only), i.e. 3.
Read-write access to the first dimension, i.e. same as
vec[0].Read-write access to the second dimension, i.e. same as
vec[1].Read-write access to the third dimension, i.e. same as
vec[2].- __add__(*args, **kwargs)
Overloaded function.
__add__(self: viren2d.Vec3i, scalar: int) -> viren2d.Vec3i
Element-wise addition:
Vec3i=Vec3i+int.__add__(self: viren2d.Vec3i, rhs: viren2d.Vec3i) -> viren2d.Vec3i
- __eq__(self: viren2d.Vec3i, other: viren2d.Vec3i) bool
Checks for equality.
- __getitem__(self: viren2d.Vec3i, arg0: int) int
Allows accessing this vector’s values via
vec[i].
- __getstate__(self: viren2d.Vec3i) tuple
- __iadd__(*args, **kwargs)
Overloaded function.
__iadd__(self: viren2d.Vec3i, rhs: int) -> viren2d.Vec3i
In-place element-wise addition:
Vec3i+=int.__iadd__(self: viren2d.Vec3i, rhs: viren2d.Vec3i) -> viren2d.Vec3i
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: viren2d.Vec3i) -> None
Initializes all values to 0.
__init__(self: viren2d.Vec3i, vec: viren2d.Vec3i) -> None
Creates a copy of the given
Vec3i.__init__(self: viren2d.Vec3i, tpl: tuple) -> None
Creates a vector from a 3-element
tuple.__init__(self: viren2d.Vec3i, lst: list) -> None
Creates a vector from a 3-element
list.__init__(self: viren2d.Vec3i, arr: numpy.ndarray) -> None
Creates a vector from a 3-element
numpy.array.__init__(self: viren2d.Vec3i, x: int, y: int, z: int) -> None
Explicit initialization from 3 separate values.
- __mul__(*args, **kwargs)
Overloaded function.
__mul__(self: viren2d.Vec3i, rhs: int) -> viren2d.Vec3i
Element-wise multiplication:
Vec3i=Vec3i*int.__mul__(self: viren2d.Vec3i, rhs: viren2d.Vec3i) -> viren2d.Vec3i
- __ne__(self: viren2d.Vec3i, other: viren2d.Vec3i) bool
Checks for inequality.
- __neg__(self: viren2d.Vec3i) viren2d.Vec3i
Returns a
Vec3d, where all values are negated.
- __rmul__(self: viren2d.Vec3i, lhs: int) viren2d.Vec3i
- __setitem__(self: viren2d.Vec3i, arg0: int, arg1: int) None
Allows accessing this vector’s values via
vec[idx].
- __setstate__(self: viren2d.Vec3i, arg0: tuple) None
Vec3dinstances can be pickled.
- __sub__(*args, **kwargs)
Overloaded function.
__sub__(self: viren2d.Vec3i, rhs: int) -> viren2d.Vec3i
Element-wise subtraction:
Vec3i=Vec3i-int.__sub__(self: viren2d.Vec3i, rhs: viren2d.Vec3i) -> viren2d.Vec3i
- __truediv__(*args, **kwargs)
Overloaded function.
__truediv__(self: viren2d.Vec3i, rhs: int) -> viren2d.Vec3d
Element-wise division with implicit type conversion. Returns a double-precision
Vec3d=Vec3i/int.__truediv__(self: viren2d.Vec3i, rhs: float) -> viren2d.Vec3d
Element-wise division with implicit type conversion. Returns a double-precision
Vec3d=Vec3i/float.__truediv__(self: viren2d.Vec3i, rhs: viren2d.Vec3i) -> viren2d.Vec3d
Element-wise division with implicit type conversion. Returns a double-precision
Vec3d=Vec3i/Vec3i.
- static all(value: int) viren2d.Vec3i
Creates a vector where each coordinate is set to the given scalar.
Corresponding C++ API:
viren2d::Vec3i::All.
- angle_deg(self: viren2d.Vec3i, other: viren2d.Vec3i) float
Computes the angle \(\in [0, 180]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec3i
- Returns:
The angle \(\in [0, 180]\) in degrees.
- angle_rad(self: viren2d.Vec3i, other: viren2d.Vec3i) float
Computes the angle \(\in [0, \pi]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec3i
- Returns:
The angle \(\in [0, \pi]\) in radians.
- as_float(self: viren2d.Vec3i) viren2d.Vec3d
Returns a
Vec3ias the result of explicitly casting the values.Corresponding C++ API:
viren2d::Vec3i::ToDouble.
- as_int(self: viren2d.Vec3i) viren2d.Vec3i
Returns a copy of this vector as
Vec3iCorresponding C++ API:
viren2d::Vec3i::ToInteger.
- copy(self: viren2d.Vec3i) viren2d.Vec3i
Returns a deep copy.
Corresponding C++ API: Copy constructor of
viren2d::Vec3i.
- cross(self: viren2d.Vec3i, other: viren2d.Vec3i) viren2d.Vec3i
Computes the cross product.
- direction_vector(self: viren2d.Vec3i, other: viren2d.Vec3i) viren2d.Vec3i
Returns the
Vec3idirection vector,other - self.
- distance_l1(self: viren2d.Vec3i, other: viren2d.Vec3i) float
Returns the Manhattan distance between
selfand the otherVec3i.
- distance_l2(self: viren2d.Vec3i, other: viren2d.Vec3i) float
Returns the Euclidean distance between
selfand the otherVec3i.
- dot(self: viren2d.Vec3i, other: viren2d.Vec3i) int
Returns the dot product of
selfand the otherVec3i.
- property dtype
Underlying data type (read-only).
- Type:
- homogeneous(self: viren2d.Vec3i) tuple
Returns the homogeneous representation of this vector, i.e. a 4-element tuple, where the additional dimension is set to 1.
- length(self: viren2d.Vec3i) float
Returns the length of this vector.
Corresponding C++ API:
viren2d::Vec3i::Length.
- length_squared(self: viren2d.Vec3i) float
Returns this vector’s squared length.
- max_index(self: viren2d.Vec3i) int
Returns \(i = \arg_i \max(v_i)\).
Corresponding C++ API:
viren2d::Vec3i::MaxIndex.
- max_value(self: viren2d.Vec3i) int
Returns \(\max(v_i)\).
Corresponding C++ API:
viren2d::Vec3i::MaxValue.
- min_index(self: viren2d.Vec3i) int
Returns \(i = \arg_i \min(v_i)\).
Corresponding C++ API:
viren2d::Vec3i::MinIndex.
- min_value(self: viren2d.Vec3i) int
Returns \(\min(v_i)\).
Corresponding C++ API:
viren2d::Vec3i::MinValue.
- unit_vector(self: viren2d.Vec3i) viren2d.Vec3d
Returns the corresponding unit vector as
Vec3d.
Floating point 2D: Vec2d
- class viren2d.Vec2d
A 2D vector of
floatcoordinates.Corresponding C++ API:
viren2d::Vec2d.Methods:
Overloaded function.
Returns
Trueif the two vectors are approximately equal.Allows accessing this vector's values via
vec[i].Overloaded function.
Overloaded function.
Overloaded function.
Returns
Trueif the two vectors are approximately equal.Returns a
Vec2d, where all values are negated.Overloaded function.
Allows accessing this vector's values via
vec[idx].Vec2dinstances can be pickled.Overloaded function.
Overloaded function.
Creates a vector where each coordinate is set to the given scalar.
Computes the angle \(\in [0, 180]\) between this and the other vector.
Computes the angle \(\in [0, \pi]\) between this and the other vector.
Returns a copy of this vector as
Vec2dReturns a
Vec2ias the result of explicitly casting/clipping the values.Returns a deep copy.
Returns the
Vec2ddirection vector,other - self.Returns the Manhattan distance between
selfand the otherVec2d.Returns the Euclidean distance between
selfand the otherVec2d.Returns the dot product of
selfand the otherVec2d.Returns the homogeneous representation of this vector, i.e. a 3-element tuple, where the additional dimension is set to 1.
Returns the length of this vector.
Returns this vector's squared length.
Returns \(i = \arg_i \max(v_i)\).
Returns \(\max(v_i)\).
Returns \(i = \arg_i \min(v_i)\).
Returns \(\min(v_i)\).
Returns the 90° counterclockwise rotated vector.
Returns the 90° clockwise rotated vector.
Returns a copy of this vector rotated around the reference point by the given angle.
Returns a copy of this vector rotated around the reference point by the given angle.
Returns the corresponding unit vector as
Vec2d.Attributes:
Underlying data type (read-only).
Provides alternative read-write access to the second dimension, (i.e.
y).Number of dimensions (read-only), i.e. 2.
Provides alternative read-write access to the first dimension, (i.e.
x).Read-write access to the first dimension, i.e. same as
vec[0].Read-write access to the second dimension, i.e. same as
vec[1].- __add__(*args, **kwargs)
Overloaded function.
__add__(self: viren2d.Vec2d, scalar: int) -> viren2d.Vec2d
Element-wise addition:
Vec2d=Vec2d+int.__add__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
Element-wise addition:
Vec2d=Vec2d+Vec2d.__add__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
Element-wise addition:
Vec2d=Vec2d+Vec2d.__add__(self: viren2d.Vec2d, rhs: float) -> viren2d.Vec2d
- __eq__(self: viren2d.Vec2d, other: viren2d.Vec2d) bool
Returns
Trueif the two vectors are approximately equal.Uses a combined test with both relative and absolute tolerance. Modulo special cases (NaN, infinity), two vectors \(x = (x_i)_{i=1}^2\) and \(y = (y_i)_{i=1}^2\) are considered approximately equal if for all their values
\(|x_i - y_i| \leq \epsilon_{\text{rel}} * \max(|x_i|, |y_i|) \quad\text{or}\quad |x_i - y_i| \leq \epsilon_{\text{abs}}\),
where \(\epsilon_{\text{rel}} = 1e-9\) and \(\epsilon_{\text{abs}} = 1e-12\).
Corresponding C++ API:
viren2d::Vec2d::operator==and::IsClose
- __getitem__(self: viren2d.Vec2d, arg0: int) float
Allows accessing this vector’s values via
vec[i].
- __getstate__(self: viren2d.Vec2d) tuple
- __iadd__(*args, **kwargs)
Overloaded function.
__iadd__(self: viren2d.Vec2d, rhs: int) -> viren2d.Vec2d
In-place element-wise addition:
Vec2d+=int.__iadd__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
In-place element-wise addition:
Vec2d+=Vec2d.__iadd__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
In-place element-wise addition:
Vec2d+=Vec2d.__iadd__(self: viren2d.Vec2d, rhs: float) -> viren2d.Vec2d
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: viren2d.Vec2d) -> None
Initializes all values to 0.
__init__(self: viren2d.Vec2d, vec_int: werkzeugkiste::geometry::Vec<int, 2ul>) -> None
Creates a double-precision vector from its 32-bit integral counterpart.
__init__(self: viren2d.Vec2d, vec: viren2d.Vec2d) -> None
Creates a copy of the given
Vec2d.__init__(self: viren2d.Vec2d, tpl: tuple) -> None
Creates a vector from a 2-element
tuple.__init__(self: viren2d.Vec2d, lst: list) -> None
Creates a vector from a 2-element
list.__init__(self: viren2d.Vec2d, arr: numpy.ndarray) -> None
Creates a vector from a 2-element
numpy.array.__init__(self: viren2d.Vec2d, x: float, y: float) -> None
Explicit initialization from 2 separate values.
- __mul__(*args, **kwargs)
Overloaded function.
__mul__(self: viren2d.Vec2d, rhs: int) -> viren2d.Vec2d
Element-wise multiplication:
Vec2d=Vec2d*int.__mul__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
Element-wise multiplication:
Vec2d=Vec2d*Vec2d.__mul__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
Element-wise multiplication:
Vec2d=Vec2d*Vec2d.__mul__(self: viren2d.Vec2d, rhs: float) -> viren2d.Vec2d
- __ne__(self: viren2d.Vec2d, other: viren2d.Vec2d) bool
Returns
Trueif the two vectors are approximately equal.Uses a combined test with both relative and absolute tolerance. Modulo special cases (NaN, infinity), two vectors \(x = (x_i)_{i=1}^2\) and \(y = (y_i)_{i=1}^2\) are considered approximately equal if for all their values
\(|x_i - y_i| \leq \epsilon_{\text{rel}} * \max(|x_i|, |y_i|) \quad\text{or}\quad |x_i - y_i| \leq \epsilon_{\text{abs}}\),
where \(\epsilon_{\text{rel}} = 1e-9\) and \(\epsilon_{\text{abs}} = 1e-12\).
Corresponding C++ API:
viren2d::Vec2d::operator==and::IsClose``Returns ``Trueif the two vectors differ sufficiently.As this operator computes
!(vec1 == vec2), refer to__eq__()for details.
- __neg__(self: viren2d.Vec2d) viren2d.Vec2d
Returns a
Vec2d, where all values are negated.
- __rmul__(*args, **kwargs)
Overloaded function.
__rmul__(self: viren2d.Vec2d, lhs: int) -> viren2d.Vec2d
Element-wise multiplication:
Vec2d=int*Vec2d.__rmul__(self: viren2d.Vec2d, lhs: viren2d.Vec2d) -> viren2d.Vec2d
Element-wise multiplication:
Vec2d=Vec2d*Vec2d.__rmul__(self: viren2d.Vec2d, lhs: float) -> viren2d.Vec2d
- __setitem__(self: viren2d.Vec2d, arg0: int, arg1: float) None
Allows accessing this vector’s values via
vec[idx].
- __setstate__(self: viren2d.Vec2d, arg0: tuple) None
Vec2dinstances can be pickled.
- __sub__(*args, **kwargs)
Overloaded function.
__sub__(self: viren2d.Vec2d, rhs: int) -> viren2d.Vec2d
Element-wise subtraction:
Vec2d=Vec2d-int.__sub__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
Element-wise subtraction:
Vec2d=Vec2d-Vec2d.__sub__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
Element-wise subtraction:
Vec2d=Vec2d-Vec2d.__sub__(self: viren2d.Vec2d, rhs: float) -> viren2d.Vec2d
- __truediv__(*args, **kwargs)
Overloaded function.
__truediv__(self: viren2d.Vec2d, rhs: int) -> viren2d.Vec2d
Element-wise division:
Vec2d=Vec2d/int.__truediv__(self: viren2d.Vec2d, rhs: float) -> viren2d.Vec2d
Element-wise division:
Vec2d=Vec2d/float.__truediv__(self: viren2d.Vec2d, rhs: viren2d.Vec2d) -> viren2d.Vec2d
- static all(value: float) viren2d.Vec2d
Creates a vector where each coordinate is set to the given scalar.
Corresponding C++ API:
viren2d::Vec2d::All.
- angle_deg(self: viren2d.Vec2d, other: viren2d.Vec2d) float
Computes the angle \(\in [0, 180]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec2d
- Returns:
The angle \(\in [0, 180]\) in degrees.
- angle_rad(self: viren2d.Vec2d, other: viren2d.Vec2d) float
Computes the angle \(\in [0, \pi]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec2d
- Returns:
The angle \(\in [0, \pi]\) in radians.
- as_float(self: viren2d.Vec2d) viren2d.Vec2d
Returns a copy of this vector as
Vec2dCorresponding C++ API:
viren2d::Vec2d::ToDouble.
- as_int(self: viren2d.Vec2d) werkzeugkiste::geometry::Vec<int, 2ul>
Returns a
Vec2ias the result of explicitly casting/clipping the values.Corresponding C++ API:
viren2d::Vec2d::ToInteger.
- copy(self: viren2d.Vec2d) viren2d.Vec2d
Returns a deep copy.
Corresponding C++ API: Copy constructor of
viren2d::Vec2d.
- direction_vector(self: viren2d.Vec2d, other: viren2d.Vec2d) viren2d.Vec2d
Returns the
Vec2ddirection vector,other - self.
- distance_l1(self: viren2d.Vec2d, other: viren2d.Vec2d) float
Returns the Manhattan distance between
selfand the otherVec2d.
- distance_l2(self: viren2d.Vec2d, other: viren2d.Vec2d) float
Returns the Euclidean distance between
selfand the otherVec2d.
- dot(self: viren2d.Vec2d, other: viren2d.Vec2d) float
Returns the dot product of
selfand the otherVec2d.
- property dtype
Underlying data type (read-only).
- Type:
- property height
Provides alternative read-write access to the second dimension, (i.e.
y).Can be useful if you want to use this 2D vector to represent a 2D size. This property is only available for 2-dimensional vectors.
- Type:
- homogeneous(self: viren2d.Vec2d) tuple
Returns the homogeneous representation of this vector, i.e. a 3-element tuple, where the additional dimension is set to 1.
- length(self: viren2d.Vec2d) float
Returns the length of this vector.
Corresponding C++ API:
viren2d::Vec2d::Length.
- length_squared(self: viren2d.Vec2d) float
Returns this vector’s squared length.
- max_index(self: viren2d.Vec2d) int
Returns \(i = \arg_i \max(v_i)\).
Corresponding C++ API:
viren2d::Vec2d::MaxIndex.
- max_value(self: viren2d.Vec2d) float
Returns \(\max(v_i)\).
Corresponding C++ API:
viren2d::Vec2d::MaxValue.
- min_index(self: viren2d.Vec2d) int
Returns \(i = \arg_i \min(v_i)\).
Corresponding C++ API:
viren2d::Vec2d::MinIndex.
- min_value(self: viren2d.Vec2d) float
Returns \(\min(v_i)\).
Corresponding C++ API:
viren2d::Vec2d::MinValue.
- perpendicular_ccw(self: viren2d.Vec2d) viren2d.Vec2d
Returns the 90° counterclockwise rotated vector.
This method assumes that the coordinate system is right-handed and is only supported for 2D vectors.
- perpendicular_cw(self: viren2d.Vec2d) viren2d.Vec2d
Returns the 90° clockwise rotated vector.
This method assumes that the coordinate system is right-handed and is only supported for 2D vectors.
- rotate_deg(self: viren2d.Vec2d, angle: float, rotation_center: viren2d.Vec2d = viren2d.Vec2d(0, 0)) viren2d.Vec2d
Returns a copy of this vector rotated around the reference point by the given angle.
This method assumes that the coordinate system is right-handed and is only supported for 2D vector specialization with floating point value type.
- Parameters:
angle – Rotation angle in degrees.
rotation_center – Reference point for rotation as
Vec2d.
- rotate_rad(self: viren2d.Vec2d, angle: viren2d.Vec2d, rotation_center: float = viren2d.Vec2d(0, 0)) viren2d.Vec2d
Returns a copy of this vector rotated around the reference point by the given angle.
This method assumes that the coordinate system is right-handed and is only supported for 2D vector specialization with floating point value type.
- Parameters:
angle – Rotation angle in radians.
rotation_center – Reference point for rotation as
Vec2d.
- unit_vector(self: viren2d.Vec2d) viren2d.Vec2d
Returns the corresponding unit vector as
Vec2d.
Floating point 3D: Vec3d
- class viren2d.Vec3d
A 3D vector of
floatcoordinates.Corresponding C++ API:
viren2d::Vec3d.Methods:
Overloaded function.
Returns
Trueif the two vectors are approximately equal.Allows accessing this vector's values via
vec[i].Overloaded function.
Overloaded function.
Overloaded function.
Returns
Trueif the two vectors are approximately equal.Returns a
Vec3d, where all values are negated.Overloaded function.
Allows accessing this vector's values via
vec[idx].Vec3dinstances can be pickled.Overloaded function.
Overloaded function.
Creates a vector where each coordinate is set to the given scalar.
Computes the angle \(\in [0, 180]\) between this and the other vector.
Computes the angle \(\in [0, \pi]\) between this and the other vector.
Returns a copy of this vector as
Vec3dReturns a
Vec3ias the result of explicitly casting/clipping the values.Returns a deep copy.
Computes the cross product.
Returns the
Vec3ddirection vector,other - self.Returns the Manhattan distance between
selfand the otherVec3d.Returns the Euclidean distance between
selfand the otherVec3d.Returns the dot product of
selfand the otherVec3d.Returns the homogeneous representation of this vector, i.e. a 4-element tuple, where the additional dimension is set to 1.
Returns the length of this vector.
Returns this vector's squared length.
Returns \(i = \arg_i \max(v_i)\).
Returns \(\max(v_i)\).
Returns \(i = \arg_i \min(v_i)\).
Returns \(\min(v_i)\).
Returns the corresponding unit vector as
Vec3d.Attributes:
Underlying data type (read-only).
Number of dimensions (read-only), i.e. 3.
Read-write access to the first dimension, i.e. same as
vec[0].Read-write access to the second dimension, i.e. same as
vec[1].Read-write access to the third dimension, i.e. same as
vec[2].- __add__(*args, **kwargs)
Overloaded function.
__add__(self: viren2d.Vec3d, scalar: int) -> viren2d.Vec3d
Element-wise addition:
Vec3d=Vec3d+int.__add__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
Element-wise addition:
Vec3d=Vec3d+Vec3d.__add__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
Element-wise addition:
Vec3d=Vec3d+Vec3d.__add__(self: viren2d.Vec3d, rhs: float) -> viren2d.Vec3d
- __eq__(self: viren2d.Vec3d, other: viren2d.Vec3d) bool
Returns
Trueif the two vectors are approximately equal.Uses a combined test with both relative and absolute tolerance. Modulo special cases (NaN, infinity), two vectors \(x = (x_i)_{i=1}^3\) and \(y = (y_i)_{i=1}^3\) are considered approximately equal if for all their values
\(|x_i - y_i| \leq \epsilon_{\text{rel}} * \max(|x_i|, |y_i|) \quad\text{or}\quad |x_i - y_i| \leq \epsilon_{\text{abs}}\),
where \(\epsilon_{\text{rel}} = 1e-9\) and \(\epsilon_{\text{abs}} = 1e-12\).
Corresponding C++ API:
viren2d::Vec3d::operator==and::IsClose
- __getitem__(self: viren2d.Vec3d, arg0: int) float
Allows accessing this vector’s values via
vec[i].
- __getstate__(self: viren2d.Vec3d) tuple
- __iadd__(*args, **kwargs)
Overloaded function.
__iadd__(self: viren2d.Vec3d, rhs: int) -> viren2d.Vec3d
In-place element-wise addition:
Vec3d+=int.__iadd__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
In-place element-wise addition:
Vec3d+=Vec3d.__iadd__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
In-place element-wise addition:
Vec3d+=Vec3d.__iadd__(self: viren2d.Vec3d, rhs: float) -> viren2d.Vec3d
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: viren2d.Vec3d) -> None
Initializes all values to 0.
__init__(self: viren2d.Vec3d, vec_int: werkzeugkiste::geometry::Vec<int, 3ul>) -> None
Creates a double-precision vector from its 32-bit integral counterpart.
__init__(self: viren2d.Vec3d, vec: viren2d.Vec3d) -> None
Creates a copy of the given
Vec3d.__init__(self: viren2d.Vec3d, tpl: tuple) -> None
Creates a vector from a 3-element
tuple.__init__(self: viren2d.Vec3d, lst: list) -> None
Creates a vector from a 3-element
list.__init__(self: viren2d.Vec3d, arr: numpy.ndarray) -> None
Creates a vector from a 3-element
numpy.array.__init__(self: viren2d.Vec3d, x: float, y: float, z: float) -> None
Explicit initialization from 3 separate values.
- __mul__(*args, **kwargs)
Overloaded function.
__mul__(self: viren2d.Vec3d, rhs: int) -> viren2d.Vec3d
Element-wise multiplication:
Vec3d=Vec3d*int.__mul__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
Element-wise multiplication:
Vec3d=Vec3d*Vec3d.__mul__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
Element-wise multiplication:
Vec3d=Vec3d*Vec3d.__mul__(self: viren2d.Vec3d, rhs: float) -> viren2d.Vec3d
- __ne__(self: viren2d.Vec3d, other: viren2d.Vec3d) bool
Returns
Trueif the two vectors are approximately equal.Uses a combined test with both relative and absolute tolerance. Modulo special cases (NaN, infinity), two vectors \(x = (x_i)_{i=1}^3\) and \(y = (y_i)_{i=1}^3\) are considered approximately equal if for all their values
\(|x_i - y_i| \leq \epsilon_{\text{rel}} * \max(|x_i|, |y_i|) \quad\text{or}\quad |x_i - y_i| \leq \epsilon_{\text{abs}}\),
where \(\epsilon_{\text{rel}} = 1e-9\) and \(\epsilon_{\text{abs}} = 1e-12\).
Corresponding C++ API:
viren2d::Vec3d::operator==and::IsClose``Returns ``Trueif the two vectors differ sufficiently.As this operator computes
!(vec1 == vec2), refer to__eq__()for details.
- __neg__(self: viren2d.Vec3d) viren2d.Vec3d
Returns a
Vec3d, where all values are negated.
- __rmul__(*args, **kwargs)
Overloaded function.
__rmul__(self: viren2d.Vec3d, lhs: int) -> viren2d.Vec3d
Element-wise multiplication:
Vec3d=int*Vec3d.__rmul__(self: viren2d.Vec3d, lhs: viren2d.Vec3d) -> viren2d.Vec3d
Element-wise multiplication:
Vec3d=Vec3d*Vec3d.__rmul__(self: viren2d.Vec3d, lhs: float) -> viren2d.Vec3d
- __setitem__(self: viren2d.Vec3d, arg0: int, arg1: float) None
Allows accessing this vector’s values via
vec[idx].
- __setstate__(self: viren2d.Vec3d, arg0: tuple) None
Vec3dinstances can be pickled.
- __sub__(*args, **kwargs)
Overloaded function.
__sub__(self: viren2d.Vec3d, rhs: int) -> viren2d.Vec3d
Element-wise subtraction:
Vec3d=Vec3d-int.__sub__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
Element-wise subtraction:
Vec3d=Vec3d-Vec3d.__sub__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
Element-wise subtraction:
Vec3d=Vec3d-Vec3d.__sub__(self: viren2d.Vec3d, rhs: float) -> viren2d.Vec3d
- __truediv__(*args, **kwargs)
Overloaded function.
__truediv__(self: viren2d.Vec3d, rhs: int) -> viren2d.Vec3d
Element-wise division:
Vec3d=Vec3d/int.__truediv__(self: viren2d.Vec3d, rhs: float) -> viren2d.Vec3d
Element-wise division:
Vec3d=Vec3d/float.__truediv__(self: viren2d.Vec3d, rhs: viren2d.Vec3d) -> viren2d.Vec3d
- static all(value: float) viren2d.Vec3d
Creates a vector where each coordinate is set to the given scalar.
Corresponding C++ API:
viren2d::Vec3d::All.
- angle_deg(self: viren2d.Vec3d, other: viren2d.Vec3d) float
Computes the angle \(\in [0, 180]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec3d
- Returns:
The angle \(\in [0, 180]\) in degrees.
- angle_rad(self: viren2d.Vec3d, other: viren2d.Vec3d) float
Computes the angle \(\in [0, \pi]\) between this and the other vector.
- Parameters:
other – The second viren2d.Vec3d
- Returns:
The angle \(\in [0, \pi]\) in radians.
- as_float(self: viren2d.Vec3d) viren2d.Vec3d
Returns a copy of this vector as
Vec3dCorresponding C++ API:
viren2d::Vec3d::ToDouble.
- as_int(self: viren2d.Vec3d) werkzeugkiste::geometry::Vec<int, 3ul>
Returns a
Vec3ias the result of explicitly casting/clipping the values.Corresponding C++ API:
viren2d::Vec3d::ToInteger.
- copy(self: viren2d.Vec3d) viren2d.Vec3d
Returns a deep copy.
Corresponding C++ API: Copy constructor of
viren2d::Vec3d.
- cross(self: viren2d.Vec3d, other: viren2d.Vec3d) viren2d.Vec3d
Computes the cross product.
- direction_vector(self: viren2d.Vec3d, other: viren2d.Vec3d) viren2d.Vec3d
Returns the
Vec3ddirection vector,other - self.
- distance_l1(self: viren2d.Vec3d, other: viren2d.Vec3d) float
Returns the Manhattan distance between
selfand the otherVec3d.
- distance_l2(self: viren2d.Vec3d, other: viren2d.Vec3d) float
Returns the Euclidean distance between
selfand the otherVec3d.
- dot(self: viren2d.Vec3d, other: viren2d.Vec3d) float
Returns the dot product of
selfand the otherVec3d.
- property dtype
Underlying data type (read-only).
- Type:
- homogeneous(self: viren2d.Vec3d) tuple
Returns the homogeneous representation of this vector, i.e. a 4-element tuple, where the additional dimension is set to 1.
- length(self: viren2d.Vec3d) float
Returns the length of this vector.
Corresponding C++ API:
viren2d::Vec3d::Length.
- length_squared(self: viren2d.Vec3d) float
Returns this vector’s squared length.
- max_index(self: viren2d.Vec3d) int
Returns \(i = \arg_i \max(v_i)\).
Corresponding C++ API:
viren2d::Vec3d::MaxIndex.
- max_value(self: viren2d.Vec3d) float
Returns \(\max(v_i)\).
Corresponding C++ API:
viren2d::Vec3d::MaxValue.
- min_index(self: viren2d.Vec3d) int
Returns \(i = \arg_i \min(v_i)\).
Corresponding C++ API:
viren2d::Vec3d::MinIndex.
- min_value(self: viren2d.Vec3d) float
Returns \(\min(v_i)\).
Corresponding C++ API:
viren2d::Vec3d::MinValue.
- unit_vector(self: viren2d.Vec3d) viren2d.Vec3d
Returns the corresponding unit vector as
Vec3d.