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<VectorXYZ[]> createShapeExtrusionAlong(VectorXYZ[] shape, List<VectorXYZ> extrusionPath, List<VectorXYZ> upVectors)
          creates triangle stip vectors for a shape extruded along a line of coordinates
static VectorXYZ[] createVectorsForTriangleStripBetween(List<? extends VectorXYZ> leftOutline, List<? extends VectorXYZ> rightOutline)
          creates a triangle strip between two outlines with identical number of vectors
static VectorXYZ[] createVectorsForVerticalTriangleStrip(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 boolean piercesWorldObject(VectorXZ pos, Collection<WorldObject> worldObjects)
          checks whether a position is on the area covered by a WorldObjectWithOutline from a collection of WorldObjects.
static VectorXYZ[] transformShape(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

createVectorsForVerticalTriangleStrip

public static final VectorXYZ[] createVectorsForVerticalTriangleStrip(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


createVectorsForTriangleStripBetween

public static final VectorXYZ[] createVectorsForTriangleStripBetween(List<? extends VectorXYZ> leftOutline,
                                                                     List<? extends 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<VectorXYZ[]> createShapeExtrusionAlong(VectorXYZ[] shape,
                                                                List<VectorXYZ> extrusionPath,
                                                                List<VectorXYZ> upVectors)
creates triangle stip 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 vector arrays for triangle strips

transformShape

public static final VectorXYZ[] transformShape(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(VectorXYZ[], List, List)

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

piercesWorldObject

public static final boolean piercesWorldObject(VectorXZ pos,
                                               Collection<WorldObject> worldObjects)
checks whether a position is 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.

Returns:
true if the position is on at least one of the WorldObjectWithOutline from the collection