A Vector2 might be used to represent a position in 2D space, a 2D direction and length, or the size of a rectangle. For example, hou.Node.position returns a position and hou.Node.size returns the size of a rectangle.
See also hou.Vector3 and hou.Vector4.
Methods ¶
__init__(values=(0.0, 0.0))
        
Return a new Vector2 from a sequence of floats. If this method is called without parameters, the resulting vector contains the values (0.0, 0.0).
Raises InvalidSize if values is not 2 elements long, or TypeError
    if values is not a sequence of floats or ints.
__getitem__(index)
  → float
        
Return the float component at the specified index. This method makes vectors behave as sequences (so you can, for example, use a for loop on the elements of a vector, convert a vector to a tuple of floats, etc.) and lets you use square brackets to index into a vector.
>>> v = hou.Vector2((1.0, 2.0)) >>> v[-1] 2.0
__setitem__(index, value)
        
This method lets you use square brackets to set a value on a vector.
>>> v = hou.Vector2((1.5, 2.5)) >>> v[0] = 0.5 >>> print v [0.5, 2.5]
setTo(sequence)
        
Set the contents of this vector to a sequence of floats.
Raises InvalidSize if values is not 2 elements long, or TypeError
    if values is not a sequence of floats or ints.
__len__()
  → int
        
Returns 2. This method lets you call len() on a Vector2.
__add__(vector2)
  → hou.Vector2
        
Add two vectors, returning a new vector with each component equal to the
    sum of the corresponding components in the two vectors.  This method lets
    you write v1 + v2, where v1 and v2 are Vector2 objects.
This method is equivalent to
    hou.Vector2(self[0] + vector2[0], self[1] + vector2[1]).
__sub__(vector2)
  → hou.Vector2
        
Subtract a vector from another, returning a new vector with each component
    equal to the first vector’s corresponding component minus the second
    vector’s.  This method lets you write v1 - v2, where v1 and v2 are
    Vector2 objects.
This method is equivalent to
    hou.Vector2(self[0] - vector2[0], self[1] - vector2[1]).
__neg__()
  → hou.Vector2
        
Return a vector whose components contain the negative values of this
    vector’s components.  This method lets you write -v, where v is a
    Vector2 object.
This method is equivalent to hou.Vector2(-self[0], -self[1]).
__mul__(scalar_or_matrix2)
  → hou.Vector2
        
Multiply a vector with a float scalar or with a hou.Matrix2,
    returning a new vector.  This method lets you write v * s where v is a
    vector and s is a float, or v * m where v is a vector and m is a
    hou.Matrix2.
This method is equivalent to
    hou.Vector2(self[0] * scalar, self[1] * scalar).
__rmul__(scalar)
  → hou.Vector2
        
Multiply a vector with a float scalar, returning a new vector.  This method
    lets you write s * v where v is a vector and s is a float.
This method is equivalent to
    hou.Vector2(self[0] * scalar, self[1] * scalar).
__div__(scalar)
  → hou.Vector2
        
Divide a vector by a float scalar, returning a new vector.  This method
    lets you write v / s where v is a vector and s is a float.
This method is equivalent to
    hou.Vector2(self[0] / scalar, self[1] / scalar).
length()
  → float
        
Interpret this vector as a direction vector and return its length.
    The result is the same as math.sqrt(self[0]**2 + self[1]**2).
lengthSquared()
  → float
        
Interpret this vector as a direction vector and return the square of its
    length.  The result is the same as self[0]**2 + self[1]**2.
normalized()
  → hou.Vector2
        
Interpreting this vector as a direction, return a vector with the same direction but with a length of 1.
If the vector’s length is 0 (or close to it), the result is the original vector.
For vector’s with non-zero lengths, this method is equivalent to
    self * (1.0/self.length()).
distanceTo(vector2)
  → float
        
Interpret this vector and the argument as 2D positions, and return the
    distance between them.  The return value is equivalent to
    (self - vector2).length().
dot(vector2)
  → float
        
Return the dot product between this vector and the one in the parameter.
almostEqual(vector2, tolerance=0.00001)
  → bool
        
Deprecated. Use Vector2.isAlmostEqual instead.
isAlmostEqual(vector2, tolerance=0.00001)
  → bool
        
Return whether this vector is equal to another, within a tolerance. Verifies that the difference between each component of this vector and the corresponding component of the other vector is within the tolerance.
x()
  → float
        
Return the first component of the vector. Equivalent to v/hom/hou/0.html.
y()
  → float
        
Return the second component of the vector. Equivalent to v/hom/hou/1.html.