Class Index | File Index

Classes


Namespace Util


Defined in: util.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
<static>  
Util.distance(p1, p2)
Returns the distance between 2 points
<static>  
Util.feather(rectangle, size)
Increase the area of a rectangle by size in any direction
<static>  
Util.getAngle(centerPoint, outsidePoint, round)
Will return the angle of rotation between 2 points, with 0 being north.
<static>  
Util.getAngle3Points(startPoint, centerPoint, endPoint, round)
Computes the angle formed by 3 {Point}s
<static>  
Util.getBounds(points)
Return the bounds for a given set of points, useful as every class uses a similar implementation.
<static>  
Util.getEndPoint(startPoint, length, angle)
It will return the end point of a line on a given angle (clockwise).
<static>  
Util.getLength(startPoint, endPoint)
Returns the lenght between 2 points
<static>  
Returns the length of a Polyline that would be created with a set of points
<static>  
Util.getUnionBounds(shapes)
<static>  
Util.isPointInside(point, points)
/* Tests whether a point is inside the area (excluding border) determined by a set of other points.
<static>  
Util.lineIntersectsLine(l1, l2)
Test to see if 2 {Line}s intersects.
<static>  
Util.lineIntersectsRectangle(startPoint, endPoint, bounds)
Tests if a a line defined by 2 points intersects a rectangle
<static>  
Util.max(v)
Returns the max of a vector
<static>  
Util.min(v)
Returns the min of a vector
<static>  
Util.pointCrossingsForCubic(px, py, x0, y0, xc0, yc0, xc1, yc1, x1, y1, level)
Calculates the number of times the cubic from (x0,y0) to (x1,y1) crosses the ray extending to the right from (px,py).
<static>  
Util.pointCrossingsForLine(px, py, x0, y0, x1, y1)
Calculates the number of times the line from (x0,y0) to (x1,y1) crosses the ray extending to the right from (px,py).
<static>  
Util.round(number, decimals)
Namespace Detail
Util
Method Detail
<static> {Number} Util.distance(p1, p2)
Returns the distance between 2 points
Author: Alex Gheorghiu .
Parameters:
{Point} p1
- first {Point}
{Point} p2
- second {Point}
Returns:
{Number} - the distance between those 2 points. It is always positive.

<static> {Array} Util.feather(rectangle, size)
Increase the area of a rectangle by size in any direction
Author: Alex Gheorghiu .
Parameters:
{Array} rectangle
- the [topX, topY, bottomX, bottomY]
{Number} size
- the size to increase the rectangle in any direction
Returns:
{Array} - the new reactangle increased :)

<static> {Number} Util.getAngle(centerPoint, outsidePoint, round)
Will return the angle of rotation between 2 points, with 0 being north. Actually the angle with N on a compass
Author: Alex Gheorghiu .
Parameters:
{@link Point} centerPoint
- the point that is to be considered the center of the shape
{@link Point} outsidePoint
- the point that we need to find the rotation about the center.
{Number} round
- amount to round to nearest angle (optional)
Returns:
{Number} - the angle in radians
See:
/documentation/specs/getAngle.png

<static> Util.getAngle3Points(startPoint, centerPoint, endPoint, round)
Computes the angle formed by 3 {Point}s
Author: Alex Gheorghiu .
Parameters:
{@link Point} startPoint
- the start point
{@link Point} centerPoint
- the center/tid of the angle point
{@link Point} endPoint
- the end/angle point
{Number} round
- amount to round to nearest angle (optional)

<static> {Array} Util.getBounds(points)
Return the bounds for a given set of points, useful as every class uses a similar implementation.
Author: Maxim Georgievskiy .
Parameters:
{Array} points
- the points collected around the outside of the shape.
Returns:
{Array} - returns [minX, minY, maxX, maxY] - bounds, where all points are in the bounds.

<static> {Point} Util.getEndPoint(startPoint, length, angle)
It will return the end point of a line on a given angle (clockwise).
Parameters:
{Point} startPoint
- the start of the line
{Number} length
- the length of the line
{Number} angle
- the angle of the line in radians
Returns:
{Point} - the endPoint of the line

<static> {Number} Util.getLength(startPoint, endPoint)
Returns the lenght between 2 points
Parameters:
{Point} startPoint
- one point
{Point} endPoint
- the other point
Returns:
{Number} - the distance

<static> {Number} Util.getPolylineLength(v)
Returns the length of a Polyline that would be created with a set of points
Parameters:
{Array} v
- an {Array} of {Points}
Returns:
{Number} - a positive number equal with total length

<static> Util.getUnionBounds(shapes)
Parameters:
shapes

<static> Util.isPointInside(point, points)
/* Tests whether a point is inside the area (excluding border) determined by a set of other points. If the points is on the border of the area it will not be counted
Parameters:
point
{Point} the point we want to chek
points
{Array} a set of points ordered clockwise.
See:
http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/ solution 1

<static> {Boolean} Util.lineIntersectsLine(l1, l2)
Test to see if 2 {Line}s intersects. They are considered finite segments and not the infinite lines from geometry
Author: Alex Gheorghiu , Maxim Georgievskiy .
Parameters:
{Line} l1
- fist line/segment
{Line} l2
- last line/segment
Returns:
{Boolean} true - if the lines intersect or false if not

<static> Util.lineIntersectsRectangle(startPoint, endPoint, bounds)
Tests if a a line defined by 2 points intersects a rectangle
Author: Alex Gheorghiu .
Parameters:
{Point} startPoint
- the starting point
{Point} endPoint
- the ending point
{Array} bounds
- the bounds of the rectangle defined by (x1, y1, x2, y2)
Returns:
true - if line intersects the rectangle, false - if not

<static> {Number} Util.max(v)
Returns the max of a vector
Author: alex@scriptoid.com.
Parameters:
{Array} v
- vector of {Number}s
Returns:
{Number} - the maximum number from the vector or NaN if vector is empty

<static> {Number} Util.min(v)
Returns the min of a vector
Author: alex@scriptoid.com.
Parameters:
{Array} v
- vector of {Number}s
Returns:
{Number} - the minimum number from the vector or NaN if vector is empty

<static> Util.pointCrossingsForCubic(px, py, x0, y0, xc0, yc0, xc1, yc1, x1, y1, level)
Calculates the number of times the cubic from (x0,y0) to (x1,y1) crosses the ray extending to the right from (px,py). If the point lies on a part of the curve, then no crossings are counted for that intersection. the level parameter should be 0 at the top-level call and will count up for each recursion level to prevent infinite recursion +1 is added for each crossing where the Y coordinate is increasing -1 is added for each crossing where the Y coordinate is decreasing
Parameters:
px
py
x0
y0
xc0
yc0
xc1
yc1
x1
y1
level

<static> Util.pointCrossingsForLine(px, py, x0, y0, x1, y1)
Calculates the number of times the line from (x0,y0) to (x1,y1) crosses the ray extending to the right from (px,py). If the point lies on the line, then no crossings are recorded. +1 is returned for a crossing where the Y coordinate is increasing -1 is returned for a crossing where the Y coordinate is decreasing
Parameters:
px
py
x0
y0
x1
y1

<static> Util.round(number, decimals)
Parameters:
number
decimals

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Jun 09 2011 12:47:27 GMT+0300 (EEST)