Changeset 2901


Ignore:
Timestamp:
06/21/07 13:47:08 (12 years ago)
Author:
sorber
Message:

Added JUnit unit tests for MathUtil. Added another vector math method to MathUtil.

Location:
trunk/loci/visbio/util
Files:
1 added
1 edited

Legend:

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

    r2885 r2901  
    378378    } 
    379379    return r; 
     380  } 
     381 
     382  /**  
     383   * Test whether two vectors are coordinate-wise opposite. 
     384   * @param u1 a unit vector 
     385   * @param u2 another unit vector  
     386   */  
     387  public static boolean opposite(float[] v1, float[] v2) { 
     388    if (v1.length != v2.length) return false; 
     389    boolean opposite = true; 
     390    for (int i=0; i<v1.length; i++) { 
     391      if (v1[i] != -v2[i]) { 
     392        opposite = false; 
     393        break; 
     394      } 
     395    } 
     396    return opposite; 
    380397  } 
    381398 
Note: See TracChangeset for help on using the changeset viewer.