Vector (hwx.common.math)¶

A mathematical represenation of a Vector in 3D space.

 x y z

Public Methods¶

 classmethod findAngle (cls, pt1, pt2, pt3, degrees=False) angle (self, x, y=None, z=None, degrees=False) close (self, x, y=None, z=None, tol=1e-07) copy (self, x=None, y=None, z=None) cross (self, x, y=None, z=None) dot (self, x, y=None, z=None) isAlignedWith (self, x, y=None, z=None, tolerance=1e-05, normalize=True) iszero (self) magnitude (self) normalize (self) perpendicularize (self) scale (self, x, y=None, z=None)

Property Details¶

x()

The x coordinate.

y()

The y coordinate.

z()

The z coordinate.

Method Details¶

classmethod findAngle(cls, pt1, pt2, pt3, degrees=False)

Computes the angle subtended between (pt2-pt1) and (pt3-pt1).

param pt1: The first Vector. Vector The second Vector. Vector The third Vector. Vector Determines if the return value will be in degrees or not. bool The angle. float
angle(self, x, y=None, z=None, degrees=False)

Computes the angle with the Vector defined by x, y, z.

param x: The x coordinate. float The y coordinate. float The z coordinate. float Determines if the return value will be in degrees or not. bool The angle. float
close(self, x, y=None, z=None, tol=1e-07)

Determines if the distance to the Vector defined by x, y, z is less or equal than tolerance.

param x: type x: The x coordinate. float The y coordinate. float The z coordinate. float The tolerance to consider when checking condition. float True if Vectors are close, False otherwise. bool
copy(self, x=None, y=None, z=None)

Creates a copy of self.

If x, y, z are given then the copy has these as coordinates.

param x: The x coordinate. float The y coordinate. float The z coordinate. float The newly created object. Vector
cross(self, x, y=None, z=None)

Computes the cross product with the Vector defined by x, y, z.

param x: The x coordinate. float The y coordinate. float The z coordinate. float The cross product. Vector
dot(self, x, y=None, z=None)

Computes the dot product with the Vector defined by x, y, z.

param x: The x coordinate. float The y coordinate. float The z coordinate. float The dot product. float
isAlignedWith(self, x, y=None, z=None, tolerance=1e-05, normalize=True)

Determines if self is parallel to the Vector defined by x, y, z.

param x: type x: The x coordinate. float The y coordinate. float The z coordinate. float The tolerance to consider when checking condition. float Determines whether to normalize self before checking the condition. bool True if Vectors are aligned, False otherwise. bool
iszero(self)

Returns True if x, y and z are set to zero, False otherwise.

magnitude(self)

Returns the magnitude.

normalize(self)

Returns the normalized Vector.

perpendicularize(self)

Computes a Vector perpendicular to self.

If any of the coordinates are zero, returns a Vector along that coordinate, otherwise returns the cross product with (1, 0, 0).

scale(self, x, y=None, z=None)

Scales by a single value ‘x’ or a tripple (x, y, z), elementwise.

param x: The x scale factor. float The y scale factor. float The z scale factor. float The scaled Vector. Vector