mosp :: collide :: Line :: Class Line
[hide private]
[frames] | no frames]

Class Line

source code


A collidable line.


Author: P. Tute

Instance Methods [hide private]
 
__init__(self, x_start, y_start, x_end, y_end)
initializes the collidable Line.
source code
 
__repr__(self)
repr(x)
source code
 
closest_to_point(self, x, y)
Finds the point on this line closest to a given point.
source code
 
collide_circle(self, x, y, radius)
Checks if this line collides with the given circle.
source code
 
collide_horizontal_line(self, x1, x2, y)
Checks if this line collides with a horizontal line.
source code
 
collide_polygon(self, corners)
Nothing Implemented! Checks if this line collides with the given polygon.
source code
 
collide_rectangle(self, x_min, y_min, x_max, y_max)
Checks if this line collides with the given rectangle.
source code
 
collide_vertical_line(self, x, y1, y2)
Checks if this line collides with a vertical line.
source code
 
get_points(self)
Yields the start and end point coordinates (x, y) of the Line.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, x_start, y_start, x_end, y_end)
(Constructor)

source code 

initializes the collidable Line.

x_start, y_start define starting point, x_end, y_end define ending point.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

closest_to_point(self, x, y)

source code 

Finds the point on this line closest to a given point.

Based on http://www.alecjacobson.com/weblog/?p=1486

collide_horizontal_line(self, x1, x2, y)

source code 

Checks if this line collides with a horizontal line.

Returns a boolean and the intersection-coordinates.

collide_polygon(self, corners)

source code 

Nothing Implemented! Checks if this line collides with the given polygon.

Status: not implemented

collide_rectangle(self, x_min, y_min, x_max, y_max)

source code 

Checks if this line collides with the given rectangle.

The algorithm by Cohen & Sutherland is used. It only works for axis-aligned rectangles. http://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland

collide_vertical_line(self, x, y1, y2)

source code 

Checks if this line collides with a vertical line.

Returns a boolean and the intersection-coordinates.