An extension on Line.
This class emposes the length property on a Line. A Segment is a finite Line.
Parameters : | arg1 : point-like arg2 : {point-like, vector}
|
---|---|
Raises : | ValueError :
|
Attributes
bounding_box | [BoundingBox] get the BoundingBox of self. |
length | [scalar] Get the length of the Segment. |
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.’ |
get_point_on_self([frac]) | Get a point on this Segment based on frac. |
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
An extension on Line.
This class emposes the length property on a Line. A Segment is a finite Line.
Parameters : | arg1 : point-like arg2 : {point-like, vector}
|
---|---|
Raises : | ValueError :
|
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}
|
---|---|
Returns : | out : {True, False}
|
Get the points that define the Line by index.
Parameters : | idx : scalar
|
---|---|
Returns : | ret : point
|
[BoundingBox] get the BoundingBox of self.
Get a point on this Segment based on frac.
If no argument is given then the Point on the Segment will be placed randomly.
Parameters : | frac : float, optional |
---|---|
Returns : | out : point |
Raises : | ValueError :
|
Check if point is part of self.
Parameters : | point : point-like
|
---|---|
Returns : | ret : {True, False}
|
See also
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 Segment.
Parameters : | obj : geometric object |
---|---|
Returns : | out : {gometrical object, None}
|
See also
Check if an object is in the form of Line-like for fast computations (not necessary to build lines).
Parameters : | obj : anything |
---|---|
Returns : | res : {True, False} |
Find out if provided Vector or Line-like is parllel to self.
Parameters : | obj : {vector, line-like} |
---|---|
Returns : | ret : {True, False}
|
Find out if provided Line is perpendicular to self.
Returns : | ret : {True, False} |
---|
[scalar] Get self.v.phi. Convenience method.
Rotate self around pivot point.
Parameters : | theta : scalar
point : {point-like}, optional
angle : {‘degrees’, ‘radians’}, optional
|
---|
Translate self by given amounts on x and y.
Parameters : | dx, dy : scalar
|
---|
[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 |