deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.model.spatialschema
Class LinearizationUtil

java.lang.Object
  extended by org.deegree.model.spatialschema.LinearizationUtil

public class LinearizationUtil
extends Object

Utility class for the linearization of arcs and circles.

Version:
$Revision: $, $Date: 9 May 2008 13:09:29$
Author:
Moataz Elmasry, last edited by: $Author: elmasri$

Constructor Summary
LinearizationUtil()
           
 
Method Summary
static boolean areCollinear(Position p0, Position p1, Position p2)
          Tests if the given three points are collinear.
protected static javax.vecmath.Vector2d calcVector(Position p0, Position p1)
          Finds the vector between two points. which is the difference between p1 and p0 and the direction is from p0 to p1.
protected static Position[] doubleToPosition(double[] doubles)
          Transforms an array of double to an array of Position
(package private) static Position findCircleCenter(Position p0, Position p1, Position p2)
          Finds the center of a cirlce/arc using three points that lie on the circle.
(package private) static boolean isClockwise(Position p0, Position p1, Position p2)
          Returns whether the order of the given three points is clockwise or counterclockwise.
static Position[] linearizeArc(Position p0, Position p1, Position p2)
          Takes in a three Position of an arc and computes a linearized Arc (linestring) using 150 positions/vertices
static Position[] linearizeArc(Position p0, Position p1, Position p2, int numberOfOpPositions)
          Takes in a three Positions of an Arc and computes a linearized Arc (linestring).
static Position[] linearizeCircle(Position p0, Position p1, Position p2, int numberOfPositions)
          Calculates a sequence of Positions on the arc of a circle.
protected static double[] positionToDouble(Position[] positions)
          Transforms an array of Position to an array of double
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearizationUtil

public LinearizationUtil()
Method Detail

linearizeArc

public static Position[] linearizeArc(Position p0,
                                      Position p1,
                                      Position p2)
Takes in a three Position of an arc and computes a linearized Arc (linestring) using 150 positions/vertices

Parameters:
p0 -
p1 -
p2 -
Returns:
An array of linearized Positions

linearizeArc

public static Position[] linearizeArc(Position p0,
                                      Position p1,
                                      Position p2,
                                      int numberOfOpPositions)
Takes in a three Positions of an Arc and computes a linearized Arc (linestring).

Parameters:
p0 -
p1 -
p2 -
numberOfOpPositions - the number of linearized Positions to produce
Returns:
An array of linearized Positions

linearizeCircle

public static Position[] linearizeCircle(Position p0,
                                         Position p1,
                                         Position p2,
                                         int numberOfPositions)
Calculates a sequence of Positions on the arc of a circle.

The circle is constructed from the input points: All three points belong to the arc of the circle. They must be distinct and non-colinear. To form a complete circle, the arc is extended past the third control point until the first control point is encountered.

Parameters:
p0 - start point on the arc of the circle
p1 - second point on the arc of the circle
p2 - third point on the arc of the circle
numberOfPositions - number of interpolation points, the returned array contains numberOfPositions+1 entries, to ensure that the first point is identical to the last
Returns:
Position array with numberOfPositions+1 entries, first entry and last entry are identical to p0
Throws:
IllegalArgumentException - if no order can be determined, because the points are identical or co-linear

isClockwise

static final boolean isClockwise(Position p0,
                                 Position p1,
                                 Position p2)
                          throws IllegalArgumentException
Returns whether the order of the given three points is clockwise or counterclockwise. Uses the (signed) area of a planar triangle to get to know about the order of the points.

Parameters:
p0 - first point
p1 - second point
p2 - third point
Returns:
true, if order is clockwise, otherwise false
Throws:
IllegalArgumentException - if no order can be determined, because the points are identical or co-linear

areCollinear

public static boolean areCollinear(Position p0,
                                   Position p1,
                                   Position p2)
Tests if the given three points are collinear.

NOTE: Only this method should be used throughout the whole linearization process for testing collinearity to avoid inconsistent results (the necessary EPSILON would differ).

Parameters:
p0 -
p1 -
p2 -
Returns:
true if the points are collinear, false otherwise

positionToDouble

protected static double[] positionToDouble(Position[] positions)
Transforms an array of Position to an array of double

Parameters:
positions -
Returns:
array of double

doubleToPosition

protected static Position[] doubleToPosition(double[] doubles)
Transforms an array of double to an array of Position

Parameters:
doubles -
Returns:
generated array of Position or null if doubles%2 != 0

findCircleCenter

static Position findCircleCenter(Position p0,
                                 Position p1,
                                 Position p2)
                          throws IllegalArgumentException
Finds the center of a cirlce/arc using three points that lie on the circle. Thanks to wikipedia: http://en.wikipedia.org/wiki/Circumradius#Coordinates_of_circumcenter.

Parameters:
p0 -
p1 -
p2 -
Returns:
center of the circle
Throws:
IllegalArgumentException - if the points are co linear, e.g. on a line.

calcVector

protected static javax.vecmath.Vector2d calcVector(Position p0,
                                                   Position p1)
Finds the vector between two points. which is the difference between p1 and p0 and the direction is from p0 to p1.

Parameters:
p0 -
p1 -
Returns:
calculated vector

deegree 2.3 (2010/04/09 10:10 build-4-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org