Class Index | File Index

Classes


Namespace URBGEN.Util

holds utility functions.
Defined in: UrbGen.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
<static>  
URBGEN.Util.addAngle(angle, dA)
Adds the specified dA (dA * Pi) to the specified angle.
<static>  
URBGEN.Util.areaPoly(poly)
Returns the area of the specified polygon.
<static>  
URBGEN.Util.checkNearPoints(point, -, distance, includeEnds)
Returns a point on the specified edge that is within the specified distance of the specified point.
<static>  
URBGEN.Util.divideLine(p0, p1, length)
Returns a path of equidistant points on the linesegment p0p1.
<static>  
URBGEN.Util.getAngle(p0, p1)
Returns the angle of the line segment p0p1 in radians.
<static>  
URBGEN.Util.getDirectedPath(p0, p1, direction, maxSteps)
Returns an array of points representing a path from p0 to p1 in the specified direction.
<static>  
URBGEN.Util.getIntersect(p0, a0, p1, a1)
Given two lines, defined by a point on the line and the angle of the line, returns the point at which the two lines intersect.
<static>  
URBGEN.Util.getLineSegmentLength(p0, p1)
Returns the length of the line segment p0p1.
<static>  
URBGEN.Util.getNeighbors(point, -)
Returns the two points closest in opposite directions to the specified point.
<static>  
URBGEN.Util.getPointAsRatio(point, p0, p1)
Returns a value that represents the specified point's location on the line through p0 and p1, relative to the line segment p0p1.
<static>  
URBGEN.Util.insertPoint(newPoint, p0, p1)
Sets the neighbor relations of p0 and p1 with the newPoint.
<static>  
URBGEN.Util.insetPoly(poly, length)
Returns an inward offset of the specified polygon.
<static>  
URBGEN.Util.linearInterpolate(p0, p1, r)
Finds a point on the line segment p0p1 using the r value (ratio of the line).
<static>  
URBGEN.Util.linearInterpolateByLength(p0, p1, length)
Returns a point on the line segment p0p1 which is the specified length along the line.
<static>  
URBGEN.Util.nearest(points, target)
Returns the point in points that has the shortest straight line distance to target.
<static>  
URBGEN.Util.offsetLineSegment(p0, p1, distance)
Returns a path representing the (right) offset of the line segment p0p1.
<static>  
URBGEN.Util.unitNormal(p0, p1)
Returns the unit normal for the line segment p0p1.
<static>  
URBGEN.Util.unitVector(p0, p1)
Returns a point representing the unit vector for the line segment p0p1.
<static>  
URBGEN.Util.unitVectorByAngle(p0, angle)
Returns a point representing the unit vector from p0 in the specified angle.
Namespace Detail
URBGEN.Util
Method Detail
<static> {number} URBGEN.Util.addAngle(angle, dA)
Adds the specified dA (dA * Pi) to the specified angle. The result is normalized to a value between 0 and 2 * Pi radians.
Parameters:
{number} angle
- The angle in radians.
{number} dA
- The factor of PI to add to the angle.
Returns:
{number} The resultant angle in radians.

<static> {number} URBGEN.Util.areaPoly(poly)
Returns the area of the specified polygon.
Parameters:
{URBGEN.Poly} poly
- The polygon.
Returns:
{number} The polygon's area.

<static> {URBGEN.Point} URBGEN.Util.checkNearPoints(point, -, distance, includeEnds)
Returns a point on the specified edge that is within the specified distance of the specified point. If includeEnds is true, then the start and end points of the edge will be included in the search. If no such point exists, returns the original point.
Parameters:
{URBGEN.Point} point
- The point to find near points for.
{URBGEN.Point[]} -
The path of potential near points.
{number} distance
- The distance within which near points can be found.
{boolean} includeEnds
- true if the start and end points should be included, false if not.
Returns:
{URBGEN.Point} The closest point to the specified point, or the original point is no such near point exists.

<static> {URBGEN.Point[]} URBGEN.Util.divideLine(p0, p1, length)
Returns a path of equidistant points on the linesegment p0p1. Note that the distance between the second last point and the end point (p1) can be of any length.
Parameters:
{URBGEN.Point} p0
- The start point of the line segment.
{URBGEN.Point} p1
- The end point of the line segment.
{number} length
- The distance between each point in the path.
Throws:
{URBGEN.Exception.PointsNotNeighborsException}
Returns:
{URBGEN.Point[]} The path of equidistant points.

<static> {number} URBGEN.Util.getAngle(p0, p1)
Returns the angle of the line segment p0p1 in radians.
Parameters:
{URBGEN.Point} p0
- The start point of the line segment.
{URBGEN.Point} p1
- The end point of the line segment.
Returns:
{number} The angle in radians of the line segment.

<static> {URBGEN.Point[]} URBGEN.Util.getDirectedPath(p0, p1, direction, maxSteps)
Returns an array of points representing a path from p0 to p1 in the specified direction. If p1 is not found in maxSteps iterations, returns false. If maxSteps is not specified, defaults to 1000.
Parameters:
{URBGEN.Point} p0
- The start point of the path.
{URBGEN.Point} p1
- The end point of the path.
{number} direction
- The direction of the path.
{number} maxSteps
- The maximum number of iterations.
Returns:
{URBGEN.Point[]} The path from p0 t0 p1.

<static> {URBGEN.Point} URBGEN.Util.getIntersect(p0, a0, p1, a1)
Given two lines, defined by a point on the line and the angle of the line, returns the point at which the two lines intersect. If the lines are colinear, returns p0.
Parameters:
{URBGEN.Point} p0
- The start point of the first line.
{number} a0
- The angle in radians of the first line.
{URBGEN.Point} p1
- The start point of the second line.
{number} a1
- The angle in radians of the second line.
Returns:
{URBGEN.Point} The intersection of the two lines.

<static> {number} URBGEN.Util.getLineSegmentLength(p0, p1)
Returns the length of the line segment p0p1.
Parameters:
{URBGEN.Point} p0
- the start point of the line segment.
{URBGEN.Point} p1
- the end point of the line segment.
Returns:
{number} The length of the line segment.

<static> {Object} URBGEN.Util.getNeighbors(point, -)
Returns the two points closest in opposite directions to the specified point.
Parameters:
{URBGEN.Point} point
- The point to find neighbors for.
{URBGEN.Point[]} -
The path of potential neighbors.
Throws:
{URBGEN.Exception.PointOutOfRangeException}
Returns:
{Object} The prev and nxt points to the specified point.

<static> {number} URBGEN.Util.getPointAsRatio(point, p0, p1)
Returns a value that represents the specified point's location on the line through p0 and p1, relative to the line segment p0p1.
Parameters:
{URBGEN.Point} point
- The point.
{URBGEN.Point} p0
- A point on the line.
{URBGEN.Point} p1
- a different point on the line.
Returns:
{number} The r value (ratio) of the point on the line.

<static> {boolean} URBGEN.Util.insertPoint(newPoint, p0, p1)
Sets the neighbor relations of p0 and p1 with the newPoint. If p0 and p1 are not neighbors, returns false, otherwise true.
Parameters:
{URBGEN.Point} newPoint
- The new point.
{URBGEN.Point} p0
- The first neighbor point.
{URNGEN.Point} p1
- The second neighbor point.
Returns:
{boolean} True if successful, false otherwise.

<static> {URBGEN.Poly} URBGEN.Util.insetPoly(poly, length)
Returns an inward offset of the specified polygon. That is, the returned polygon is formed by insetting the edges of the specified polygon.
Parameters:
{URGBEN.Poly} poly
- The poly to offset.
{number} length
- The distance of the inward offset.
Returns:
{URBGEN.Poly} The offset polygon.

<static> {URBGEN.Point} URBGEN.Util.linearInterpolate(p0, p1, r)
Finds a point on the line segment p0p1 using the r value (ratio of the line).
Parameters:
{URBGEN.Point} p0
- The start point of the line.
{URBGEN.Point} p1
- The end point of the line.
{number} r
- The r value of the new point.
Returns:
{URBGEN.Point} The new point.

<static> {URBGEN.Point} URBGEN.Util.linearInterpolateByLength(p0, p1, length)
Returns a point on the line segment p0p1 which is the specified length along the line.
Parameters:
{URBGEN.Point} p0
- The start point of the line.
{URBGEN.Point} p1
- The end point of the line.
{number} length
- The length along the line of the new point.
Returns:
{URBGEN.Point} The new point.

<static> {URBGEN.Point} URBGEN.Util.nearest(points, target)
Returns the point in points that has the shortest straight line distance to target. If any points have equal distances to target, returns the point which comse first in points.
Parameters:
{URBGEN.Point[]} points
- The points in which to look for the closest point.
{URBGEN.Point} target
- The target point.
Returns:
{URBGEN.Point} The point that is closest to the target.

<static> {URBGEN.Point[]} URBGEN.Util.offsetLineSegment(p0, p1, distance)
Returns a path representing the (right) offset of the line segment p0p1.
Parameters:
{URBGEN.Point} p0
- The start point of the line segment.
{URBGEN.Point} p1
- The end point of the line segment.
{number} distance
- The distance to offset the line to the right.
Returns:
{URBGEN.Point[]} Array containing the start and end points of the offset line segment.

<static> {URBGEN.Point} URBGEN.Util.unitNormal(p0, p1)
Returns the unit normal for the line segment p0p1.
Parameters:
{URBGEN.Point} p0
- The start point of the line segment.
{URBGEN.Point} p1
- The end point of the line segment.
Returns:
{URBGEN.Point} The unit normal.

<static> {URBGEN.Point} URBGEN.Util.unitVector(p0, p1)
Returns a point representing the unit vector for the line segment p0p1.
Parameters:
{URBGEN.Point} p0
- The start point of the line segment.
{URBGEN.Point} p1
- The end point of the line segment.
Returns:
{URBGEN.Point} The unit vector.

<static> {URBGEN.Point} URBGEN.Util.unitVectorByAngle(p0, angle)
Returns a point representing the unit vector from p0 in the specified angle.
Parameters:
{URBGEN.Point} p0
- The start point of the unit vector.
{number} angle
- The anlge in radians of the unit vector.
Returns:
{URBGEN.Point} The unit vector.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Sep 04 2014 11:25:30 GMT+0100 (BST)