diva.sketch.features

## Class FEUtilities

• ```public class FEUtilities
extends Object```
Common calculation methods used in path filtering and feature extraction processes.
Version:
\$Revision: 1.17 \$
Author:
Heloise Hse (hwawen@eecs.berkeley.edu)
• ### Constructor Summary

Constructors
Constructor and Description
`FEUtilities()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```calcAngle(Line2D line1, Line2D line2)```
Calculate the angle (in radians) in between the given vectors.
`static double` ```calcLengthRatio(Line2D line1, Line2D line2)```
Calculate the ratio of line1's length and line2's length.
`static double` ```computeAngle(double xhead, double yhead, double xtail, double ytail)```
Given a 2D vector, find the angle (in radians) formed between this vector and the horizontal vector pointing in the positive x direction.
`static double` ```distance(double x1, double y1, double x2, double y2)```
Return the Euclidean distance between two points, (x1, y1) and (x2, y2).
`static double` ```distanceSquared(double x1, double y1, double x2, double y2)```
Return the square of the distance between two points, (x1, y1) and (x2, y2).
`static double` ```dotProduct(double x1, double y1, double x2, double y2, double x3, double y3)```
Return the dot product of the vector (x1, y1)(x2, y2) and the vector (x2, y2)(x3, y3).
`static double` ```dotProduct(double p1xh, double p1yh, double p1xt, double p1yt, double p2xh, double p2yh, double p2xt, double p2yt)```
Return the dot product of the vector (p1xh, p1yh)(p1xt, p1yt) and the vector (p2xh,p2yh)(p2xt, p2yt) h = head, t = tail, tail-------->head
`static double` ```findArea(Point2D p1, Point2D p2, Point2D p3)```
Given three points each represents the vertex of a triangle, return the area of this triangle.
`static double` ```findSlope(double p1x, double p1y, double p2x, double p2y)```
Find the slope of the line formed by two points (p1x, p1y) and (p2x, p2y).
`static double` ```pathLength(double[] xvals, double[] yvals, int num)```
Return the total pathlength by summing over the distance of consecutive points in the array.
`static double` ```pathLength(double[] xvals, double[] yvals, int startIndex, int endIndex)```
calculate the path length starting from the startIndex to the endIndex (inclusive) of the points in the array.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### FEUtilities

`public FEUtilities()`
• ### Method Detail

• #### calcAngle

```public static double calcAngle(Line2D line1,
Line2D line2)```
Calculate the angle (in radians) in between the given vectors.
• #### calcLengthRatio

```public static double calcLengthRatio(Line2D line1,
Line2D line2)```
Calculate the ratio of line1's length and line2's length. (line1/line2);
• #### computeAngle

```public static double computeAngle(double xhead,
double xtail,
double ytail)```
Given a 2D vector, find the angle (in radians) formed between this vector and the horizontal vector pointing in the positive x direction. Return Double.NaN if the 2 points given are the same points.
• #### distance

```public static double distance(double x1,
double y1,
double x2,
double y2)```
Return the Euclidean distance between two points, (x1, y1) and (x2, y2).
• #### distanceSquared

```public static double distanceSquared(double x1,
double y1,
double x2,
double y2)```
Return the square of the distance between two points, (x1, y1) and (x2, y2).
• #### dotProduct

```public static double dotProduct(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)```
Return the dot product of the vector (x1, y1)(x2, y2) and the vector (x2, y2)(x3, y3).
• #### dotProduct

```public static double dotProduct(double p1xh,
double p1yh,
double p1xt,
double p1yt,
double p2xh,
double p2yh,
double p2xt,
double p2yt)```
Return the dot product of the vector (p1xh, p1yh)(p1xt, p1yt) and the vector (p2xh,p2yh)(p2xt, p2yt) h = head, t = tail, tail-------->head
• #### findArea

```public static double findArea(Point2D p1,
Point2D p2,
Point2D p3)```
Given three points each represents the vertex of a triangle, return the area of this triangle.
• #### findSlope

```public static double findSlope(double p1x,
double p1y,
double p2x,
double p2y)```
Find the slope of the line formed by two points (p1x, p1y) and (p2x, p2y).
• #### pathLength

```public static double pathLength(double[] xvals,
double[] yvals,
int num)```
Return the total pathlength by summing over the distance of consecutive points in the array.
• #### pathLength

```public static double pathLength(double[] xvals,
double[] yvals,
int startIndex,
int endIndex)```
calculate the path length starting from the startIndex to the endIndex (inclusive) of the points in the array.