This class provides useful geometric primitives and advanced geometric algorithms.
Type Details
- yfiles module
- algorithms
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.algorithms.Geom
Static Methods
Calculates the convex hull for a set of points.
Complexity
O(n)*log(n), n := points.size()
Parameters
A map of options to pass to the method.
Returns
- ↪YList
- a list of YPoint objects that constitute the convex hull of the given points. The list contains points in counter clockwise order around the hull. The first point is the one with the smallest
x
coordinate. If two such points exist then of these points the one with the smallesty
coordinate is chosen as the first one.
Calculates the intersection point of two affine lines.
Remarks
Parameters
A map of options to pass to the method.
- p1 - YPoint
- origin point of the first line.
- d1 - YVector
- direction vector of the first line.
- p2 - YPoint
- origin point of the second line.
- d2 - YVector
- direction vector of the second line.
Returns
- ↪YPoint
- the intersection point of the specified lines or
null
if there is no intersection.
Calculates the intersection point of two affine lines.
Remarks
Parameters
A map of options to pass to the method.
- p1 - YPoint
- one point on the first line.
- p2 - YPoint
- another point on the first line.
- p3 - YPoint
- one point on the second line.
- p4 - YPoint
- another point on the second line.
Returns
- ↪YPoint
- the intersection point of the specified lines or
null
if there is no intersection.
calcIntersection
(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number) : YPointCalculates the intersection point of two affine lines.
Remarks
Parameters
A map of options to pass to the method.
- x1 - number
- x-coordinate of one point on the first line.
- y1 - number
- y-coordinate of one point on the first line.
- x2 - number
- x-coordinate of another point on the first line.
- y2 - number
- y-coordinate of another point on the first line.
- x3 - number
- x-coordinate of one point on the second line.
- y3 - number
- y-coordinate of one point on the second line.
- x4 - number
- x-coordinate of another point on the second line.
- y4 - number
- y-coordinate of another point on the second line.
Returns
- ↪YPoint
- the intersection point of the specified lines or
null
if there is no intersection.
Intersects the pair of specified source Rectangle2D
objects and puts the result into the specified destination Rectangle2D
object.
Remarks
Parameters
A map of options to pass to the method.
- r1 - Rectangle2D
- the first of a pair of
Rectangle2D
objects to be intersected with each other - r2 - Rectangle2D
- the second of a pair of
Rectangle2D
objects to be intersected with each other - dest - Rectangle2D
- the
Rectangle2D
that holds the results of the intersection ofr1
andr2
Unions the pair of source Rectangle2D
objects and puts the result into the specified destination Rectangle2D
object.
Remarks
r1
. One of the source rectangles can also be the destination to avoid creating a third Rectangle2D object, but in this case the original points of this source rectangle will be overwritten by this method. If the destination is null
, a new Rectangle2D
is created.Parameters
A map of options to pass to the method.
- r1 - Rectangle2D
- the first of a pair of
Rectangle2D
objects to be combined with each other - r2 - Rectangle2D
- the second of a pair of
Rectangle2D
objects to be combined with each other - dest - Rectangle2D
- the
Rectangle2D
that holds the results of the union ofr1
andr2
Returns true
iff the given points are collinear, that is, all three points lie on a common line.
Remarks
distanceToLineSegment
(pointX: number, pointY: number, lineX1: number, lineY1: number, lineX2: number, lineY2: number) : numberDetermines the distance of the point p
to the line segment [l1, l2]
.
Parameters
A map of options to pass to the method.
- pointX - number
- the x coordinate of p
- pointY - number
- the y coordinate of p
- lineX1 - number
- the x coordinate of l1
- lineY1 - number
- the y coordinate of l1
- lineX2 - number
- the x coordinate of l2
- lineY2 - number
- the y coordinate of l2
Same as orientation(p,q,r) > 0
Returns the orientation of point r
relative to the directed line from point p
to point q
.
Remarks
The given tuple of points is said to have positive orientation if p
and q
are distinct and r
lies to the left of the oriented line passing through p
and q
and oriented from p
to q
.
The tuple is said to have negative orientation if p
and q
are distinct and r
lies to the right of the line, and the tuple is said to have orientation zero if the three points are collinear.
Returns
- ↪number
- +1 in the case of positive orientation, -1 in the case of negative orientation and 0 in the case of zero orientation.
Same as orientation with double values as arguments.
projection
(pointX: number, pointY: number, lineX1: number, lineY1: number, lineX2: number, lineY2: number) : YPointDetermines the projection of the point p
onto the line segment [l1, l2]
.
Remarks
- the orthogonal projection of
p
onto the line throughl1
andl2
, iff the projection lies on the line segment[l1, l2]
- the end point of the line segment
[l1, l2]
that is closest top
, otherwise
Parameters
A map of options to pass to the method.
- pointX - number
- the x coordinate of p
- pointY - number
- the y coordinate of p
- lineX1 - number
- the x coordinate of l1
- lineY1 - number
- the y coordinate of l1
- lineX2 - number
- the x coordinate of l2
- lineY2 - number
- the y coordinate of l2
Same as orientation(p,q,r) < 0