### Navigation

- index
- modules |
- next |
- previous |
- Grease v0.2 documentation »

# `grease.geometry` – 2D Geometry

Note

This class is in the process of being replaced by a standalone library now in development.

class `grease.geometry.``Rect`(rect_or_left, bottom=None, right=None, top=None)

  Simple rectangle. Will gain more functionality as needed

  `bottom`
    Structure/Union member
  `height`
    Rectangle height
  `left`
    Structure/Union member
  `right`
    Structure/Union member
  `top`
    Structure/Union member
  `width`
    Rectangle width

class `grease.geometry.``Vec2d`(x_or_pair, y=None)

  2d vector class, supports vector and scalar operators, and also provides a bunch of high level functions

  `cross`(other)
    The cross product between the vector and other vector
      v1.cross(v2) -> v1.x*v2.y - v2.y-v1.x

    Returns: | The cross product

  `dot`(other)
    The dot product between the vector and other vector
      v1.dot(v2) -> v1.x*v2.x + v1.y*v2.y

    Returns: | The dot product

  `get_angle_between`(other)

    Get the angle between the vector and the other in degrees

    Returns: | The angle

  `get_dist_sqrd`(other)

    The squared distance between the vector and other vector It is more efficent to use this method than to call get_distance() first and then do a sqrt() on the result.

    Returns: | The squared distance

  `get_distance`(other)

    The distance between the vector and other vector

    Returns: | The distance

  `get_length`()

    Get the length of the vector.

    Returns: | The length

  `get_length_sqrd`()

    Get the squared length of the vector. It is more efficent to use this method instead of first call get_length() or access .length and then do a sqrt().

    Returns: | The squared length

  `normalize_return_length`()

    Normalize the vector and return its length before the normalization

    Returns: | The length before the normalization

  `normalized`()

    Get a normalized copy of the vector

    Returns: | A normalized vector

  `rotate`(angle_degrees)
    Rotate the vector by angle_degrees degrees clockwise.
  `rotated`(angle_degrees)

    Create and return a new vector by rotating this vector by angle_degrees degrees clockwise.

    Returns: | Rotated vector

  `angle`
    Gets or sets the angle of a vector
  `length`
    Gets or sets the magnitude of the vector
  `x`
    Structure/Union member
  `y`
    Structure/Union member

### Navigation

- index
- modules |
- next |
- previous |
- Grease v0.2 documentation »