EasyGeometry::D2::LinearEntity
A base class for all linear entities (Line, Ray and Segment) in 2-dimensional Euclidean space.
#direction
The direction vector
of the LinearEntity
.
#angle_between(other)
Return the non-reflex angle
formed by rays emanating from the origin with directions the same as the direction vectors of the linear entities
.
From the dot product of vectors v1 and v2 it is known that:
dot(v1, v2) = |v1|*|v2|*cos(A)
where A is the angle formed between the two vectors. We can get the directional vectors of the two lines and readily find the angle between the two using the above formula.
#parallel_to?(other)
Are two LinearEntity
parallel?
return true
if self and other LinearEntity are parallel, false
otherwise.
#perpendicular_to?(other)
Are two LinearEntity
perpendicular?
return true
if self and other LinearEntity are perpendicular, false
otherwise.
#similar_to?(other)
Are two linear entities
similar?
Return true
if self and other are contained in the same line.
#intersection(entity)
The intersection with another geometrical entity
.
#parallel_line(point)
Create a new Line
parallel to this linear entity
which passes through the point
p.
#perpendicular_line(point)
Create a new Line
perpendicular to this linear entity
which passes through the point
.
#perpendicular_segment(point)
Create a perpendicular line segment
from point
to this line
. The enpoints of the segment are point
and the closest point in the line containing self. (If self is not a line, the point might not be in self.)
#slope
The slope of this linear entity
, or infinity
if vertical.
#span_test(point)
Test whether the point
lies in the positive span of self
. A point x is 'in front' of a point y if x.dot(y) >= 0.
Returns:
-1 if
other
is behindself.p1
0 if
other
isself.p1
1 if
other
is in front ofself.p1
.
Last updated
Was this helpful?