Vector
- class compas.geometry.Vector(x, y, z=0.0, **kwargs)[source]
Bases:
compas.geometry.primitives._primitive.Primitive
A vector is defined by XYZ components and a homogenisation factor.
- Parameters
x (float) – The X component of the vector.
y (float) – The Y component of the vector.
z (float) – The Z component of the vector.
- Attributes
data (dict) – The data representation of the vector.
x (float) – The component along the X axis of the vector.
y (float) – The component along the Y axis of the vector.
z (float) – The component along the Z axis of the vector.
length (float, read-only) – The length of the vector.
Examples
>>> u = Vector(1, 0, 0) >>> v = Vector(0, 1, 0) >>> u Vector(1.000, 0.000, 0.000) >>> v Vector(0.000, 1.000, 0.000) >>> u.x 1.0 >>> u[0] 1.0 >>> u.length 1.0 >>> u + v Vector(1.000, 1.000, 0.000) >>> u + [0.0, 1.0, 0.0] Vector(1.000, 1.000, 0.000) >>> u * 2 Vector(2.000, 0.000, 0.000) >>> u.dot(v) 0.0 >>> u.cross(v) Vector(0.000, 0.000, 1.000)
Attributes
DATASCHEMA
The schema of the data of this object.
JSONSCHEMANAME
data
The data dictionary that represents the vector.
length
The length of this vector.
x
The X coordinate of the point.
y
The Y coordinate of the point.
z
The Z coordinate of the point.
Inherited Attributes
JSONSCHEMA
The schema of the JSON representation of the data of this object.
dtype
The type of the object in the form of a '2-level' import and a class name.
guid
The globally unique identifier of the object.
jsondefinitions
Reusable schema definitions.
jsonstring
The representation of the object data in JSON format.
jsonvalidator
JSON schema validator for draft 7.
name
The name of the object.
Methods
Construct a unit vector along the X axis.
Construct a unit vector along the Y axis.
Construct a unit vector along the Z axis.
Compute the smallest angle between this vector and another vector.
Compute the signed angle between this vector and another vector.
Compute the smallest angle between corresponding pairs of two lists of vectors.
Compute both angles between this vector and another vector.
Compute both angles between corresponding pairs of two lists of vectors.
Make a copy of this vector.
The cross product of this vector and another vector.
Compute the cross product of two lists of vectors.
The dot product of this vector and another vector.
Compute the dot product of two lists of vectors.
Construct a vector from a data dict.
Construct a vector from start and end points.
Invert the direction of this vector
Returns a inverted copy of this vector
Compute the length of multiple vectors.
Scale this vector by a factor n.
Returns a scaled copy of this vector.
Compute the sum of multiple vectors.
Transform this vector.
Transform a collection of vector objects.
Return a transformed copy of this vector.
Create a collection of transformed vectors.
Scale this vector to unit length.
Returns a unitized copy of this vector.
Inherited Methods
Construct an object from serialized data contained in a JSON file.
Construct an object from serialized data contained in a JSON string.
Convert an object to its native data representation.
Serialize the data representation of an object to a JSON file.
Serialize the data representation of an object to a JSON string.
Validate the object's data against its data schema (self.DATASCHEMA).
Validate the object's data against its json schema (self.JSONSCHEMA).