Vector (hwx.common.math)

A mathematical represenation of a Vector in 3D space.

Properties

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.
type pt1:Vector
param pt2:The second Vector.
type pt2:Vector
param pt3:The third Vector.
type pt3:Vector
param degrees:Determines if the return value will be in degrees or not.
type degrees:bool
returns:The angle.
rtype: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.
type x:float
param y:The y coordinate.
type y:float
param z:The z coordinate.
type z:float
param degrees:Determines if the return value will be in degrees or not.
type degrees:bool
returns:The angle.
rtype: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:The x coordinate.
type x:float
param y:The y coordinate.
type y:float
param z:The z coordinate.
type z:float
param tolerance:
 The tolerance to consider when checking condition.
type tolerance:float
returns:True if Vectors are close, False otherwise.
rtype: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.
type x:float
param y:The y coordinate.
type y:float
param z:The z coordinate.
type z:float
returns:The newly created object.
rtype: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.
type x:float
param y:The y coordinate.
type y:float
param z:The z coordinate.
type z:float
returns:The cross product.
rtype: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.
type x:float
param y:The y coordinate.
type y:float
param z:The z coordinate.
type z:float
returns:The dot product.
rtype: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:The x coordinate.
type x:float
param y:The y coordinate.
type y:float
param z:The z coordinate.
type z:float
param tolerance:
 The tolerance to consider when checking condition.
type tolerance:float
param normalize:
 Determines whether to normalize self before checking the condition.
type normalize:bool
returns:True if Vectors are aligned, False otherwise.
rtype: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.
type x:float
param y:The y scale factor.
type y:float
param z:The z scale factor.
type z:float
returns:The scaled Vector.
rtype:Vector