|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.mit.sketch.ddg.Util
public class Util
This class implements several static methods useful for the package.
Util.java Created: Tue Apr 5 19:47:00 2002
| Field Summary | |
|---|---|
static boolean |
DEBUG_MODE
Determines whether the system is in debug mode |
static double |
MAX_ANGULAR_OFFSET
The maximum angle that can be considered negligible |
static double |
MAX_OFFSET
The maximum offset after which the distance between two points cannot be considered negligible |
static double |
OBSTRUCTION_SENSITIVITY
Determines how sensitive constraints are to obstruction |
static double |
SIZE_TO_OFFSET_RATIO
How much larger the object should be than the distance from this object to some other point so that that the confidence distance is just considered negligible |
| Constructor Summary | |
|---|---|
Util()
|
|
| Method Summary | |
|---|---|
static boolean |
aboveLine(Point p,
Line l)
Returns true if the given point is in the upper hyperplane as defined by the line |
static double |
angleNegligible(double angle)
The confidence that the given angle (in radians) can be considered negligible. |
static boolean |
belowLine(Point p,
Line l)
Returns true if the given point is in the lower hyperplane as defined by the line |
static Polygon |
closedContour(DrawnObject object,
ConnectsConstraint connectsConstraint,
IntersectsConstraint intersectsConstraint)
If the given object is a closed contour return a polygon that is the boundary. |
static Point |
closestPoint(Ellipse e,
Point p)
Returns the closest point on the ellipse to the given point |
static Point |
closestPoint(Line line,
Point p)
Returns the closest point on the line to a given point |
static int |
closestPointType(Ellipse e,
Point p)
Returns the closest qualitative point type on the ellipse to the given point |
static void |
debug(java.lang.String txt)
Prints out debugging information if in debugging mode |
static double |
distanceNegligible(double distance,
double objectSize)
The confidence that the given distance can be considered negligible. |
static Line[] |
eightLineEllipseApproximation(Ellipse e)
Approximate the ellipse with 8 lines and return the list |
static GeometricObjectList |
ellipseApproximation(Ellipse e)
Approximate the ellipse with a list of lines and return the list |
static boolean |
isHorizontal(Line line)
|
static boolean |
isVertical(Line line)
|
static boolean |
leftOfLine(Point p,
Line l)
Returns true if the given point is in the left hyperplane as defined by the line |
static double |
minDistance(GeometricObject o1,
GeometricObject o2)
Calculte the minimum distance between two primitives. |
static double |
minLineDistance(Line l1,
Line l2)
Calculate the minimun distance between two line segments |
static boolean |
onSameAxis(Line l1,
Line l2)
|
static double |
parallelity(Line l1,
Line l2)
Returns the degree of parallelity from 0 to 1; |
static Line |
parallelSegment(Line l,
Ellipse e)
Find the closest of the two ellipse segments that are most parallel to the given line |
static boolean |
rightOfLine(Point p,
Line l)
Returns true if the given point is in the right hyperplane as defined by the line |
static double |
roundToPrecision(double value,
int precision)
Round a double to a given number of decimal places |
static boolean |
sameSide(Line line,
Point p1,
Point p2)
Takes in a line, that defines a hyperplane, and returns true is the second point is in the same hyperplane as the first point. |
static double |
sigmoid(double a,
double x,
double b)
Returns the value of the function 1 / (1 + exp{-a*(x - b)}) |
static double |
size(GeometricObject object)
Calculate the size of the geometric object |
static double |
twoSlopeRoofFunction(double value,
double smallWidth,
double largeWidth,
double maxX,
double medY)
Two-slope-roof-like function returning value in the interval [0;1]. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static double SIZE_TO_OFFSET_RATIO
public static double MAX_OFFSET
public static double MAX_ANGULAR_OFFSET
public static double OBSTRUCTION_SENSITIVITY
public static boolean DEBUG_MODE
| Constructor Detail |
|---|
public Util()
| Method Detail |
|---|
public static double angleNegligible(double angle)
The confidence that the given angle (in radians) can be considered negligible. Returns a value in the interval [0;1]. The angle that is larger than MAX_ANGULAR_OFFSET cannont be negligible
public static double distanceNegligible(double distance,
double objectSize)
The confidence that the given distance can be considered negligible.
Returns a value in the interval [0;1].
The distance and object size should be passed in pixels devided by the line width
on the screen. That is the distance is measured in the perceived pixels.
Ideally the confidence depends on two factors:
- object size - the larger, the more the confidence, given the same distance
- distance - the smaller, the more the confidence, given the same size
Here we approximate this function by size factor if distance is below MAX_OFFSET, and by
distance factor if size-to-distance ratio is more than SIZE_TO_OFFSET_RATIO
public static Polygon closedContour(DrawnObject object,
ConnectsConstraint connectsConstraint,
IntersectsConstraint intersectsConstraint)
public static double twoSlopeRoofFunction(double value,
double smallWidth,
double largeWidth,
double maxX,
double medY)
throws InvalidParameterException
InvalidParameterExceptionpublic static void debug(java.lang.String txt)
public static double roundToPrecision(double value,
int precision)
public static double parallelity(Line l1,
Line l2)
public static Line parallelSegment(Line l,
Ellipse e)
public static Line[] eightLineEllipseApproximation(Ellipse e)
public static GeometricObjectList ellipseApproximation(Ellipse e)
public static double minDistance(GeometricObject o1,
GeometricObject o2)
public static double size(GeometricObject object)
public static double minLineDistance(Line l1,
Line l2)
public static boolean aboveLine(Point p,
Line l)
public static boolean belowLine(Point p,
Line l)
public static boolean rightOfLine(Point p,
Line l)
public static boolean leftOfLine(Point p,
Line l)
public static boolean sameSide(Line line,
Point p1,
Point p2)
public static double sigmoid(double a,
double x,
double b)
public static Point closestPoint(Ellipse e,
Point p)
public static int closestPointType(Ellipse e,
Point p)
public static Point closestPoint(Line line,
Point p)
public static boolean isVertical(Line line)
public static boolean isHorizontal(Line line)
public static boolean onSameAxis(Line l1,
Line l2)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||