geo2d.geometry.Ray

class geo2d.geometry.Ray(arg1, arg2)[source]

A Ray extension on Line.

The only difference is that this has a starting Point (p1) which represents the end of the Ray in that direction.

Parameters :

arg1 : point-like

The passed in parameters can be either two points or a Point and a Vector For more on Point-like see the Point class.

arg2 : {point-like, vector}

See arg1.

See also

Line, Segment, Vector

Attributes

p1 [point] Get the 1st Point that defines the Line.
p2 [point] Get the 2nd Point that defines the Line.
phi [scalar] Get self.v.phi. Convenience method.
v [vector] Get the Vector pointing from self.p1 to`self.p2`.

Methods

__contains__(x) Searches for x in “itself”.
__getitem__(idx) Get the points that define the Line by index.
__len__() The Line is made of 2 points so it’s length is 2.’
has(point) Check if point is part of self.
intersection(obj) Tries to find the Point of intersection.
is_line_like(obj) Check if an object is in the form of Line-like for fast
parallel_to(obj) Find out if provided Vector or Line-like is
perpendicular_to(obj) Find out if provided Line is perpendicular to self.
rotate(theta[, point, angle]) Rotate self around pivot point.
translate(dx, dy) Translate self by given amounts on x and y.

Detailed description

class geo2d.geometry.Ray(arg1, arg2)[source]

A Ray extension on Line.

The only difference is that this has a starting Point (p1) which represents the end of the Ray in that direction.

Parameters :

arg1 : point-like

The passed in parameters can be either two points or a Point and a Vector For more on Point-like see the Point class.

arg2 : {point-like, vector}

See arg1.

See also

Line, Segment, Vector

__contains__(x)

Searches for x in “itself”. If we’re talking about a Point or a Vector then this searches within their components (x, y). For everything else it searches within the list of points (vertices).

Parameters :

x : {point, scalar}

The object to search for.

Returns :

out : {True, False}

True if we find x in self, else False.

__getitem__(idx)

Get the points that define the Line by index.

Parameters :

idx : scalar

The index for Point.

Returns :

ret : point

Selected Point by index.

__len__()

The Line is made of 2 points so it’s length is 2.’

has(point)[source]

Check if point is part of self.

Parameters :

point : point-like

The Point to check.

Returns :

ret : {True, False}

If the point is on the Ray then return True, else False.

intersection(obj)[source]

Tries to find the Point of intersection.

The difference between this and the Line intersection method is that this has also the constrain that if the Point of intersection is on the line then it also must be within the bounds of the Ray.

Parameters :

obj : geometric object

Returns :

out : {gometric object, None}

GeometricObject if intersection is possible, else the cases from Line.intersection.

static is_line_like(obj)

Check if an object is in the form of Line-like for fast computations (not necessary to build lines).

Parameters :

obj : anything

obj is checked if is of type Line (i.e. not Ray nor Segment) or if this is not true then of the form: ((0, 1), (3, 2)) or [[0, 2], [3, 2]] or even combinations of these.

Returns :

res : {True, False}

p1

[point] Get the 1st Point that defines the Line.

p2

[point] Get the 2nd Point that defines the Line.

parallel_to(obj)

Find out if provided Vector or Line-like is parllel to self.

Parameters :

obj : {vector, line-like}

The Vector or Line-like to compare parallelism with.

Returns :

ret : {True, False}

If self and Line are parallel then retrun True, else False.

perpendicular_to(obj)

Find out if provided Line is perpendicular to self.

Returns :ret : {True, False}
phi

[scalar] Get self.v.phi. Convenience method.

rotate(theta, point=None, angle='degrees')

Rotate self around pivot point.

Parameters :

theta : scalar

The angle to be rotated by.

point : {point-like}, optional

If given this will be used as the rotation pivot.

angle : {‘degrees’, ‘radians’}, optional

This tells the function how theta is passed: as degrees or as radians. Default is degrees.

translate(dx, dy)

Translate self by given amounts on x and y.

Parameters :

dx, dy : scalar

Amount to translate (relative movement).

v

[vector] Get the Vector pointing from self.p1 to`self.p2`.

[Arnon1983]Arnon et al., A Linear Time Algorithm for the Minimum Area Rectangle Enclosing a Convex Polygon” (1983), Computer Science Technical Reports. Paper 382
[WPolygon]http://en.wikipedia.org/wiki/Polygon

Previous topic

geo2d.geometry.Line

Next topic

geo2d.geometry.Segment

This Page