org.osm2world.core.world.modules.common
Class WorldModuleGeometryUtil

Object
  extended by WorldModuleGeometryUtil

public final class WorldModuleGeometryUtil
extends Object

offers some geometry-related utility functions for WorldModules


Method Summary
static List<VectorXYZ> createLineBetween(List<VectorXYZ> leftOutline, List<VectorXYZ> rightOutline, float ratio)
           
static List<List<VectorXYZ>> createShapeExtrusionAlong(List<VectorXYZ> shape, List<VectorXYZ> extrusionPath, List<VectorXYZ> upVectors)
          creates triangle strip vectors for a shape extruded along a line of coordinates
static List<VectorXYZ> createTriangleStripBetween(List<VectorXYZ> leftOutline, List<VectorXYZ> rightOutline)
          creates a triangle strip between two outlines with identical number of vectors
static List<VectorXYZ> createVerticalTriangleStrip(List<? extends VectorXYZ> baseLine, float stripLowerYBound, float stripUpperYBound)
          creates the vectors for a vertical triangle strip at a given elevation above a line of points
static void filterWorldObjectCollisions(Collection<VectorXZ> positions, Collection<WorldObject> worldObjects)
          removes positions from a collection if they are on the area covered by a WorldObjectWithOutline from a collection of WorldObjects.
static List<VectorXYZ> rotateShapeX(List<VectorXYZ> shape, double angle, double posY, double posZ)
          creates an rotated version of a list of vectors by rotating them by the given angle around the parallel of the x axis defined by the given Y and Z coordinates
static List<VectorXYZ> transformShape(List<VectorXYZ> shape, VectorXYZ center, VectorXYZ forward, VectorXYZ up)
          moves a shape that was defined at the origin to a new position.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createVerticalTriangleStrip

public static final List<VectorXYZ> createVerticalTriangleStrip(List<? extends VectorXYZ> baseLine,
                                                                float stripLowerYBound,
                                                                float stripUpperYBound)
creates the vectors for a vertical triangle strip at a given elevation above a line of points


createTriangleStripBetween

public static final List<VectorXYZ> createTriangleStripBetween(List<VectorXYZ> leftOutline,
                                                               List<VectorXYZ> rightOutline)
creates a triangle strip between two outlines with identical number of vectors


createLineBetween

public static final List<VectorXYZ> createLineBetween(List<VectorXYZ> leftOutline,
                                                      List<VectorXYZ> rightOutline,
                                                      float ratio)
Parameters:
ratio - 0 is at left outline, 1 at right outline

createShapeExtrusionAlong

public static final List<List<VectorXYZ>> createShapeExtrusionAlong(List<VectorXYZ> shape,
                                                                    List<VectorXYZ> extrusionPath,
                                                                    List<VectorXYZ> upVectors)
creates triangle strip vectors for a shape extruded along a line of coordinates

Parameters:
shape - shape relative to origin
extrusionPath - nodes to extrude the shape along; needs at least 2 nodes
upVectors - vector for "up" direction at each extrusion path node. You can use Collections.nCopies(int, Object) if you want the same up vector for all nodes.
Returns:
list of triangle strip vertex lists

rotateShapeX

public static final List<VectorXYZ> rotateShapeX(List<VectorXYZ> shape,
                                                 double angle,
                                                 double posY,
                                                 double posZ)
creates an rotated version of a list of vectors by rotating them by the given angle around the parallel of the x axis defined by the given Y and Z coordinates

Parameters:
angle - rotation angle in degrees

transformShape

public static final List<VectorXYZ> transformShape(List<VectorXYZ> shape,
                                                   VectorXYZ center,
                                                   VectorXYZ forward,
                                                   VectorXYZ up)
moves a shape that was defined at the origin to a new position. This is used by createShapeExtrusionAlong(List, List, List)

Parameters:
center - new center coordinate
forward - new forward direction (unit vector)
up - new up direction (unit vector)
Returns:
list of 3d vectors; same length as shape

filterWorldObjectCollisions

public static final void filterWorldObjectCollisions(Collection<VectorXZ> positions,
                                                     Collection<WorldObject> worldObjects)
removes positions from a collection if they are on the area covered by a WorldObjectWithOutline from a collection of WorldObjects. This can be used to avoid placing trees, bridge pillars and other randomly distributed features on roads, rails or other similar places where they don't belong.