edu.stanford.rsl.konrad.geometry
Class General

java.lang.Object
  extended by edu.stanford.rsl.konrad.geometry.General

public abstract class General
extends java.lang.Object

All kinds of geometric routines that are not specific to some geometric object or interact on a set of these.

Author:
Andreas Keil

Field Summary
static SimpleVector E_X
           
static SimpleVector E_Y
           
static SimpleVector E_Z
           
 
Constructor Summary
General()
           
 
Method Summary
 double angle(SimpleVector a, SimpleVector b)
          Computes the angle between two vectors;
static boolean areColinear(SimpleVector v1, SimpleVector v2, double delta)
           
static SimpleVector augmentToHomgeneous(SimpleVector v)
           
static SimpleMatrix createHomAffineMotionMatrix(SimpleMatrix A)
           
static SimpleMatrix createHomAffineMotionMatrix(SimpleMatrix A, SimpleVector t)
           
static SimpleMatrix createHomAffineMotionMatrix(SimpleVector t)
           
static java.util.ArrayList<Triangle> createTrianglesFromPlanarPointSet(java.util.ArrayList<PointND> points)
          Creates a triangle mesh for a planar set of points.
static SimpleVector crossProduct(SimpleVector v1, SimpleVector v2)
           
static double euclideanDistance(SimpleVector v1, SimpleVector v2)
           
static java.util.ArrayList<PointND> extractCandidatePoints(ij.process.ImageProcessor houghSpace, double offset)
          Extract points from an ImageProcessor which exceed a certain value
static java.util.ArrayList<PointND> extractClusterCenter(java.util.ArrayList<PointND> pointList, double distance)
          Extracts cluster centers from an ordered List of points.
static PointND getGeometricCenter(java.util.ArrayList<PointND> list)
          Compute the geometric center of a set of points
static PointND getGeometricCenter(java.util.Iterator<PointND> list)
          Compute the geometric center of an iterator of points
static PointND getGeometricCenter(PointND[] pts)
           
static boolean intersectRayWithCuboid(SimpleVector origin, SimpleVector dir, SimpleVector cubmin, SimpleVector cubmax, double[] distanceNearAndFar)
          Computes the two intersections of a ray with a cuboid, called entry and exit point where the ray is specified by the given line origin and ray direction.
static java.util.ArrayList<PointND> intersectRayWithCuboid(StraightLine line, PointND min, PointND max)
           
static boolean isNormalizeMode()
           
static boolean isWithinCuboid(PointND point, PointND min, PointND max)
          Method to check whether a point is within a given cubiod defined by min and max.
static SimpleVector normalizeFromHomogeneous(SimpleVector v)
           
static void setNormalizeMode(boolean mode)
           
static void splitHomAffineMotionMatrix(SimpleMatrix At, SimpleMatrix A, SimpleVector t)
           
static double toDegrees(double radians)
           
static double toRadians(double degrees)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

E_X

public static final SimpleVector E_X

E_Y

public static final SimpleVector E_Y

E_Z

public static final SimpleVector E_Z
Constructor Detail

General

public General()
Method Detail

isNormalizeMode

public static boolean isNormalizeMode()

setNormalizeMode

public static void setNormalizeMode(boolean mode)

crossProduct

public static SimpleVector crossProduct(SimpleVector v1,
                                        SimpleVector v2)

areColinear

public static boolean areColinear(SimpleVector v1,
                                  SimpleVector v2,
                                  double delta)

angle

public double angle(SimpleVector a,
                    SimpleVector b)
Computes the angle between two vectors;

Parameters:
a -
b -
Returns:
the angle in radians

euclideanDistance

public static double euclideanDistance(SimpleVector v1,
                                       SimpleVector v2)

augmentToHomgeneous

public static SimpleVector augmentToHomgeneous(SimpleVector v)

normalizeFromHomogeneous

public static SimpleVector normalizeFromHomogeneous(SimpleVector v)

createHomAffineMotionMatrix

public static SimpleMatrix createHomAffineMotionMatrix(SimpleMatrix A,
                                                       SimpleVector t)

createHomAffineMotionMatrix

public static SimpleMatrix createHomAffineMotionMatrix(SimpleMatrix A)

createHomAffineMotionMatrix

public static SimpleMatrix createHomAffineMotionMatrix(SimpleVector t)

toRadians

public static double toRadians(double degrees)

toDegrees

public static double toDegrees(double radians)

splitHomAffineMotionMatrix

public static void splitHomAffineMotionMatrix(SimpleMatrix At,
                                              SimpleMatrix A,
                                              SimpleVector t)

intersectRayWithCuboid

public static java.util.ArrayList<PointND> intersectRayWithCuboid(StraightLine line,
                                                                  PointND min,
                                                                  PointND max)

isWithinCuboid

public static boolean isWithinCuboid(PointND point,
                                     PointND min,
                                     PointND max)
Method to check whether a point is within a given cubiod defined by min and max.

Parameters:
point - the point
min - the minimum coordinate of the cuboid
max - the maximum coordinate of the cuboid.
Returns:
true, if the point is inside

intersectRayWithCuboid

public static boolean intersectRayWithCuboid(SimpleVector origin,
                                             SimpleVector dir,
                                             SimpleVector cubmin,
                                             SimpleVector cubmax,
                                             double[] distanceNearAndFar)
Computes the two intersections of a ray with a cuboid, called entry and exit point where the ray is specified by the given line origin and ray direction. The entry and exit points are returned as distances from the line origin along the ray. The world coordinates of the entry and exit points may be computed as follows:
%preamble{\usepackage{amsmath}} \begin{align*}

Parameters:
origin - The ray origin in world coordinates.
dir - The normalized(!) ray direction (corresponding to a specific pixel) in world coordinates [rd_x rd_y rd_z].
cubmin - The cuboid's minimal planes given as [min_x, min_y, min_z] in world coordinates.
cubmax - The cuboid's maximal planes given as [max_x, max_y, max_z] in world coordinates.
distanceNearAndFar - Return values. In case of a hit: Positive distances (in world coordinate units) of nearest and farthest plane intersection.
Returns:
Boolean value which is true if the ray intersects with the bounding box and false otherwise.
See Also:
http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter0.htm, http://dx.doi.org/10.1145/15922.15916

getGeometricCenter

public static PointND getGeometricCenter(java.util.ArrayList<PointND> list)
Compute the geometric center of a set of points

Parameters:
list - the set of points
Returns:
the geometric center

getGeometricCenter

public static PointND getGeometricCenter(java.util.Iterator<PointND> list)
Compute the geometric center of an iterator of points

Parameters:
list - the set of points
Returns:
the geometric center

extractCandidatePoints

public static java.util.ArrayList<PointND> extractCandidatePoints(ij.process.ImageProcessor houghSpace,
                                                                  double offset)
Extract points from an ImageProcessor which exceed a certain value

Parameters:
houghSpace - the ImageProcessor
offset - the threshold for extraction
Returns:
the list of candidate points

extractClusterCenter

public static java.util.ArrayList<PointND> extractClusterCenter(java.util.ArrayList<PointND> pointList,
                                                                double distance)
Extracts cluster centers from an ordered List of points. Points must be ordered first with respect to x, then to y coordinate. Algorithm assumes that only one point may appear in the same row, i.e., all clusters must be separable via the y direction. A cluster center is then computed as the geometric center of the points in the same cluster. Algorithm is fast, but very restricted.

Parameters:
pointList - the list of candidate points
distance - the minimal distance between clusters
Returns:
the list of cluster centers

getGeometricCenter

public static PointND getGeometricCenter(PointND[] pts)

createTrianglesFromPlanarPointSet

public static java.util.ArrayList<Triangle> createTrianglesFromPlanarPointSet(java.util.ArrayList<PointND> points)
Creates a triangle mesh for a planar set of points. The geometric center is estimated and each subsequent set of points is connected with the center to form the mesh. Note that the points must be neighboring points in the ArrayList. Such a set of points can be obtained using for example a convex hull algorithm. This method can also be used to close a BSplineSurface.

Parameters:
points - the points
Returns:
the list of triangles
See Also:
ConvexHull, SurfaceBSpline