Grease logo

Previous topic

grease.entity – Entity Classes

Next topic

grease – Base Classes

This Page

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)[source]

Simple rectangle. Will gain more functionality as needed

bottom

Structure/Union member

height[source]

Rectangle height

left

Structure/Union member

right

Structure/Union member

top

Structure/Union member

width[source]

Rectangle width

class grease.geometry.Vec2d(x_or_pair, y=None)[source]

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

cross(other)[source]
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)[source]
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)[source]

Get the angle between the vector and the other in degrees

Returns:The angle
get_dist_sqrd(other)[source]

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)[source]

The distance between the vector and other vector

Returns:The distance
get_length()[source]

Get the length of the vector.

Returns:The length
get_length_sqrd()[source]

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()[source]

Normalize the vector and return its length before the normalization

Returns:The length before the normalization
normalized()[source]

Get a normalized copy of the vector

Returns:A normalized vector
rotate(angle_degrees)[source]

Rotate the vector by angle_degrees degrees clockwise.

rotated(angle_degrees)[source]

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