# Changeset 2855

Ignore:
Timestamp:
06/12/07 10:00:10 (13 years ago)
Message:

File:
1 edited

Unmodified
Removed
• ## trunk/loci/visbio/util/MathUtil.java

 r2725 } return Math.sqrt(sum); } /** * Computes the minimum distance between the point p and the point v in * double precision. * * @param p Coordinates of the first point * @param v Coordinates of the second point */ public static double getDistance (float[] p, float[] v) { double[] pp = new double[p.length]; double[] vv = new double[v.length]; return getDistance(pp, vv); } return result; } // -- Vector Math Methods -- /** Computes the cross product of two 2D vectors. */ public static float cross2D(float[] v1, float[] v2) { return v1[0] * v2[1] - v1[1] * v2[0]; } /** Computes the N-D unit vector in the direction as the vector supplied. */ public static float[] unit(float[] v) { float mag = mag(v); float[] vHat = new float[v.length]; for (int i=0; i hi) { between = false; break; } } return between; } /** Gets a unit vector which bisects (p1 - p2) and (p3 - p2).  */ public static float[] getBisectorVector2D(float[] p1, float[] p2, float[] p3) { System.out.println("entering getBisectorVector2D ..."); //TEMP float[] v1 = vector(p1, p2); float[] v2 = vector(p3, p2); float[] v1Hat = unit(v1); float[] v2Hat = unit(v2); float[] vAvg = {(v1Hat[0] + v2Hat[0]) / 2f, (v1Hat[1] + v2Hat[1]) / 2f}; float[] bisector; if (vAvg[0] == 0 && vAvg[1] == 0) { float[] aBisector = new float[]{-v1[1], v1[0]}; bisector = unit(aBisector); } else { bisector = unit(vAvg); } // System.out.println("v1 = " + v1[0] + " " + v1[1]); // System.out.println("v2 = " + v2[0] + " " + v2[1]); // System.out.println("v1Hat = " + v1Hat[0] + " " + v1Hat[1]); // System.out.println("v2Hat = " + v2Hat[0] + " " + v2Hat[1]); // System.out.println("vAvg = " + vAvg[0] + " " + vAvg[1]); // System.out.println("bisector = " + bisector[0] + " " + bisector[1]); // System.out.println("p1a = " + p1a[0] + " " + p1a[1]); // System.out.println("p2a = " + p2a[0] + " " + p2a[1]); // System.out.println("p4a = " + p4a[0] + " " + p4a[1]); // System.out.println("v42 = " + v42[0] + " " + v42[1]); // System.out.println("v42Hat = " +v42Hat[0] + " " + v42Hat[1]); return bisector; } /** Adds two N-D vectors. */ public static float[] add(float[] v1, float[] v2) { // v1 and v2 should have same lengths if (v1.length != v2.length) return null; int len = v1.length; float[] r = new float[v1.length]; for (int i=0; i
Note: See TracChangeset for help on using the changeset viewer.