Packagecom.yworks.yfiles.geom
Classpublic class Geom
InheritanceGeom Inheritance YObject Inheritance Object

This class provides useful geometric primitives and advanced geometric algorithms.

This class is intended to provide static methods for geometric calculations. It can be compared to the class java.lang.Math which provides methods for general mathematical calculations.



Public Methods
 MethodDefined By
  
Geom(init:Boolean = true)
Geom
  
[static] Calculates the convex hull for a set of points.
Geom
  
[static] Intersects the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.
Geom
  
[static] Calculates the intersection point of two affine lines.
Geom
  
[static] Calculates the intersection point of two affine lines.
Geom
  
calcIntersection4(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, x4:Number, y4:Number):YPoint
[static] Calculates the intersection point of two affine lines.
Geom
  
calcTransformedBounds(x:Number, y:Number, width:Number, height:Number, transform:AffineTransform, dest:Rectangle2D):Rectangle2D
[static] Calculates the bounding box of the rectangle at location (x,y) with the specified width and height after the specified transformation has been applied.
Geom
  
[static] Unions the pair of source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.
Geom
  
collinear(p:YPoint, q:YPoint, r:YPoint):Boolean
[static] Returns true iff the given points are collinear, i.e.
Geom
  
distanceToLineSegment(pointX:Number, pointY:Number, lineX1:Number, lineY1:Number, lineX2:Number, lineY2:Number):Number
[static] Determines the distance of the point p to the line segment [l1, l2].
Geom
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
Geom
 Inherited
hashCode():int
YObject
  
leftTurn(p:YPoint, q:YPoint, r:YPoint):Boolean
[static] Same as orientation(p,q,r) > 0 (orientation())
Geom
  
linesIntersect(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, x4:Number, y4:Number):Boolean
[static] Same as java.awt.geom.Line2D.linesIntersect().
Geom
  
[static] Returns the orientation of point r relative to the directed line from point p to point q.
Geom
  
orientation2(px:Number, py:Number, qx:Number, qy:Number, rx:Number, ry:Number):int
[static] Same as orientation() with double values as arguments.
Geom
  
projection(pointX:Number, pointY:Number, lineX1:Number, lineY1:Number, lineX2:Number, lineY2:Number):YPoint
[static] Determines the projection of the point p onto the line segment [l1, l2].
Geom
  
rightTurn(p:YPoint, q:YPoint, r:YPoint):Boolean
[static] Same as orientation(p,q,r) < 0 (orientation())
Geom
  
[static] Returns +1 if point d lies left of the directed circle through points a, b, and c, 0 if a,b,c and d are cocircular, and -1 otherwise.
Geom
  
toDegrees(angrad:Number):Number
[static] Same as Math.toDegrees().
Geom
  
toRadians(angdeg:Number):Number
[static] Same as Math.toRadians().
Geom
Constructor Detail
Geom()Constructor
public function Geom(init:Boolean = true)



Parameters
init:Boolean (default = true)
Method Detail
calcConvexHull()method
public static function calcConvexHull(points:YList):YList

Calculates the convex hull for a set of points.

Complexity O(n)*log(n), n := points.size()

Parameters

points:YList — a list of com.yworks.yfiles.geom.YPoint objects

Returns
YList — a list of com.yworks.yfiles.geom.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 smallest y coordinate is chosen as the first one.

See also

calcIntersection()method 
public static function calcIntersection(r1:Rectangle2D, r2:Rectangle2D, dest:Rectangle2D):Rectangle2D

Intersects the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object. If one or both of the source rectangles have negative width or height, the resulting rectangle will be located at (0,0) with a width and height of -1. 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.

Parameters

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 of r1 and r2

Returns
Rectangle2D
calcIntersection2()method 
public static function calcIntersection2(p1:YPoint, d1:YVector, p2:YPoint, d2:YVector):YPoint

Calculates the intersection point of two affine lines. Each line is given by a point and a direction vector.

Parameters

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.
calcIntersection3()method 
public static function calcIntersection3(p1:YPoint, p2:YPoint, p3:YPoint, p4:YPoint):YPoint

Calculates the intersection point of two affine lines. Each line is given by two points.

Parameters

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.
calcIntersection4()method 
public static function calcIntersection4(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, x4:Number, y4:Number):YPoint

Calculates the intersection point of two affine lines. Each line is given by the coordinates of two points.

Parameters

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.
calcTransformedBounds()method 
public static function calcTransformedBounds(x:Number, y:Number, width:Number, height:Number, transform:AffineTransform, dest:Rectangle2D):Rectangle2D

Calculates the bounding box of the rectangle at location (x,y) with the specified width and height after the specified transformation has been applied.

Parameters

x:Number — the x coordinate of the rectangle to be transformed
 
y:Number — the y coordinate of the rectangle to be transformed
 
width:Number — the width of the rectangle to be transformed
 
height:Number — the height of the rectangle to be transformed
 
transform:AffineTransform — the AffineTransform to be applied
 
dest:Rectangle2D — the Rectangle2D that holds the bounding box of the transformed input

Returns
Rectangle2D
calcUnion()method 
public static function calcUnion(r1:Rectangle2D, r2:Rectangle2D, dest:Rectangle2D):Rectangle2D

Unions the pair of source Rectangle2D objects and puts the result into the specified destination Rectangle2D object. If one of the source rectangles has negative width or height, it is excluded from the union. If both source rectangles have negative width or height, the destination rectangle will become a copy of 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

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 of r1 and r2

Returns
Rectangle2D
collinear()method 
public static function collinear(p:YPoint, q:YPoint, r:YPoint):Boolean

Returns true iff the given points are collinear, i.e. all three points lie on a common line.

Same as orientation(p,q,r) == 0 (orientation())

Parameters

p:YPoint
 
q:YPoint
 
r:YPoint

Returns
Boolean

See also

distanceToLineSegment()method 
public static function distanceToLineSegment(pointX:Number, pointY:Number, lineX1:Number, lineY1:Number, lineX2:Number, lineY2:Number):Number

Determines the distance of the point p to the line segment [l1, l2].

Parameters

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

Returns
Number
getClass()method 
override public function getClass():Class

Returns
Class
leftTurn()method 
public static function leftTurn(p:YPoint, q:YPoint, r:YPoint):Boolean

Same as orientation(p,q,r) > 0 (orientation())

Parameters

p:YPoint
 
q:YPoint
 
r:YPoint

Returns
Boolean

See also

linesIntersect()method 
public static function linesIntersect(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, x4:Number, y4:Number):Boolean

Same as java.awt.geom.Line2D.linesIntersect().

Parameters

x1:Number
 
y1:Number
 
x2:Number
 
y2:Number
 
x3:Number
 
y3:Number
 
x4:Number
 
y4:Number

Returns
Boolean

See also

java.awt.geom.Line2D.linesIntersect()
orientation()method 
public static function orientation(p:YPoint, q:YPoint, r:YPoint):int

Returns the orientation of point r relative to the directed line from point p to point q.

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.

Parameters

p:YPoint
 
q:YPoint
 
r:YPoint

Returns
int+1 in the case of positive orientation, -1 in the case of negative orientation and 0 in the case of zero orientation.
orientation2()method 
public static function orientation2(px:Number, py:Number, qx:Number, qy:Number, rx:Number, ry:Number):int

Same as orientation() with double values as arguments.

Parameters

px:Number
 
py:Number
 
qx:Number
 
qy:Number
 
rx:Number
 
ry:Number

Returns
int

See also

projection()method 
public static function projection(pointX:Number, pointY:Number, lineX1:Number, lineY1:Number, lineX2:Number, lineY2:Number):YPoint

Determines the projection of the point p onto the line segment [l1, l2]. The resulting point is

Parameters

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

Returns
YPoint
rightTurn()method 
public static function rightTurn(p:YPoint, q:YPoint, r:YPoint):Boolean

Same as orientation(p,q,r) < 0 (orientation())

Parameters

p:YPoint
 
q:YPoint
 
r:YPoint

Returns
Boolean

See also

sideOfCircle()method 
public static function sideOfCircle(a:YPoint, b:YPoint, c:YPoint, d:YPoint):int

Returns +1 if point d lies left of the directed circle through points a, b, and c, 0 if a,b,c and d are cocircular, and -1 otherwise.

Parameters

a:YPoint
 
b:YPoint
 
c:YPoint
 
d:YPoint

Returns
int
toDegrees()method 
public static function toDegrees(angrad:Number):Number

Same as Math.toDegrees().

Parameters

angrad:Number

Returns
Number

See also

Math.toDegrees()
toRadians()method 
public static function toRadians(angdeg:Number):Number

Same as Math.toRadians().

Parameters

angdeg:Number

Returns
Number

See also

Math.toRadians()