code
stringlengths 67
466k
| docstring
stringlengths 1
13.2k
|
---|---|
public static double ChiSquare(double[] histogram1, double[] histogram2) {
double r = 0;
for (int i = 0; i < histogram1.length; i++) {
double t = histogram1[i] + histogram2[i];
if (t != 0)
r += Math.pow(histogram1[i] - histogram2[i], 2) / t;
}
return 0.5 * r;
} | Gets the Chi Square distance between two normalized histograms.
@param histogram1 Histogram.
@param histogram2 Histogram.
@return The Chi Square distance between x and y. |
public static double Correlation(double[] p, double[] q) {
double x = 0;
double y = 0;
for (int i = 0; i < p.length; i++) {
x += -p[i];
y += -q[i];
}
x /= p.length;
y /= q.length;
double num = 0;
double den1 = 0;
double den2 = 0;
for (int i = 0; i < p.length; i++) {
num += (p[i] + x) * (q[i] + y);
den1 += Math.abs(Math.pow(p[i] + x, 2));
den2 += Math.abs(Math.pow(q[i] + x, 2));
}
return 1 - (num / (Math.sqrt(den1) * Math.sqrt(den2)));
} | Gets the Correlation distance between two points.
@param p A point in space.
@param q A point in space.
@return The Correlation distance between x and y. |
public static double Cosine(double[] p, double[] q) {
double sumProduct = 0;
double sumP = 0, sumQ = 0;
for (int i = 0; i < p.length; i++) {
sumProduct += p[i] * q[i];
sumP += Math.pow(Math.abs(p[i]), 2);
sumQ += Math.pow(Math.abs(q[i]), 2);
}
sumP = Math.sqrt(sumP);
sumQ = Math.sqrt(sumQ);
double result = 1 - (sumProduct / (sumP * sumQ));
return result;
} | Gets the Cosine distance between two points.
@param p A point in space.
@param q A point in space.
@return The Cosine distance between x and y. |
public static double Cosine(double x1, double y1, double x2, double y2) {
double sumProduct = x1 * x2 + y1 * y2;
double sumP = Math.pow(Math.abs(x1), 2) + Math.pow(Math.abs(x2), 2);
double sumQ = Math.pow(Math.abs(y1), 2) + Math.pow(Math.abs(y2), 2);
sumP = Math.sqrt(sumP);
sumQ = Math.sqrt(sumQ);
double result = 1 - (sumProduct / (sumP * sumQ));
return result;
} | Gets the Cosine distance between two points.
@param x1 X1 axis coordinate.
@param y1 Y1 axis coordinate.
@param x2 X2 axis coordinate.
@param y2 Y2 axis coordinate.
@return The Cosine distance between x and y. |
public static double Cosine(IntPoint p, IntPoint q) {
return Cosine(p.x, p.y, q.x, q.y);
} | Gets the Cosine distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@return The Cosine distance between x and y. |
public static double Euclidean(double x1, double y1, double x2, double y2) {
double dx = Math.abs(x1 - x2);
double dy = Math.abs(y1 - y2);
return Math.sqrt(dx * dx + dy * dy);
} | Gets the Euclidean distance between two points.
@param x1 X1 axis coordinate.
@param y1 Y1 axis coordinate.
@param x2 X2 axis coordinate.
@param y2 Y2 axis coordinate.
@return The Euclidean distance between x and y. |
public static double Euclidean(IntPoint p, IntPoint q) {
return Euclidean(p.x, p.y, q.x, q.y);
} | Gets the Euclidean distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@return The Euclidean distance between x and y. |
public static int Hamming(String first, String second) {
if (first.length() != second.length())
throw new IllegalArgumentException("The size of string must be the same.");
int diff = 0;
for (int i = 0; i < first.length(); i++)
if (first.charAt(i) != second.charAt(i))
diff++;
return diff;
} | Gets the Hamming distance between two strings.
@param first First string.
@param second Second string.
@return The Hamming distance between p and q. |
public static double JaccardDistance(double[] p, double[] q) {
double distance = 0;
int intersection = 0, union = 0;
for (int x = 0; x < p.length; x++) {
if ((p[x] != 0) || (q[x] != 0)) {
if (p[x] == q[x]) {
intersection++;
}
union++;
}
}
if (union != 0)
distance = 1.0 - ((double) intersection / (double) union);
else
distance = 0;
return distance;
} | Gets the Jaccard distance between two points.
@param p A point in space.
@param q A point in space.
@return The Jaccard distance between x and y. |
public static double JensenShannonDivergence(double[] p, double[] q) {
double[] m = new double[p.length];
for (int i = 0; i < m.length; i++) {
m[i] = (p[i] + q[i]) / 2;
}
return (KullbackLeiblerDivergence(p, m) + KullbackLeiblerDivergence(q, m)) / 2;
} | Gets the Jensen Shannon divergence.
@param p U vector.
@param q V vector.
@return The Jensen Shannon divergence between u and v. |
public static double KumarJohnsonDivergence(double[] p, double[] q) {
double r = 0;
for (int i = 0; i < p.length; i++) {
if (p[i] != 0 && q[i] != 0) {
r += Math.pow(p[i] * p[i] - q[i] * q[i], 2) / 2 * Math.pow(p[i] * q[i], 1.5);
}
}
return r;
} | Gets the Kumar-Johnson divergence.
@param p P vector.
@param q Q vector.
@return The Kumar-Johnson divergence between p and q. |
public static double KullbackLeiblerDivergence(double[] p, double[] q) {
boolean intersection = false;
double k = 0;
for (int i = 0; i < p.length; i++) {
if (p[i] != 0 && q[i] != 0) {
intersection = true;
k += p[i] * Math.log(p[i] / q[i]);
}
}
if (intersection)
return k;
else
return Double.POSITIVE_INFINITY;
} | Gets the Kullback Leibler divergence.
@param p P vector.
@param q Q vector.
@return The Kullback Leibler divergence between u and v. |
public static double Mahalanobis(double[][] A, double[][] B) {
if (A[0].length != B[0].length)
throw new IllegalArgumentException("The number of columns of both matrix must be equals.");
double[][] subA = new double[A.length][A[0].length];
double[][] subB = new double[B.length][B[0].length];
//Center data A
double[] meansA = new double[A[0].length];
for (int j = 0; j < A[0].length; j++) {
for (int i = 0; i < A.length; i++) {
meansA[j] += A[i][j];
}
meansA[j] /= (double) A.length;
for (int i = 0; i < A.length; i++) {
subA[i][j] = A[i][j] - meansA[j];
}
}
//Center data B
double[] meansB = new double[B[0].length];
for (int j = 0; j < B[0].length; j++) {
for (int i = 0; i < B.length; i++) {
meansB[j] += B[i][j];
}
meansB[j] /= (double) B.length;
for (int i = 0; i < B.length; i++) {
subB[i][j] = B[i][j] - meansB[j];
}
}
//Matrix of covariance
double[][] covA = Covariance(subA);
double[][] covB = Covariance(subB);
//Pooled covariance
double rows = subA.length + subB.length;
double[][] pCov = new double[covA.length][covA[0].length];
for (int i = 0; i < pCov.length; i++) {
for (int j = 0; j < pCov[0].length; j++) {
pCov[i][j] = covA[i][j] * ((double) subA.length / rows) + covB[i][j] * ((double) subB.length / rows);
}
}
//Inverse of pooled covariance
pCov = Matrix.Inverse(pCov);
//compute mean difference
double[] diff = new double[A[0].length];
for (int i = 0; i < diff.length; i++) {
diff[i] = meansA[i] - meansB[i];
}
return Math.sqrt(Matrix.InnerProduct(Matrix.MultiplyByTranspose(pCov, diff), diff));
} | Gets the Mahalanobis distance.
@param A Matrix A.
@param B Matrix B.
@return The Mahalanobis distance between A and B. |
public static double Manhattan(double[] p, double[] q) {
double sum = 0;
for (int i = 0; i < p.length; i++) {
sum += Math.abs(p[i] - q[i]);
}
return sum;
} | Gets the Manhattan distance between two points.
@param p A point in space.
@param q A point in space.
@return The Manhattan distance between x and y. |
public static double Manhattan(IntPoint p, IntPoint q) {
return Manhattan(p.x, p.y, q.x, q.y);
} | Gets the Manhattan distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@return The Manhattan distance between x and y. |
public static double Minkowski(double x1, double y1, double x2, double y2, int r) {
double sum = Math.pow(Math.abs(x1 - x2), r);
sum += Math.pow(Math.abs(y1 - y2), r);
return Math.pow(sum, 1 / r);
} | Gets the Minkowski distance between two points.
@param x1 X1 axis coordinate.
@param y1 Y1 axis coordinate.
@param x2 X2 axis coordinate.
@param y2 Y2 axis coordinate.
@param r Order between two points.
@return The Minkowski distance between x and y. |
public static double Minkowski(IntPoint p, IntPoint q, int r) {
return Minkowski(p.x, p.y, q.x, q.y, r);
} | Gets the Minkowski distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@param r Order between two points.
@return The Minkowski distance between x and y. |
public static double Minkowski(double[] u, double[] v, double p) {
double distance = 0;
for (int i = 0; i < u.length; i++) {
distance += Math.pow(Math.abs(u[i] - v[i]), p);
}
return Math.pow(distance, 1 / p);
} | Gets the Minkowski distance between two points.
@param u A point in space.
@param v A point in space.
@param p Order between two points.
@return The Minkowski distance between x and y. |
public static double QuasiEuclidean(double x1, double y1, double x2, double y2) {
if (Math.abs(x1 - x2) > Math.abs(y1 - y2)) {
return Math.abs(x1 - x2) + (Constants.Sqrt2 - 1) * Math.abs(y1 - y2);
}
return (Constants.Sqrt2 - 1) * Math.abs(x1 - x2) + Math.abs(y1 - y2);
} | Gets the Quasi-Euclidean distance between two points.
@param x1 X1 axis coordinates.
@param y1 Y1 axis coordinates.
@param x2 X2 axis coordinates.
@param y2 Y2 axis coordinates.
@return The Quasi-Euclidean distance between x and y. |
public static double QuasiEuclidean(IntPoint p, IntPoint q) {
return QuasiEuclidean(p.x, p.y, q.x, q.y);
} | Gets the Quasi-Euclidean distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@return The Quasi Euclidean distance between p and q. |
public static double SquaredEuclidean(double[] x, double[] y) {
double d = 0.0, u;
for (int i = 0; i < x.length; i++) {
u = x[i] - y[i];
d += u * u;
}
return d;
} | Gets the Square Euclidean distance between two points.
@param x A point in space.
@param y A point in space.
@return The Square Euclidean distance between x and y. |
public static double SquaredEuclidean(double x1, double y1, double x2, double y2) {
double dx = x2 - x1;
double dy = y2 - y1;
return dx * dx + dy * dy;
} | Gets the Squared Euclidean distance between two points.
@param x1 X1 axis coordinates.
@param y1 Y1 axis coordinates.
@param x2 X2 axis coordinates.
@param y2 Y2 axis coordinates.
@return The Squared euclidean distance between x and y. |
public static double SquaredEuclidean(IntPoint p, IntPoint q) {
double dx = q.x - p.x;
double dy = q.y - p.y;
return dx * dx + dy * dy;
} | Gets the Squared Euclidean distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@return The Squared euclidean distance between x and y. |
public static double SymmetricChiSquareDivergence(double[] p, double[] q) {
double r = 0;
for (int i = 0; i < p.length; i++) {
double den = p[i] * q[i];
if (den != 0) {
double p1 = p[i] - q[i];
double p2 = p[i] + q[i];
r += (p1 * p1 * p2) / den;
}
}
return r;
} | Gets the Symmetric Chi-square divergence.
@param p P vector.
@param q Q vector.
@return The Symmetric chi-square divergence between p and q. |
public static double SymmetricKullbackLeibler(double[] p, double[] q) {
double dist = 0;
for (int i = 0; i < p.length; i++) {
dist += (p[i] - q[i]) * (Math.log(p[i]) - Math.log(q[i]));
}
return dist;
} | Gets the Symmetric Kullback-Leibler distance.
This metric is valid only for real and positive P and Q.
@param p P vector.
@param q Q vector.
@return The Symmetric Kullback Leibler distance between p and q. |
public static double Taneja(double[] p, double[] q) {
double r = 0;
for (int i = 0; i < p.length; i++) {
if (p[i] != 0 && q[i] != 0) {
double pq = p[i] + q[i];
r += (pq / 2) * Math.log(pq / (2 * Math.sqrt(p[i] * q[i])));
}
}
return r;
} | Gets the Taneja divergence.
@param p P vector.
@param q Q vector.
@return The Taneja divergence between p and q. |
public static double TopsoeDivergence(double[] p, double[] q) {
double r = 0;
for (int i = 0; i < p.length; i++) {
if (p[i] != 0 && q[i] != 0) {
double den = p[i] + q[i];
r += p[i] * Math.log(2 * p[i] / den) + q[i] * Math.log(2 * q[i] / den);
}
}
return r;
} | Gets the Topsoe divergence.
@param p P vector.
@param q Q vector.
@return The Topsoe divergence between p and q. |
public DeviceTypePricingTier createPricingTiers(String dtid, DeviceTypePricingTier pricingTierInfo) throws ApiException {
ApiResponse<DeviceTypePricingTier> resp = createPricingTiersWithHttpInfo(dtid, pricingTierInfo);
return resp.getData();
} | Define devicetype's pricing tiers.
Define devicetype's pricing tiers.
@param dtid DeviceType ID (required)
@param pricingTierInfo Pricing tier info (required)
@return DeviceTypePricingTier
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DeviceTypePricingTier> createPricingTiersWithHttpInfo(String dtid, DeviceTypePricingTier pricingTierInfo) throws ApiException {
com.squareup.okhttp.Call call = createPricingTiersValidateBeforeCall(dtid, pricingTierInfo, null, null);
Type localVarReturnType = new TypeToken<DeviceTypePricingTier>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Define devicetype's pricing tiers.
Define devicetype's pricing tiers.
@param dtid DeviceType ID (required)
@param pricingTierInfo Pricing tier info (required)
@return ApiResponse<DeviceTypePricingTier>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public DevicePricingTiersEnvelope getPricingTiers(String did, Boolean active) throws ApiException {
ApiResponse<DevicePricingTiersEnvelope> resp = getPricingTiersWithHttpInfo(did, active);
return resp.getData();
} | Get a device's pricing tiers
Get a device's pricing tiers
@param did Device ID (required)
@param active Filter by active (optional)
@return DevicePricingTiersEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DevicePricingTiersEnvelope> getPricingTiersWithHttpInfo(String did, Boolean active) throws ApiException {
com.squareup.okhttp.Call call = getPricingTiersValidateBeforeCall(did, active, null, null);
Type localVarReturnType = new TypeToken<DevicePricingTiersEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get a device's pricing tiers
Get a device's pricing tiers
@param did Device ID (required)
@param active Filter by active (optional)
@return ApiResponse<DevicePricingTiersEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public DeviceTypePricingTiersEnvelope getThePricingTiers(String dtid, Integer version) throws ApiException {
ApiResponse<DeviceTypePricingTiersEnvelope> resp = getThePricingTiersWithHttpInfo(dtid, version);
return resp.getData();
} | Get devicetype's pricing tiers.
Get devicetype's pricing tiers.
@param dtid DeviceType ID (required)
@param version Version (required)
@return DeviceTypePricingTiersEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DeviceTypePricingTiersEnvelope> getThePricingTiersWithHttpInfo(String dtid, Integer version) throws ApiException {
com.squareup.okhttp.Call call = getThePricingTiersValidateBeforeCall(dtid, version, null, null);
Type localVarReturnType = new TypeToken<DeviceTypePricingTiersEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get devicetype's pricing tiers.
Get devicetype's pricing tiers.
@param dtid DeviceType ID (required)
@param version Version (required)
@return ApiResponse<DeviceTypePricingTiersEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public UpgradePathEnvelope getUpgradePath(String did, String action) throws ApiException {
ApiResponse<UpgradePathEnvelope> resp = getUpgradePathWithHttpInfo(did, action);
return resp.getData();
} | Get upgrade path
Get upgrade path
@param did Device ID (required)
@param action Action to perform (required)
@return UpgradePathEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<UpgradePathEnvelope> getUpgradePathWithHttpInfo(String did, String action) throws ApiException {
com.squareup.okhttp.Call call = getUpgradePathValidateBeforeCall(did, action, null, null);
Type localVarReturnType = new TypeToken<UpgradePathEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get upgrade path
Get upgrade path
@param did Device ID (required)
@param action Action to perform (required)
@return ApiResponse<UpgradePathEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public DevicePricingTierEnvelope setPricingTier(String did, DevicePricingTierRequest pricingTier) throws ApiException {
ApiResponse<DevicePricingTierEnvelope> resp = setPricingTierWithHttpInfo(did, pricingTier);
return resp.getData();
} | Set a device's pricing tier
Set a device's pricing tier
@param did Device ID (required)
@param pricingTier Pricing tier (required)
@return DevicePricingTierEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DevicePricingTierEnvelope> setPricingTierWithHttpInfo(String did, DevicePricingTierRequest pricingTier) throws ApiException {
com.squareup.okhttp.Call call = setPricingTierValidateBeforeCall(did, pricingTier, null, null);
Type localVarReturnType = new TypeToken<DevicePricingTierEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Set a device's pricing tier
Set a device's pricing tier
@param did Device ID (required)
@param pricingTier Pricing tier (required)
@return ApiResponse<DevicePricingTierEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
Triangle nextNeighbor(Vector3 p, Triangle prevTriangle) {
Triangle neighbor = null;
if (a.equals(p)) {
neighbor = canext;
}
if (b.equals(p)) {
neighbor = abnext;
}
if (c.equals(p)) {
neighbor = bcnext;
}
if(prevTriangle == null) {
return neighbor;
}
// Udi Schneider: Added a condition check for isHalfPlane. If the current
// neighbor is a half plane, we also want to move to the next neighbor
if (neighbor.equals(prevTriangle) || neighbor.isHalfplane()) {
if (a.equals(p)) {
neighbor = abnext;
}
if (b.equals(p)) {
neighbor = bcnext;
}
if (c.equals(p)) {
neighbor = canext;
}
}
return neighbor;
} | Returns the neighbors that shares the given corner and is not the previous triangle.
@param p The given corner
@param prevTriangle The previous triangle.
@return The neighbors that shares the given corner and is not the previous triangle.
By: Eyal Roth & Doron Ganel. |
public boolean contains(Vector3 p) {
boolean ans = false;
if(this.halfplane || p== null) return false;
if (isCorner(p)) {
return true;
}
PointLinePosition a12 = PointLineTest.pointLineTest(a,b,p);
PointLinePosition a23 = PointLineTest.pointLineTest(b,c,p);
PointLinePosition a31 = PointLineTest.pointLineTest(c,a,p);
if ((a12 == PointLinePosition.LEFT && a23 == PointLinePosition.LEFT && a31 == PointLinePosition.LEFT ) ||
(a12 == PointLinePosition.RIGHT && a23 == PointLinePosition.RIGHT && a31 == PointLinePosition.RIGHT ) ||
(a12 == PointLinePosition.ON_SEGMENT ||a23 == PointLinePosition.ON_SEGMENT || a31 == PointLinePosition.ON_SEGMENT)) {
ans = true;
}
return ans;
} | determinates if this triangle contains the point p.
@param p the query point
@return true iff p is not null and is inside this triangle (Note: on boundary is considered inside!!). |
public boolean fallInsideCircumcircle(Vector3[] arrayPoints) {
boolean isInside = false;
Vector3 p1 = this.p1();
Vector3 p2 = this.p2();
Vector3 p3 = this.p3();
int i = 0;
while(!isInside && i<arrayPoints.length)
{
Vector3 p = arrayPoints[i];
if(!p.equals(p1)&& !p.equals(p2) && !p.equals(p3))
{
isInside = this.circumcircleContains(p);
}
i++;
}
return isInside;
} | Doron |
public float z_value(Vector3 q) {
if(q==null || this.halfplane) throw new RuntimeException("*** ERR wrong parameters, can't approximate the z value ..***: "+q);
/* incase the query point is on one of the points */
if(q.x==a.x & q.y==a.y) return a.z;
if(q.x==b.x & q.y==b.y) return b.z;
if(q.x==c.x & q.y==c.y) return c.z;
/*
* plane: aX + bY + c = Z:
* 2D line: y= mX + k
*
*/
float x=0,x0 = q.x, x1 = a.x, x2=b.x, x3=c.x;
float y=0,y0 = q.y, y1 = a.y, y2=b.y, y3=c.y;
float z=0, m01=0,k01=0,m23=0,k23=0;
float r = 0;
// 0 - regular, 1-horizontal , 2-vertical.
int flag01 = 0;
if(x0!=x1) {
m01 = (y0-y1)/(x0-x1);
k01 = y0 - m01*x0;
if (m01 ==0) {
flag01 = 1;
}
} else { // 2-vertical.
flag01 = 2;//x01 = x0
}
int flag23 = 0;
if(x2!=x3) {
m23 = (y2-y3)/(x2-x3);
k23 = y2 - m23*x2;
if (m23 ==0) {
flag23 = 1;
}
}
else { // 2-vertical.
flag23 = 2;//x01 = x0
}
if (flag01 ==2 ) {
x = x0;
y = m23*x + k23;
}
else {
if(flag23==2) {
x = x2;
y = m01*x + k01;
}
else { // regular case
x=(k23-k01)/(m01-m23);
y = m01*x+k01;
}
}
if(flag23==2) {
r=(y2-y)/(y2-y3);
} else {
r=(x2-x)/(x2-x3);
}
z = b.z + (c.z-b.z)*r;
if(flag01==2) {
r=(y1-y0)/(y1-y);
} else {
r=(x1-x0)/(x1-x);
}
float qZ = a.z + (z-a.z)*r;
return qZ;
} | compute the Z value for the X,Y values of q. <br />
assume this triangle represent a plane --> q does NOT need to be contained
in this triangle.
@param q query point (its Z value is ignored).
@return the Z value of this plane implies by this triangle 3 points. |
public Vector3 z(Vector3 q) {
float z = z_value(q);
return new Vector3(q.x, q.y, z);
} | compute the Z value for the X,Y values of q.
assume this triangle represent a plane --> q does NOT need to be contained
in this triangle.
@param q query point (its Z value is ignored).
@return q with updated Z value. |
public static float calcDet(Vector3 a ,Vector3 b, Vector3 c) {
return (a.x*(b.y-c.y)) - (a.y*(b.x-c.x)) + (b.x*c.y-b.y*c.x);
} | checks if the triangle is not re-entrant |
public int sharedSegments(Triangle t2) {
int counter = 0;
if(a.equals(t2.a)) {
counter++;
}
if(a.equals(t2.b)) {
counter++;
}
if(a.equals(t2.c)) {
counter++;
}
if(b.equals(t2.a)) {
counter++;
}
if(b.equals(t2.b)) {
counter++;
}
if(b.equals(t2.c)) {
counter++;
}
if(c.equals(t2.a)) {
counter++;
}
if(c.equals(t2.b)) {
counter++;
}
if(c.equals(t2.c)) {
counter++;
}
return counter;
} | checks if the 2 triangles shares a segment
@author Doron Ganel & Eyal Roth(2009)
@param t2 - a second triangle
@return boolean |
private void update(){
total = 0;
for (int i = 0; i < values.length; i++) {
total += values[i];
}
mean = HistogramStatistics.Mean( values );
stdDev = HistogramStatistics.StdDev( values, mean );
kurtosis = HistogramStatistics.Kurtosis(values, mean, stdDev);
skewness = HistogramStatistics.Skewness(values, mean, stdDev);
median = HistogramStatistics.Median( values );
mode = HistogramStatistics.Mode(values);
entropy = HistogramStatistics.Entropy(values);
} | Update histogram. |
@Override
public ImageSource apply(ImageSource source) {
if (radius != 0) {
if (source.isGrayscale()) {
return applyGrayscale(source, radius);
} else {
return applyRGB(source, radius);
}
} else {
if (source.isGrayscale()) {
return applyGrayscale(source, kernel);
} else {
return applyRGB(source, kernel);
}
}
} | Apply filter to an image.
@param source FastBitmap |
public <T> T handleResponse(Response response, Type returnType) throws ApiException {
if (response.isSuccessful()) {
if (returnType == null || response.code() == 204) {
// returning null if the returnType is not defined,
// or the status code is 204 (No Content)
return null;
} else {
return deserialize(response, returnType);
}
} else {
String respBody = null;
if (response.body() != null) {
try {
respBody = response.body().string();
} catch (IOException e) {
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
}
}
throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody);
}
} | Handle the given response, return the deserialized object when the response is successful.
@param <T> Type
@param response Response
@param returnType Return type
@throws ApiException If the response has a unsuccessful status code or
fail to deserialize the response body
@return Type |
public void add(int ds, Object value) throws SerializationException, InvalidDataSetException {
if (value == null) {
return;
}
DataSetInfo dsi = dsiFactory.create(ds);
byte[] data = dsi.getSerializer().serialize(value, activeSerializationContext);
DataSet dataSet = new DefaultDataSet(dsi, data);
dataSets.add(dataSet);
} | Adds a data set to IIM file.
@param ds
data set id (see constants in IIM class)
@param value
data set value. Null values are silently ignored.
@throws SerializationException
if value can't be serialized by data set's serializer
@throws InvalidDataSetException
if data set isn't defined |
public void addDateTimeHelper(int ds, Date date) throws SerializationException, InvalidDataSetException {
if (date == null) {
return;
}
DataSetInfo dsi = dsiFactory.create(ds);
SimpleDateFormat df = new SimpleDateFormat(dsi.getSerializer().toString());
String value = df.format(date);
byte[] data = dsi.getSerializer().serialize(value, activeSerializationContext);
DataSet dataSet = new DefaultDataSet(dsi, data);
add(dataSet);
} | Adds a data set with date-time value to IIM file.
@param ds
data set id (see constants in IIM class)
@param date
date to set. Null values are silently ignored.
@throws SerializationException
if value can't be serialized by data set's serializer
@throws InvalidDataSetException
if data set isn't defined |
public Object get(int dataSet) throws SerializationException {
Object result = null;
for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) {
DataSet ds = i.next();
DataSetInfo info = ds.getInfo();
if (info.getDataSetNumber() == dataSet) {
result = getData(ds);
break;
}
}
return result;
} | Gets a first data set value.
@param dataSet
IIM record and dataset code (See constants in {@link IIM})
@return data set value
@throws SerializationException
if value can't be deserialized from binary representation |
public List<Object> getAll(int dataSet) throws SerializationException {
List<Object> result = new ArrayList<Object>();
for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) {
DataSet ds = i.next();
DataSetInfo info = ds.getInfo();
if (info.getDataSetNumber() == dataSet) {
result.add(getData(ds));
}
}
return result;
} | Gets all data set values.
@param dataSet
IIM record and dataset code (See constants in {@link IIM})
@return data set value
@throws SerializationException
if value can't be deserialized from binary representation |
public Date getDateTimeHelper(int dateDataSet, int timeDataSet) throws SerializationException {
DataSet dateDS = null;
DataSet timeDS = null;
for (Iterator<DataSet> i = dataSets.iterator(); (dateDS == null || timeDS == null) && i.hasNext();) {
DataSet ds = i.next();
DataSetInfo info = ds.getInfo();
if (info.getDataSetNumber() == dateDataSet) {
dateDS = ds;
} else if (info.getDataSetNumber() == timeDataSet) {
timeDS = ds;
}
}
Date result = null;
if (dateDS != null && timeDS != null) {
DataSetInfo dateDSI = dateDS.getInfo();
DataSetInfo timeDSI = timeDS.getInfo();
SimpleDateFormat format = new SimpleDateFormat(dateDSI.getSerializer().toString()
+ timeDSI.getSerializer().toString());
StringBuffer date = new StringBuffer(20);
try {
date.append(getData(dateDS));
date.append(getData(timeDS));
result = format.parse(date.toString());
} catch (ParseException e) {
throw new SerializationException("Failed to read date (" + e.getMessage() + ") with format " + date);
}
}
return result;
} | Gets combined date/time value from two data sets.
@param dateDataSet
data set containing date value
@param timeDataSet
data set containing time value
@return date/time instance
@throws SerializationException
if data sets can't be deserialized from binary format or
can't be parsed |
public void readFrom(IIMReader reader, int recover) throws IOException, InvalidDataSetException {
final boolean doLog = log != null;
for (;;) {
try {
DataSet ds = reader.read();
if (ds == null) {
break;
}
if (doLog) {
log.debug("Read data set " + ds);
}
DataSetInfo info = ds.getInfo();
Serializer s = info.getSerializer();
if (s != null) {
if (info.getDataSetNumber() == IIM.DS(1, 90)) {
setCharacterSet((String) s.deserialize(ds.getData(), activeSerializationContext));
}
}
dataSets.add(ds);
if (stopAfter9_10 && info.getDataSetNumber() == IIM.DS(9, 10))
break;
} catch (IIMFormatException e) {
if (recoverFromIIMFormat && recover-- > 0) {
boolean r = reader.recover();
if (doLog) {
log.debug(r ? "Recoved from " + e : "Failed to recover from " + e);
}
if (!r)
break;
} else {
throw e;
}
} catch (UnsupportedDataSetException e) {
if (recoverFromUnsupportedDataSet && recover-- > 0) {
boolean r = reader.recover();
if (doLog) {
log.debug(r ? "Recoved from " + e : "Failed to recover from " + e);
}
if (!r)
break;
} else {
throw e;
}
} catch (InvalidDataSetException e) {
if (recoverFromInvalidDataSet && recover-- > 0) {
boolean r = reader.recover();
if (doLog) {
log.debug(r ? "Recoved from " + e : "Failed to recover from " + e);
}
if (!r)
break;
} else {
throw e;
}
} catch (IOException e) {
if (recover-- > 0 && !dataSets.isEmpty()) {
if (doLog) {
log.error("IOException while reading, however some data sets where recovered, " + e);
}
return;
} else {
throw e;
}
}
}
} | Reads data sets from a passed reader.
@param reader
data sets source
@param recover
max number of errors reading process will try to recover from.
Set to 0 to fail immediately
@throws IOException
if reader can't read underlying stream
@throws InvalidDataSetException
if invalid/undefined data set is encountered |
public void writeTo(IIMWriter writer) throws IOException {
final boolean doLog = log != null;
for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) {
DataSet ds = i.next();
writer.write(ds);
if (doLog) {
log.debug("Wrote data set " + ds);
}
}
} | Writes this IIMFile to writer.
@param writer
writer to write to
@throws IOException
if file can't be written to |
public Set<ConstraintViolation> validate(DataSetInfo info) {
Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>();
try {
if (info.isMandatory() && get(info.getDataSetNumber()) == null) {
errors.add(new ConstraintViolation(info, ConstraintViolation.MANDATORY_MISSING));
}
if (!info.isRepeatable() && getAll(info.getDataSetNumber()).size() > 1) {
errors.add(new ConstraintViolation(info, ConstraintViolation.REPEATABLE_REPEATED));
}
} catch (SerializationException e) {
errors.add(new ConstraintViolation(info, ConstraintViolation.INVALID_VALUE));
}
return errors;
} | Checks if data set is mandatory but missing or non repeatable but having
multiple values in this IIM instance.
@param info
IIM data set to check
@return list of constraint violations, empty set if data set is valid |
public Set<ConstraintViolation> validate(int record) {
Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>();
for (int ds = 0; ds < 250; ++ds) {
try {
DataSetInfo dataSetInfo = dsiFactory.create(IIM.DS(record, ds));
errors.addAll(validate(dataSetInfo));
} catch (InvalidDataSetException ignored) {
// DataSetFactory doesn't know about this ds, so will skip it
}
}
return errors;
} | Checks all data sets in a given record for constraint violations.
@param record
IIM record (1,2,3, ...) to check
@return list of constraint violations, empty set if IIM file is valid |
public Set<ConstraintViolation> validate() {
Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>();
for (int record = 1; record <= 3; ++record) {
errors.addAll(validate(record));
}
return errors;
} | Checks all data sets in IIM records 1, 2 and 3 for constraint violations.
@return list of constraint violations, empty set if IIM file is valid |
@Override
public ImageSource apply(ImageSource input) {
if (input.isGrayscale()) {
return input;
}
if (!isAlgorithm) {
double r, g, b, gray;
for (int i = 0; i < EffectHelper.getSize(input); i++) {
r = EffectHelper.getRed(i, input);
g = EffectHelper.getGreen(i, input);
b = EffectHelper.getBlue(i, input);
int a = EffectHelper.getAlpha(i, input);
gray = (r * redCoefficient + g * greenCoefficient + b * blueCoefficient);
EffectHelper.setRGB(i, (int) gray, (int) gray, (int) gray, a, input);
}
return input;
} else {
return apply(input, grayscaleMethod);
}
} | Apply filter to a FastBitmap.
@param input Image to be processed. |
public DeviceStatus getDeviceStatus(String deviceId, Boolean includeSnapshot, Boolean includeSnapshotTimestamp) throws ApiException {
ApiResponse<DeviceStatus> resp = getDeviceStatusWithHttpInfo(deviceId, includeSnapshot, includeSnapshotTimestamp);
return resp.getData();
} | Get Device Status
Get Device Status
@param deviceId Device ID. (required)
@param includeSnapshot Include device snapshot into the response (optional)
@param includeSnapshotTimestamp Include device snapshot timestamp into the response (optional)
@return DeviceStatus
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DeviceStatus> getDeviceStatusWithHttpInfo(String deviceId, Boolean includeSnapshot, Boolean includeSnapshotTimestamp) throws ApiException {
com.squareup.okhttp.Call call = getDeviceStatusValidateBeforeCall(deviceId, includeSnapshot, includeSnapshotTimestamp, null, null);
Type localVarReturnType = new TypeToken<DeviceStatus>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get Device Status
Get Device Status
@param deviceId Device ID. (required)
@param includeSnapshot Include device snapshot into the response (optional)
@param includeSnapshotTimestamp Include device snapshot timestamp into the response (optional)
@return ApiResponse<DeviceStatus>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public com.squareup.okhttp.Call getDeviceStatusAsync(String deviceId, Boolean includeSnapshot, Boolean includeSnapshotTimestamp, final ApiCallback<DeviceStatus> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = getDeviceStatusValidateBeforeCall(deviceId, includeSnapshot, includeSnapshotTimestamp, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<DeviceStatus>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | Get Device Status (asynchronously)
Get Device Status
@param deviceId Device ID. (required)
@param includeSnapshot Include device snapshot into the response (optional)
@param includeSnapshotTimestamp Include device snapshot timestamp into the response (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object |
public DeviceStatusBatch getDevicesStatus(String dids, Boolean includeSnapshot, Boolean includeSnapshotTimestamp) throws ApiException {
ApiResponse<DeviceStatusBatch> resp = getDevicesStatusWithHttpInfo(dids, includeSnapshot, includeSnapshotTimestamp);
return resp.getData();
} | Get Devices Status
Get Devices Status
@param dids List of device ids (comma-separated) for which the statuses are requested. (required)
@param includeSnapshot Include device snapshot into the response (optional)
@param includeSnapshotTimestamp Include device snapshot timestamp into the response (optional)
@return DeviceStatusBatch
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DeviceStatusBatch> getDevicesStatusWithHttpInfo(String dids, Boolean includeSnapshot, Boolean includeSnapshotTimestamp) throws ApiException {
com.squareup.okhttp.Call call = getDevicesStatusValidateBeforeCall(dids, includeSnapshot, includeSnapshotTimestamp, null, null);
Type localVarReturnType = new TypeToken<DeviceStatusBatch>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get Devices Status
Get Devices Status
@param dids List of device ids (comma-separated) for which the statuses are requested. (required)
@param includeSnapshot Include device snapshot into the response (optional)
@param includeSnapshotTimestamp Include device snapshot timestamp into the response (optional)
@return ApiResponse<DeviceStatusBatch>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public DeviceStatus putDeviceStatus(String deviceId, DeviceStatusPut body) throws ApiException {
ApiResponse<DeviceStatus> resp = putDeviceStatusWithHttpInfo(deviceId, body);
return resp.getData();
} | Update Device Status
Update Device Status
@param deviceId Device ID. (required)
@param body Body (optional)
@return DeviceStatus
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DeviceStatus> putDeviceStatusWithHttpInfo(String deviceId, DeviceStatusPut body) throws ApiException {
com.squareup.okhttp.Call call = putDeviceStatusValidateBeforeCall(deviceId, body, null, null);
Type localVarReturnType = new TypeToken<DeviceStatus>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Update Device Status
Update Device Status
@param deviceId Device ID. (required)
@param body Body (optional)
@return ApiResponse<DeviceStatus>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public int compare(Vector3 o1, Vector3 o2) {
int ans = 0;
if (o1 != null && o2 != null) {
Vector3 d1 = o1;
Vector3 d2 = o2;
if (d1.x > d2.x)
return 1;
if (d1.x < d2.x)
return -1;
// x1 == x2
if (d1.y > d2.y)
return 1;
if (d1.y < d2.y)
return -1;
} else {
if (o1 == null && o2 == null)
return 0;
if (o1 == null && o2 != null)
return 1;
if (o1 != null && o2 == null)
return -1;
}
return ans;
} | compare between two points. |
public double nextDouble(double lo, double hi) {
if (lo < 0) {
if (nextInt(2) == 0)
return -nextDouble(0, -lo);
else
return nextDouble(0, hi);
} else {
return (lo + (hi - lo) * nextDouble());
}
} | Generate a uniform random number in the range [lo, hi)
@param lo lower limit of range
@param hi upper limit of range
@return a uniform random real in the range [lo, hi) |
public void permutate(int[] x) {
for (int i = 0; i < x.length; i++) {
int j = i + nextInt(x.length - i);
int s = x[i];
x[i] = x[j];
x[j] = s;
}
} | Generates a permutation of given array. |
public ApiResponse<TagsEnvelope> getTagCategoriesWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = getTagCategoriesValidateBeforeCall(null, null);
Type localVarReturnType = new TypeToken<TagsEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get all categories
Get all tags marked as categories
@return ApiResponse<TagsEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public TagsEnvelope getTagSuggestions(String entityType, String tags, String name, Integer count) throws ApiException {
ApiResponse<TagsEnvelope> resp = getTagSuggestionsWithHttpInfo(entityType, tags, name, count);
return resp.getData();
} | Get tag suggestions
Get tag suggestions for applications, device types that have been most used with a group of tags.
@param entityType Entity type name. (optional)
@param tags Comma separated list of tags. (optional)
@param name Name of tags used for type ahead. (optional)
@param count Number of results to return. Max 10. (optional)
@return TagsEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<TagsEnvelope> getTagSuggestionsWithHttpInfo(String entityType, String tags, String name, Integer count) throws ApiException {
com.squareup.okhttp.Call call = getTagSuggestionsValidateBeforeCall(entityType, tags, name, count, null, null);
Type localVarReturnType = new TypeToken<TagsEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get tag suggestions
Get tag suggestions for applications, device types that have been most used with a group of tags.
@param entityType Entity type name. (optional)
@param tags Comma separated list of tags. (optional)
@param name Name of tags used for type ahead. (optional)
@param count Number of results to return. Max 10. (optional)
@return ApiResponse<TagsEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public TagsEnvelope getTagsByCategories(String categories) throws ApiException {
ApiResponse<TagsEnvelope> resp = getTagsByCategoriesWithHttpInfo(categories);
return resp.getData();
} | Get all tags of categories
Get all tags related to the list of categories
@param categories Comma separated list of categories. (optional)
@return TagsEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<TagsEnvelope> getTagsByCategoriesWithHttpInfo(String categories) throws ApiException {
com.squareup.okhttp.Call call = getTagsByCategoriesValidateBeforeCall(categories, null, null);
Type localVarReturnType = new TypeToken<TagsEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get all tags of categories
Get all tags related to the list of categories
@param categories Comma separated list of categories. (optional)
@return ApiResponse<TagsEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public RuleEnvelope createRule(RuleCreationInfo ruleInfo, String userId) throws ApiException {
ApiResponse<RuleEnvelope> resp = createRuleWithHttpInfo(ruleInfo, userId);
return resp.getData();
} | Create Rule
Create a new Rule
@param ruleInfo Rule object that needs to be added (required)
@param userId User ID (required)
@return RuleEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<RuleEnvelope> createRuleWithHttpInfo(RuleCreationInfo ruleInfo, String userId) throws ApiException {
com.squareup.okhttp.Call call = createRuleValidateBeforeCall(ruleInfo, userId, null, null);
Type localVarReturnType = new TypeToken<RuleEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Create Rule
Create a new Rule
@param ruleInfo Rule object that needs to be added (required)
@param userId User ID (required)
@return ApiResponse<RuleEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public RuleEnvelope deleteRule(String ruleId) throws ApiException {
ApiResponse<RuleEnvelope> resp = deleteRuleWithHttpInfo(ruleId);
return resp.getData();
} | Delete Rule
Delete a Rule
@param ruleId Rule ID. (required)
@return RuleEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<RuleEnvelope> deleteRuleWithHttpInfo(String ruleId) throws ApiException {
com.squareup.okhttp.Call call = deleteRuleValidateBeforeCall(ruleId, null, null);
Type localVarReturnType = new TypeToken<RuleEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Delete Rule
Delete a Rule
@param ruleId Rule ID. (required)
@return ApiResponse<RuleEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public RuleEnvelope getRule(String ruleId) throws ApiException {
ApiResponse<RuleEnvelope> resp = getRuleWithHttpInfo(ruleId);
return resp.getData();
} | Get Rule
Get a rule using the Rule ID
@param ruleId Rule ID. (required)
@return RuleEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public RuleEnvelope updateRule(String ruleId, RuleUpdateInfo ruleInfo) throws ApiException {
ApiResponse<RuleEnvelope> resp = updateRuleWithHttpInfo(ruleId, ruleInfo);
return resp.getData();
} | Update Rule
Update an existing Rule
@param ruleId Rule ID. (required)
@param ruleInfo Rule object that needs to be updated (required)
@return RuleEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<RuleEnvelope> updateRuleWithHttpInfo(String ruleId, RuleUpdateInfo ruleInfo) throws ApiException {
com.squareup.okhttp.Call call = updateRuleValidateBeforeCall(ruleId, ruleInfo, null, null);
Type localVarReturnType = new TypeToken<RuleEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Update Rule
Update an existing Rule
@param ruleId Rule ID. (required)
@param ruleInfo Rule object that needs to be updated (required)
@return ApiResponse<RuleEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public boolean recover() throws IOException {
if (!input.isCached()) {
throw new IllegalStateException("can't recover using input that isn't cached");
}
synchronized (input) {
// Seek a byte after last position
input.seek(pos + 1);
int tag = input.read();
while (tag != 28) {
if (tag == -1) {
// We've reached EOF, no more datasets to return
close();
return false;
}
tag = input.read();
}
pos = input.position() - 1;
input.seek(pos);
return true;
}
} | Tries to recover from errors that occured during last call to read.
Searches for next start or record tag (0x1C) in input stream. Can be
called only on cached inputs
@return true if IIMReader has recovered from error and you can use read
to read next dataset
@throws IOException
if stream can't be read
@throws IllegalStateException
if input isn't cached |
protected void addNeighbor(Queue<ColorPoint> queue, int px, int py, int color, Feature component) {
if (!inBoundary(px, py, component)) {
return;
}
if (!mask.isTouched(px, py)) {
queue.add(new ColorPoint(px, py, color));
}
} | May have to be changed to let multiple touch |
public double Function1D(double x) {
return Math.exp(x * x / (-2 * sqrSigma)) / (Math.sqrt(2 * Math.PI) * sigma);
} | 1-D Gaussian function.
@param x value.
@return Function's value at point x. |
public double Function2D(double x, double y) {
return Math.exp(-(x * x + y * y) / (2 * sqrSigma)) / (2 * Math.PI * sqrSigma);
} | 2-D Gaussian function.
@param x value.
@param y value.
@return Function's value at point (x,y). |
public double[] Kernel1D(int size) {
if (((size % 2) == 0) || (size < 3) || (size > 101)) {
try {
throw new Exception("Wrong size");
} catch (Exception e) {
e.printStackTrace();
}
}
int r = size / 2;
// kernel
double[] kernel = new double[size];
// compute kernel
for (int x = -r, i = 0; i < size; x++, i++) {
kernel[i] = Function1D(x);
}
return kernel;
} | 1-D Gaussian kernel.
@param size Kernel size (should be odd), [3, 101].
@return Returns 1-D Gaussian kernel of the specified size. |
public double[][] Kernel2D(int size) {
if (((size % 2) == 0) || (size < 3) || (size > 101)) {
try {
throw new Exception("Wrong size");
} catch (Exception e) {
e.printStackTrace();
}
}
int r = size / 2;
double[][] kernel = new double[size][size];
// compute kernel
double sum = 0;
for (int y = -r, i = 0; i < size; y++, i++) {
for (int x = -r, j = 0; j < size; x++, j++) {
kernel[i][j] = Function2D(x, y);
sum += kernel[i][j];
}
}
for (int i = 0; i < kernel.length; i++) {
for (int j = 0; j < kernel[0].length; j++) {
kernel[i][j] /= sum;
}
}
return kernel;
} | 2-D Gaussian kernel.
@param size Kernel size (should be odd), [3, 101].
@return Returns 2-D Gaussian kernel of specified size. |
public ArrayList<IntPoint> process(ImageSource fastBitmap) {
//FastBitmap l = new FastBitmap(fastBitmap);
if (points == null) {
apply(fastBitmap);
}
int width = fastBitmap.getWidth();
int height = fastBitmap.getHeight();
points = new ArrayList<IntPoint>();
if (fastBitmap.isGrayscale()) {
for (int x = 0; x < height; x++) {
for (int y = 0; y < width; y++) {
if (fastBitmap.getRGB(y, x) == 255) points.add(new IntPoint(y, x));
}
}
} else {
for (int x = 0; x < height; x++) {
for (int y = 0; y < width; y++) {
// TODO Check for green and blue?
if (fastBitmap.getR(y, x) == 255) points.add(new IntPoint(y, x));
}
}
}
return points;
} | Get points after extract boundary.
@param fastBitmap Image to be processed.
@return List of points. |
public DoublePoint Add(DoublePoint point1, DoublePoint point2) {
DoublePoint result = new DoublePoint(point1);
result.Add(point2);
return result;
} | Adds values of two points.
@param point1 DoublePoint.
@param point2 DoublePoint.
@return A new DoublePoint with the add operation. |
public DoublePoint Subtract(DoublePoint point1, DoublePoint point2) {
DoublePoint result = new DoublePoint(point1);
result.Subtract(point2);
return result;
} | Subtract values of two points.
@param point1 DoublePoint.
@param point2 DoublePoint.
@return A new DoublePoint with the subtraction operation. |
public DoublePoint Multiply(DoublePoint point1, DoublePoint point2) {
DoublePoint result = new DoublePoint(point1);
result.Multiply(point2);
return result;
} | Multiply values of two points.
@param point1 DoublePoint.
@param point2 DoublePoint.
@return A new DoublePoint with the multiplication operation. |
public DoublePoint Divide(DoublePoint point1, DoublePoint point2) {
DoublePoint result = new DoublePoint(point1);
result.Divide(point2);
return result;
} | Divides values of two points.
@param point1 DoublePoint.
@param point2 DoublePoint.
@return A new DoublePoint with the division operation. |
public static void Forward(double[] data) {
double[] result = new double[data.length];
for (int k = 0; k < result.length; k++) {
double sum = 0;
for (int n = 0; n < data.length; n++) {
double theta = ((2.0 * Math.PI) / data.length) * k * n;
sum += data[n] * cas(theta);
}
result[k] = (1.0 / Math.sqrt(data.length)) * sum;
}
for (int i = 0; i < result.length; i++) {
data[i] = result[i];
}
} | 1-D Forward Discrete Hartley Transform.
@param data Data. |
public static void Forward(double[][] data) {
double[][] result = new double[data.length][data[0].length];
for (int m = 0; m < data.length; m++) {
for (int n = 0; n < data[0].length; n++) {
double sum = 0;
for (int i = 0; i < result.length; i++) {
for (int k = 0; k < data.length; k++) {
sum += data[i][k] * cas(((2.0 * Math.PI) / data.length) * (i * m + k * n));
}
result[m][n] = (1.0 / data.length) * sum;
}
}
}
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[0].length; j++) {
data[i][j] = result[i][j];
}
}
} | 2-D Forward Discrete Hartley Transform.
@param data Data. |
public PropertiesEnvelope createUserProperties(String userId, AppProperties properties, String aid) throws ApiException {
ApiResponse<PropertiesEnvelope> resp = createUserPropertiesWithHttpInfo(userId, properties, aid);
return resp.getData();
} | Create User Application Properties
Create application properties for a user
@param userId User Id (required)
@param properties Properties to be updated (required)
@param aid Application ID (optional)
@return PropertiesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public PropertiesEnvelope deleteUserProperties(String userId, String aid) throws ApiException {
ApiResponse<PropertiesEnvelope> resp = deleteUserPropertiesWithHttpInfo(userId, aid);
return resp.getData();
} | Delete User Application Properties
Deletes a user's application properties
@param userId User Id (required)
@param aid Application ID (optional)
@return PropertiesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<PropertiesEnvelope> deleteUserPropertiesWithHttpInfo(String userId, String aid) throws ApiException {
com.squareup.okhttp.Call call = deleteUserPropertiesValidateBeforeCall(userId, aid, null, null);
Type localVarReturnType = new TypeToken<PropertiesEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Delete User Application Properties
Deletes a user's application properties
@param userId User Id (required)
@param aid Application ID (optional)
@return ApiResponse<PropertiesEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<UserEnvelope> getSelfWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = getSelfValidateBeforeCall(null, null);
Type localVarReturnType = new TypeToken<UserEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get Current User Profile
Get's the current user's profile
@return ApiResponse<UserEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public DeviceTypesEnvelope getUserDeviceTypes(String userId, Integer offset, Integer count, Boolean includeShared) throws ApiException {
ApiResponse<DeviceTypesEnvelope> resp = getUserDeviceTypesWithHttpInfo(userId, offset, count, includeShared);
return resp.getData();
} | Get User Device Types
Retrieve User's Device Types
@param userId User ID. (required)
@param offset Offset for pagination. (optional)
@param count Desired count of items in the result set (optional)
@param includeShared Optional. Boolean (true/false) - If false, only return the user's device types. If true, also return device types shared by other users. (optional)
@return DeviceTypesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public ApiResponse<DeviceTypesEnvelope> getUserDeviceTypesWithHttpInfo(String userId, Integer offset, Integer count, Boolean includeShared) throws ApiException {
com.squareup.okhttp.Call call = getUserDeviceTypesValidateBeforeCall(userId, offset, count, includeShared, null, null);
Type localVarReturnType = new TypeToken<DeviceTypesEnvelope>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | Get User Device Types
Retrieve User's Device Types
@param userId User ID. (required)
@param offset Offset for pagination. (optional)
@param count Desired count of items in the result set (optional)
@param includeShared Optional. Boolean (true/false) - If false, only return the user's device types. If true, also return device types shared by other users. (optional)
@return ApiResponse<DeviceTypesEnvelope>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
public DevicesEnvelope getUserDevices(String userId, Integer offset, Integer count, Boolean includeProperties, String owner, Boolean includeShareInfo, String dtid) throws ApiException {
ApiResponse<DevicesEnvelope> resp = getUserDevicesWithHttpInfo(userId, offset, count, includeProperties, owner, includeShareInfo, dtid);
return resp.getData();
} | Get User Devices
Retrieve User's Devices
@param userId User ID (required)
@param offset Offset for pagination. (optional)
@param count Desired count of items in the result set (optional)
@param includeProperties Optional. Boolean (true/false) - If false, only return the user's device types. If true, also return device types shared by other users. (optional)
@param owner Return owned and/or shared devices. Default to ALL. (optional)
@param includeShareInfo Include share info (optional)
@param dtid Return only devices of this device type. If empty, assumes all device types allowed by the authorization. (optional)
@return DevicesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.